2424
2525#include < Rcpp.h>
2626
27- using namespace Rcpp ;
27+ using namespace Rcpp ;
2828
2929#include " internal.h"
3030#include < R_ext/PrtUtil.h>
@@ -39,15 +39,15 @@ using namespace Rcpp ;
3939 #else
4040 #include < execinfo.h>
4141
42- static std::string demangler_one ( const char * input){
43- static std::string buffer ;
44- buffer = input ;
45- buffer.resize ( buffer.find_last_of ( ' +' ) - 1 ) ;
42+ static std::string demangler_one (const char * input) {
43+ static std::string buffer;
44+ buffer = input;
45+ buffer.resize (buffer.find_last_of (' +' ) - 1 ) ;
4646 buffer.erase (
4747 buffer.begin (),
48- buffer.begin () + buffer.find_last_of ( ' ' ) + 1
49- ) ;
50- return demangle ( buffer) ;
48+ buffer.begin () + buffer.find_last_of (' ' ) + 1
49+ );
50+ return demangle (buffer);
5151 }
5252
5353 #endif
@@ -65,20 +65,20 @@ namespace Rcpp {
6565 unsigned long enterRNGScope () {
6666 if (RNGScopeCounter == 0 ) GetRNGstate ();
6767 RNGScopeCounter++;
68- return RNGScopeCounter ;
68+ return RNGScopeCounter;
6969 }
7070
7171 // [[Rcpp::register]]
7272 unsigned long exitRNGScope () {
7373 RNGScopeCounter--;
7474 if (RNGScopeCounter == 0 ) PutRNGstate ();
75- return RNGScopeCounter ;
75+ return RNGScopeCounter;
7676 }
7777
7878 // [[Rcpp::register]]
79- char * get_string_buffer (){
79+ char * get_string_buffer () {
8080 static char buffer[MAXELTSIZE];
81- return buffer ;
81+ return buffer;
8282 }
8383
8484 }
@@ -119,151 +119,151 @@ namespace Rcpp {
119119} // namespace Rcpp
120120
121121// [[Rcpp::register]]
122- std::string demangle ( const std::string& name ) {
122+ std::string demangle (const std::string& name) {
123123 #ifdef RCPP_HAS_DEMANGLING
124- std::string real_class ;
125- int status =-1 ;
124+ std::string real_class;
125+ int status =-1 ;
126126 char *dem = 0 ;
127127 dem = abi::__cxa_demangle (name.c_str (), 0 , 0 , &status);
128- if ( status == 0 ) {
129- real_class = dem ;
128+ if ( status == 0 ) {
129+ real_class = dem;
130130 free (dem);
131131 } else {
132- real_class = name ;
132+ real_class = name;
133133 }
134- return real_class ;
134+ return real_class;
135135 #else
136- return name ;
136+ return name;
137137 #endif
138138}
139139
140140// [[Rcpp::register]]
141- const char * short_file_name (const char * file){
142- std::string f (file) ;
143- size_t index = f.find (" /include/" ) ;
144- if ( index != std::string::npos ) {
145- f = f.substr ( index + 9 ) ;
141+ const char * short_file_name (const char * file) {
142+ std::string f (file);
143+ size_t index = f.find (" /include/" );
144+ if ( index != std::string::npos) {
145+ f = f.substr (index + 9 ) ;
146146 }
147- return f.c_str () ;
147+ return f.c_str ();
148148}
149149
150150// [[Rcpp::internal]]
151- SEXP as_character_externalptr (SEXP xp){
152- char buffer[20 ] ;
153- snprintf ( buffer, 20 , " %p" , (void *)EXTPTR_PTR (xp) ) ;
154- return Rcpp::wrap ( (const char *)buffer ) ;
151+ SEXP as_character_externalptr (SEXP xp) {
152+ char buffer[20 ];
153+ snprintf (buffer, 20 , " %p" , (void *)EXTPTR_PTR (xp)) ;
154+ return Rcpp::wrap ((const char *)buffer) ;
155155}
156156
157157// [[Rcpp::internal]]
158- SEXP rcpp_capabilities (){
159- Shield<SEXP> cap ( Rf_allocVector ( LGLSXP, 12 ) );
160- Shield<SEXP> names ( Rf_allocVector ( STRSXP, 12 ) );
158+ SEXP rcpp_capabilities () {
159+ Shield<SEXP> cap (Rf_allocVector (LGLSXP, 12 ) );
160+ Shield<SEXP> names (Rf_allocVector (STRSXP, 12 ) );
161161 #ifdef HAS_VARIADIC_TEMPLATES
162- LOGICAL (cap)[0 ] = TRUE ;
162+ LOGICAL (cap)[0 ] = TRUE ;
163163 #else
164- LOGICAL (cap)[0 ] = FALSE ;
164+ LOGICAL (cap)[0 ] = FALSE ;
165165 #endif
166166 #ifdef HAS_CXX0X_INITIALIZER_LIST
167- LOGICAL (cap)[1 ] = TRUE ;
167+ LOGICAL (cap)[1 ] = TRUE ;
168168 #else
169- LOGICAL (cap)[1 ] = FALSE ;
169+ LOGICAL (cap)[1 ] = FALSE ;
170170 #endif
171171 /* exceptions are always supported */
172- LOGICAL (cap)[2 ] = TRUE ;
172+ LOGICAL (cap)[2 ] = TRUE ;
173173
174174 #ifdef HAS_TR1_UNORDERED_MAP
175- LOGICAL (cap)[3 ] = TRUE ;
175+ LOGICAL (cap)[3 ] = TRUE ;
176176 #else
177- LOGICAL (cap)[3 ] = FALSE ;
177+ LOGICAL (cap)[3 ] = FALSE ;
178178 #endif
179179
180180 #ifdef HAS_TR1_UNORDERED_SET
181- LOGICAL (cap)[4 ] = TRUE ;
181+ LOGICAL (cap)[4 ] = TRUE ;
182182 #else
183- LOGICAL (cap)[4 ] = FALSE ;
183+ LOGICAL (cap)[4 ] = FALSE ;
184184 #endif
185185
186- LOGICAL (cap)[5 ] = TRUE ;
186+ LOGICAL (cap)[5 ] = TRUE ;
187187
188188 #ifdef RCPP_HAS_DEMANGLING
189- LOGICAL (cap)[6 ] = TRUE ;
189+ LOGICAL (cap)[6 ] = TRUE ;
190190 #else
191- LOGICAL (cap)[6 ] = FALSE ;
191+ LOGICAL (cap)[6 ] = FALSE ;
192192 #endif
193193
194- LOGICAL (cap)[7 ] = FALSE ;
194+ LOGICAL (cap)[7 ] = FALSE ;
195195
196196 #ifdef RCPP_HAS_LONG_LONG_TYPES
197- LOGICAL (cap)[8 ] = TRUE ;
197+ LOGICAL (cap)[8 ] = TRUE ;
198198 #else
199- LOGICAL (cap)[8 ] = FALSE ;
199+ LOGICAL (cap)[8 ] = FALSE ;
200200 #endif
201201
202202 #ifdef HAS_CXX0X_UNORDERED_MAP
203- LOGICAL (cap)[9 ] = TRUE ;
203+ LOGICAL (cap)[9 ] = TRUE ;
204204 #else
205- LOGICAL (cap)[9 ] = FALSE ;
205+ LOGICAL (cap)[9 ] = FALSE ;
206206 #endif
207207
208208 #ifdef HAS_CXX0X_UNORDERED_SET
209- LOGICAL (cap)[10 ] = TRUE ;
209+ LOGICAL (cap)[10 ] = TRUE ;
210210 #else
211- LOGICAL (cap)[10 ] = FALSE ;
211+ LOGICAL (cap)[10 ] = FALSE ;
212212 #endif
213213
214214 #ifdef RCPP_USING_CXX11
215- LOGICAL (cap)[11 ] = TRUE ;
215+ LOGICAL (cap)[11 ] = TRUE ;
216216 #else
217- LOGICAL (cap)[11 ] = FALSE ;
217+ LOGICAL (cap)[11 ] = FALSE ;
218218 #endif
219219
220- SET_STRING_ELT (names, 0 , Rf_mkChar (" variadic templates" ) ) ;
221- SET_STRING_ELT (names, 1 , Rf_mkChar (" initializer lists" ) ) ;
222- SET_STRING_ELT (names, 2 , Rf_mkChar (" exception handling" ) ) ;
223- SET_STRING_ELT (names, 3 , Rf_mkChar (" tr1 unordered maps" ) ) ;
224- SET_STRING_ELT (names, 4 , Rf_mkChar (" tr1 unordered sets" ) ) ;
225- SET_STRING_ELT (names, 5 , Rf_mkChar (" Rcpp modules" ) ) ;
226- SET_STRING_ELT (names, 6 , Rf_mkChar (" demangling" ) ) ;
227- SET_STRING_ELT (names, 7 , Rf_mkChar (" classic api" ) ) ;
228- SET_STRING_ELT (names, 8 , Rf_mkChar (" long long" ) ) ;
229- SET_STRING_ELT (names, 9 , Rf_mkChar (" C++0x unordered maps" ) ) ;
230- SET_STRING_ELT (names, 10 , Rf_mkChar (" C++0x unordered sets" ) ) ;
231- SET_STRING_ELT (names, 11 , Rf_mkChar (" Full C++11 support" ) ) ;
232- Rf_setAttrib ( cap, R_NamesSymbol, names ) ;
233- return cap ;
220+ SET_STRING_ELT (names, 0 , Rf_mkChar (" variadic templates" )) ;
221+ SET_STRING_ELT (names, 1 , Rf_mkChar (" initializer lists" )) ;
222+ SET_STRING_ELT (names, 2 , Rf_mkChar (" exception handling" )) ;
223+ SET_STRING_ELT (names, 3 , Rf_mkChar (" tr1 unordered maps" )) ;
224+ SET_STRING_ELT (names, 4 , Rf_mkChar (" tr1 unordered sets" )) ;
225+ SET_STRING_ELT (names, 5 , Rf_mkChar (" Rcpp modules" )) ;
226+ SET_STRING_ELT (names, 6 , Rf_mkChar (" demangling" )) ;
227+ SET_STRING_ELT (names, 7 , Rf_mkChar (" classic api" )) ;
228+ SET_STRING_ELT (names, 8 , Rf_mkChar (" long long" )) ;
229+ SET_STRING_ELT (names, 9 , Rf_mkChar (" C++0x unordered maps" )) ;
230+ SET_STRING_ELT (names, 10 , Rf_mkChar (" C++0x unordered sets" )) ;
231+ SET_STRING_ELT (names, 11 , Rf_mkChar (" Full C++11 support" )) ;
232+ Rf_setAttrib (cap, R_NamesSymbol, names) ;
233+ return cap;
234234}
235235
236236
237237// [[Rcpp::internal]]
238- SEXP rcpp_can_use_cxx0x (){
238+ SEXP rcpp_can_use_cxx0x () {
239239 #if defined(HAS_VARIADIC_TEMPLATES) || defined(RCPP_USING_CXX11)
240- return Rf_ScalarLogical ( TRUE );
240+ return Rf_ScalarLogical (TRUE );
241241 #else
242- return Rf_ScalarLogical ( FALSE );
242+ return Rf_ScalarLogical (FALSE );
243243 #endif
244244}
245245
246246
247247// [[Rcpp::internal]]
248- SEXP rcpp_can_use_cxx11 (){
248+ SEXP rcpp_can_use_cxx11 () {
249249 #if defined(RCPP_USING_CXX11)
250- return Rf_ScalarLogical ( TRUE );
250+ return Rf_ScalarLogical (TRUE );
251251 #else
252- return Rf_ScalarLogical ( FALSE );
252+ return Rf_ScalarLogical (FALSE );
253253 #endif
254254}
255255
256256
257257// [[Rcpp::register]]
258- SEXP stack_trace ( const char * file, int line ) {
258+ SEXP stack_trace (const char * file, int line) {
259259 #if defined(__GNUC__)
260260 #if defined(WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun) || defined(_AIX)
261261 // Simpler version for Windows and *BSD
262262 List trace = List::create (_[" file" ] = file,
263263 _[ " line" ] = line,
264264 _[ " stack" ] = " C++ stack not available on this system" );
265- trace.attr (" class" ) = " Rcpp_stack_trace" ;
266- return trace ;
265+ trace.attr (" class" ) = " Rcpp_stack_trace" ;
266+ return trace;
267267 #else // ! (defined(WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun) || defined(_AIX)
268268
269269 /* inspired from http://tombarta.wordpress.com/2008/08/01/c-stack-traces-with-gcc/ */
@@ -275,26 +275,20 @@ SEXP stack_trace( const char* file, int line ){
275275 stack_depth = backtrace (stack_addrs, max_depth);
276276 stack_strings = backtrace_symbols (stack_addrs, stack_depth);
277277
278- std::string current_line ;
278+ std::string current_line;
279279
280- CharacterVector res ( stack_depth - 1 ) ;
281- std::transform (
282- stack_strings + 1 , stack_strings + stack_depth,
283- res.begin (),
284- demangler_one
285- ) ;
280+ CharacterVector res (stack_depth - 1 );
281+ std::transform (stack_strings + 1 , stack_strings + stack_depth, res.begin (), demangler_one);
286282 free (stack_strings); // malloc()ed by backtrace_symbols
287283
288- List trace = List::create (
289- _[" file" ] = file,
290- _[" line" ] = line,
291- _[" stack" ] = res
292- ) ;
293- trace.attr (" class" ) = " Rcpp_stack_trace" ;
294- return trace ;
284+ List trace = List::create (_[" file" ] = file,
285+ _[" line" ] = line,
286+ _[" stack" ] = res);
287+ trace.attr (" class" ) = " Rcpp_stack_trace" ;
288+ return trace;
295289 #endif
296290 #else /* !defined( __GNUC__ ) */
297- return R_NilValue ;
291+ return R_NilValue;
298292 #endif
299293}
300294
0 commit comments