Skip to content

Commit e90318f

Browse files
Rcpp now compiles header only
1 parent 67e7a18 commit e90318f

6 files changed

Lines changed: 103 additions & 94 deletions

File tree

inst/include/Rcpp/api/meat/Dimension.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
namespace Rcpp{
2222

23-
Dimension::Dimension(SEXP dims_) : dims( as< std::vector<int> >(dims_) ){}
23+
inline Dimension::Dimension(SEXP dims_) : dims( as< std::vector<int> >(dims_) ){}
2424

2525
inline Dimension::operator SEXP() const {
2626
return wrap( dims.begin(), dims.end() ) ;

inst/include/Rcpp/exceptions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#ifndef Rcpp__exceptions__h
2323
#define Rcpp__exceptions__h
2424

25-
SEXP stack_trace( const char *file, int line) ;
2625
#define GET_STACKTRACE() stack_trace( __FILE__, __LINE__ )
2726

2827
namespace Rcpp{

inst/include/Rcpp/internal/caster.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ inline std::complex<double> caster<Rcomplex,std::complex<double> >( Rcomplex fro
5757
return std_complex_caster<double>(from);
5858
}
5959

60-
template<> std::complex<float> caster<Rcomplex,std::complex<float> >( Rcomplex from){
60+
template<>
61+
inline std::complex<float> caster<Rcomplex,std::complex<float> >( Rcomplex from){
6162
return std_complex_caster<float>(from) ;
6263
}
6364

inst/include/Rcpp/internal/r_coerce.h

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ inline double r_coerce<RAWSXP,REALSXP>(Rbyte from){
8888
}
8989

9090
// -> LGLSXP
91-
template <> int r_coerce<REALSXP,LGLSXP>(double from){
91+
template <>
92+
inline int r_coerce<REALSXP,LGLSXP>(double from){
9293
return R_IsNA(from) ? NA_LOGICAL : (from!=0.0);
9394
}
9495

@@ -220,7 +221,8 @@ inline const char* coerce_to_string<CPLXSXP>(Rcomplex x){
220221
snprintf(tmp3, 255, "%s+%si", dropTrailing0(tmp1, '.'), dropTrailing0(tmp2, '.'));
221222
return tmp3;
222223
}
223-
template <> const char* coerce_to_string<REALSXP>(double x){
224+
template <>
225+
inline const char* coerce_to_string<REALSXP>(double x){
224226
//int w,d,e ;
225227
// cf src/main/format.c in R's sources:
226228
// The return values are
@@ -239,17 +241,20 @@ template <> const char* coerce_to_string<REALSXP>(double x){
239241
return dropTrailing0(tmp, '.');
240242
}
241243
#define NB 1000
242-
template <> const char* coerce_to_string<INTSXP >(int from) {
244+
template <>
245+
inline const char* coerce_to_string<INTSXP >(int from) {
243246
static char buffer[NB] ;
244247
snprintf( buffer, NB, "%*d", integer_width(from), from );
245248
return buffer ;
246249
}
247-
template <> const char* coerce_to_string<RAWSXP >(Rbyte from){
250+
template <>
251+
inline const char* coerce_to_string<RAWSXP >(Rbyte from){
248252
static char buff[3];
249253
::sprintf(buff, "%02x", from);
250254
return buff ;
251255
}
252-
template <> const char* coerce_to_string<LGLSXP >(int from){
256+
template <>
257+
inline const char* coerce_to_string<LGLSXP >(int from){
253258
return from == 0 ? "FALSE" : "TRUE" ;
254259
}
255260

@@ -274,7 +279,8 @@ template <>
274279
inline SEXP r_coerce<RAWSXP ,STRSXP>(Rbyte from){
275280
return Rf_mkChar( coerce_to_string<RAWSXP>(from));
276281
}
277-
template <> inline SEXP r_coerce<LGLSXP ,STRSXP>(int from){
282+
template <>
283+
inline SEXP r_coerce<LGLSXP ,STRSXP>(int from){
278284
return Rcpp::traits::is_na<LGLSXP>(from) ? NA_STRING :Rf_mkChar( coerce_to_string<LGLSXP>(from));
279285
}
280286

inst/include/Rcpp/routines.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ namespace Rcpp{
2626
SEXP Rcpp_eval(SEXP expr, SEXP env = R_GlobalEnv) ;
2727
const char* type2name(SEXP x) ;
2828
std::string demangle( const std::string& name) ;
29-
SEXP stack_trace( const char *file, int line) ;
3029
unsigned long enterRNGScope();
3130
unsigned long exitRNGScope() ;
3231
SEXP get_Rcpp_namespace() ;
3332
int* get_cache( int n ) ;
3433
SEXP rcpp_get_stack_trace() ;
3534
SEXP rcpp_set_stack_trace(SEXP) ;
3635
}
37-
36+
37+
SEXP stack_trace( const char *file, int line) ;
3838
SEXP get_string_elt(SEXP s, int i);
3939
const char* char_get_string_elt(SEXP s, int i) ;
4040
void set_string_elt(SEXP s, int i, SEXP v);
@@ -83,12 +83,6 @@ namespace Rcpp {
8383
return fun(name) ;
8484
}
8585

86-
inline SEXP stack_trace( const char *file, int line){
87-
typedef SEXP (*Fun)(const char*, int) ;
88-
static Fun fun = GET_CALLABLE("stack_trace") ;
89-
return fun(file, line) ;
90-
}
91-
9286
inline unsigned long enterRNGScope(){
9387
typedef unsigned long (*Fun)(void) ;
9488
static Fun fun = GET_CALLABLE("enterRNGScope") ;
@@ -114,7 +108,13 @@ namespace Rcpp {
114108
}
115109

116110
}
117-
111+
112+
inline SEXP stack_trace( const char *file, int line){
113+
typedef SEXP (*Fun)(const char*, int) ;
114+
static Fun fun = GET_CALLABLE("stack_trace") ;
115+
return fun(file, line) ;
116+
}
117+
118118
inline SEXP get_string_elt(SEXP s, int i){
119119
typedef SEXP (*Fun)(SEXP, int) ;
120120
static Fun fun = GET_CALLABLE("get_string_elt") ;

src/api.cpp

Lines changed: 79 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@
2424

2525
#include <Rcpp.h>
2626

27+
using namespace Rcpp ;
28+
2729
#include "internal.h"
2830
#include <R_ext/PrtUtil.h>
2931

3032
#ifdef RCPP_HAS_DEMANGLING
3133
#include <cxxabi.h>
3234
#endif
33-
35+
3436
#if defined(__GNUC__)
3537
#if defined(WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun)
3638
#else
@@ -168,81 +170,6 @@ namespace Rcpp {
168170
}
169171
}
170172

171-
// [[Rcpp::internal]]
172-
SEXP rcpp_capabilities(){
173-
Shield<SEXP> cap( Rf_allocVector( LGLSXP, 9 ) );
174-
Shield<SEXP> names( Rf_allocVector( STRSXP, 9 ) );
175-
#ifdef HAS_VARIADIC_TEMPLATES
176-
LOGICAL(cap)[0] = TRUE ;
177-
#else
178-
LOGICAL(cap)[0] = FALSE ;
179-
#endif
180-
#ifdef HAS_CXX0X_INITIALIZER_LIST
181-
LOGICAL(cap)[1] = TRUE ;
182-
#else
183-
LOGICAL(cap)[1] = FALSE ;
184-
#endif
185-
/* exceptions are always supported */
186-
LOGICAL(cap)[2] = TRUE ;
187-
188-
#ifdef HAS_TR1_UNORDERED_MAP
189-
LOGICAL(cap)[3] = TRUE ;
190-
#else
191-
LOGICAL(cap)[3] = FALSE ;
192-
#endif
193-
194-
#ifdef HAS_TR1_UNORDERED_SET
195-
LOGICAL(cap)[4] = TRUE ;
196-
#else
197-
LOGICAL(cap)[4] = FALSE ;
198-
#endif
199-
200-
LOGICAL(cap)[5] = TRUE ;
201-
202-
#ifdef RCPP_HAS_DEMANGLING
203-
LOGICAL(cap)[6] = TRUE ;
204-
#else
205-
LOGICAL(cap)[6] = FALSE ;
206-
#endif
207-
208-
LOGICAL(cap)[7] = FALSE ;
209-
210-
#ifdef RCPP_HAS_LONG_LONG_TYPES
211-
LOGICAL(cap)[8] = TRUE ;
212-
#else
213-
LOGICAL(cap)[8] = FALSE ;
214-
#endif
215-
216-
SET_STRING_ELT(names, 0, Rf_mkChar("variadic templates") ) ;
217-
SET_STRING_ELT(names, 1, Rf_mkChar("initializer lists") ) ;
218-
SET_STRING_ELT(names, 2, Rf_mkChar("exception handling") ) ;
219-
SET_STRING_ELT(names, 3, Rf_mkChar("tr1 unordered maps") ) ;
220-
SET_STRING_ELT(names, 4, Rf_mkChar("tr1 unordered sets") ) ;
221-
SET_STRING_ELT(names, 5, Rf_mkChar("Rcpp modules") ) ;
222-
SET_STRING_ELT(names, 6, Rf_mkChar("demangling") ) ;
223-
SET_STRING_ELT(names, 7, Rf_mkChar("classic api") ) ;
224-
SET_STRING_ELT(names, 8, Rf_mkChar("long long") ) ;
225-
Rf_setAttrib( cap, R_NamesSymbol, names ) ;
226-
return cap ;
227-
}
228-
229-
230-
// [[Rcpp::internal]]
231-
SEXP rcpp_can_use_cxx0x(){
232-
#ifdef HAS_VARIADIC_TEMPLATES
233-
return Rf_ScalarLogical( TRUE );
234-
#else
235-
return Rf_ScalarLogical( FALSE );
236-
#endif
237-
}
238-
239-
// [[Rcpp::internal]]
240-
SEXP as_character_externalptr(SEXP xp){
241-
char buffer[20] ;
242-
snprintf( buffer, 20, "%p", (void*)EXTPTR_PTR(xp) ) ;
243-
return Rcpp::wrap( (const char*)buffer ) ;
244-
}
245-
246173
// [[Rcpp::register]]
247174
const char* short_file_name(const char* file){
248175
std::string f(file) ;
@@ -256,6 +183,82 @@ namespace Rcpp {
256183

257184
} // namespace Rcpp
258185

186+
// [[Rcpp::internal]]
187+
SEXP as_character_externalptr(SEXP xp){
188+
char buffer[20] ;
189+
snprintf( buffer, 20, "%p", (void*)EXTPTR_PTR(xp) ) ;
190+
return Rcpp::wrap( (const char*)buffer ) ;
191+
}
192+
193+
// [[Rcpp::internal]]
194+
SEXP rcpp_capabilities(){
195+
Shield<SEXP> cap( Rf_allocVector( LGLSXP, 9 ) );
196+
Shield<SEXP> names( Rf_allocVector( STRSXP, 9 ) );
197+
#ifdef HAS_VARIADIC_TEMPLATES
198+
LOGICAL(cap)[0] = TRUE ;
199+
#else
200+
LOGICAL(cap)[0] = FALSE ;
201+
#endif
202+
#ifdef HAS_CXX0X_INITIALIZER_LIST
203+
LOGICAL(cap)[1] = TRUE ;
204+
#else
205+
LOGICAL(cap)[1] = FALSE ;
206+
#endif
207+
/* exceptions are always supported */
208+
LOGICAL(cap)[2] = TRUE ;
209+
210+
#ifdef HAS_TR1_UNORDERED_MAP
211+
LOGICAL(cap)[3] = TRUE ;
212+
#else
213+
LOGICAL(cap)[3] = FALSE ;
214+
#endif
215+
216+
#ifdef HAS_TR1_UNORDERED_SET
217+
LOGICAL(cap)[4] = TRUE ;
218+
#else
219+
LOGICAL(cap)[4] = FALSE ;
220+
#endif
221+
222+
LOGICAL(cap)[5] = TRUE ;
223+
224+
#ifdef RCPP_HAS_DEMANGLING
225+
LOGICAL(cap)[6] = TRUE ;
226+
#else
227+
LOGICAL(cap)[6] = FALSE ;
228+
#endif
229+
230+
LOGICAL(cap)[7] = FALSE ;
231+
232+
#ifdef RCPP_HAS_LONG_LONG_TYPES
233+
LOGICAL(cap)[8] = TRUE ;
234+
#else
235+
LOGICAL(cap)[8] = FALSE ;
236+
#endif
237+
238+
SET_STRING_ELT(names, 0, Rf_mkChar("variadic templates") ) ;
239+
SET_STRING_ELT(names, 1, Rf_mkChar("initializer lists") ) ;
240+
SET_STRING_ELT(names, 2, Rf_mkChar("exception handling") ) ;
241+
SET_STRING_ELT(names, 3, Rf_mkChar("tr1 unordered maps") ) ;
242+
SET_STRING_ELT(names, 4, Rf_mkChar("tr1 unordered sets") ) ;
243+
SET_STRING_ELT(names, 5, Rf_mkChar("Rcpp modules") ) ;
244+
SET_STRING_ELT(names, 6, Rf_mkChar("demangling") ) ;
245+
SET_STRING_ELT(names, 7, Rf_mkChar("classic api") ) ;
246+
SET_STRING_ELT(names, 8, Rf_mkChar("long long") ) ;
247+
Rf_setAttrib( cap, R_NamesSymbol, names ) ;
248+
return cap ;
249+
}
250+
251+
252+
// [[Rcpp::internal]]
253+
SEXP rcpp_can_use_cxx0x(){
254+
#ifdef HAS_VARIADIC_TEMPLATES
255+
return Rf_ScalarLogical( TRUE );
256+
#else
257+
return Rf_ScalarLogical( FALSE );
258+
#endif
259+
}
260+
261+
259262
// [[Rcpp::register]]
260263
SEXP stack_trace( const char* file, int line ){
261264
#if defined(__GNUC__)

0 commit comments

Comments
 (0)