Skip to content

Commit 3b4243d

Browse files
mark functions as registered and make sure they don't throw. closes #73
1 parent 90dc9a9 commit 3b4243d

File tree

2 files changed

+29
-11
lines changed

2 files changed

+29
-11
lines changed

src/api.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,11 @@ SEXP stack_trace( const char* file, int line ){
227227
#if defined(__GNUC__)
228228
#if defined(WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun)
229229
// Simpler version for Windows and *BSD
230-
Rcpp::List trace = Rcpp::List::create(
231-
Rcpp::Named( "file" ) = file,
232-
Rcpp::Named( "line" ) = line,
233-
Rcpp::Named( "stack" ) = "C++ stack not available on this system" ) ;
230+
List trace = List::create(
231+
_[ "file" ] = file,
232+
_[ "line" ] = line,
233+
_[ "stack" ] = "C++ stack not available on this system"
234+
) ;
234235
trace.attr("class") = "Rcpp_stack_trace" ;
235236
return trace ;
236237
#else // ! (defined(WIN32) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__CYGWIN__) || defined(__sun)
@@ -246,18 +247,18 @@ SEXP stack_trace( const char* file, int line ){
246247

247248
std::string current_line ;
248249

249-
Rcpp::CharacterVector res( stack_depth - 1) ;
250+
CharacterVector res( stack_depth - 1) ;
250251
std::transform(
251252
stack_strings + 1, stack_strings + stack_depth,
252253
res.begin(),
253254
demangler_one
254255
) ;
255256
free(stack_strings); // malloc()ed by backtrace_symbols
256257

257-
Rcpp::List trace = Rcpp::List::create(
258-
Rcpp::Named( "file" ) = file,
259-
Rcpp::Named( "line" ) = line,
260-
Rcpp::Named( "stack" ) = res
258+
List trace = List::create(
259+
_["file" ] = file,
260+
_["line" ] = line,
261+
_["stack"] = res
261262
) ;
262263
trace.attr("class") = "Rcpp_stack_trace" ;
263264
return trace ;

src/barrier.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,52 @@
2828
#include <algorithm>
2929
#include <Rcpp/protection/Shield.h>
3030

31-
31+
// [[Rcpp::register]]
3232
SEXP get_string_elt(SEXP x, int i){
3333
return STRING_ELT(x, i ) ;
3434
}
35+
36+
// [[Rcpp::register]]
3537
const char* char_get_string_elt(SEXP x, int i){
3638
return CHAR(STRING_ELT(x, i )) ;
3739
}
40+
41+
// [[Rcpp::register]]
3842
void set_string_elt(SEXP x, int i, SEXP value){
3943
STRING_ELT(x, i) = value ;
4044
}
45+
46+
// [[Rcpp::register]]
4147
void char_set_string_elt(SEXP x, int i, const char* value){
4248
STRING_ELT(x, i) = Rf_mkChar(value) ;
4349
}
50+
51+
// [[Rcpp::register]]
4452
SEXP* get_string_ptr(SEXP x){
4553
return STRING_PTR(x) ;
4654
}
4755

56+
// [[Rcpp::register]]
4857
SEXP get_vector_elt(SEXP x, int i){
4958
return VECTOR_ELT(x, i ) ;
5059
}
60+
61+
// [[Rcpp::register]]
5162
void set_vector_elt(SEXP x, int i, SEXP value){
5263
SET_VECTOR_ELT(x, i, value ) ;
5364
}
65+
66+
// [[Rcpp::register]]
5467
SEXP* get_vector_ptr(SEXP x){
5568
return VECTOR_PTR(x) ;
5669
}
70+
71+
// [[Rcpp::register]]
5772
void* dataptr(SEXP x){
5873
return DATAPTR(x);
5974
}
6075

61-
// when we already know x is a CHARSXP
76+
// [[Rcpp::register]]
6277
const char* char_nocheck( SEXP x ){
6378
return CHAR(x);
6479
}
@@ -154,6 +169,7 @@ int error_occured(){
154169
return LOGICAL(err)[0] ;
155170
}
156171

172+
// [[Rcpp::internal]]
157173
SEXP rcpp_error_recorder(SEXP e){
158174
SEXP cache = get_rcpp_cache() ;
159175

@@ -171,6 +187,7 @@ SEXP rcpp_get_current_error(){
171187
return VECTOR_ELT( get_rcpp_cache(), 2 ) ;
172188
}
173189

190+
// [[Rcpp::register]]
174191
int* get_cache( int m){
175192
SEXP cache = get_rcpp_cache() ;
176193
SEXP hash_cache = VECTOR_ELT( cache, RCPP_HASH_CACHE_INDEX) ;

0 commit comments

Comments
 (0)