Skip to content

Commit 2013d3a

Browse files
authored
Merge pull request #523 from thirdwing/master
Remove unsafe usage of Rf_eval (close #498)
2 parents b50768d + ccb3259 commit 2013d3a

File tree

9 files changed

+24
-11
lines changed

9 files changed

+24
-11
lines changed

ChangeLog

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
2016-07-31 Qiang Kou <[email protected]>
2+
3+
* inst/examples/SugarPerformance/sugarBenchmarks.R: Remove usage of Rf_eval
4+
* inst/include/Rcpp/Environment.h: Idem
5+
* inst/include/Rcpp/Module.h: Idem
6+
* inst/include/Rcpp/exceptions.h: Idem
7+
* inst/include/Rcpp/proxy/FieldProxy.h: Idem
8+
* inst/include/Rcpp/r_cast.h: Idem
9+
* inst/unitTests/cpp/language.cpp: Idem
10+
* src/barrier.cpp: Idem
11+
112
2016-07-24 Dirk Eddelbuettel <[email protected]>
213

314
* inst/unitTests/cpp/rmath.cpp: Added RNG unit tests for sugar variants

inst/examples/SugarPerformance/sugarBenchmarks.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ src <- sprintf( '
5353
5454
timer.Reset(); timer.Start();
5555
for (unsigned int i=0; i<runs; i++) {
56-
NumericVector res2 = Rf_eval( call, e ) ;
56+
NumericVector res2 = Rcpp_eval( call, e ) ;
5757
}
5858
timer.Stop();
5959
double t3 = timer.ElapsedTime();

inst/include/Rcpp/Environment.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ namespace Rcpp{
247247
Shield<SEXP> call( Rf_lang2(internalSym,
248248
Rf_lang4(removeSym, Rf_mkString(name.c_str()), Storage::get__(), Rf_ScalarLogical( FALSE ))
249249
) );
250-
Rf_eval( call, R_GlobalEnv ) ;
250+
Rcpp_eval( call, R_GlobalEnv ) ;
251251
}
252252
} else{
253253
throw no_such_binding(name) ;

inst/include/Rcpp/Module.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static VARIABLE_IS_NOT_USED SEXP moduleSym = NULL;
454454
// this macro is called by code wanting to load a module -- see RInside's rinside_module_sample0.cpp
455455
#define LOAD_RCPP_MODULE(NAME) \
456456
Shield<SEXP> __load_module_call__( Rf_lang2( GET_MODULE_SYM, _rcpp_module_boot_##NAME() ); \
457-
Rf_eval(__load_module_call__), R_GlobalEnv );
457+
Rcpp_eval(__load_module_call__), R_GlobalEnv );
458458

459459
#endif
460460

inst/include/Rcpp/exceptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ namespace Rcpp{
129129
inline SEXP get_last_call(){
130130
SEXP sys_calls_symbol = Rf_install( "sys.calls" ) ;
131131
Rcpp::Shield<SEXP> sys_calls_expr( Rf_lang1(sys_calls_symbol) );
132-
Rcpp::Shield<SEXP> calls( Rf_eval( sys_calls_expr, R_GlobalEnv ) );
132+
Rcpp::Shield<SEXP> calls( Rcpp_eval( sys_calls_expr, R_GlobalEnv ) );
133133
SEXP res = calls ;
134134
while( !Rf_isNull(CDR(res)) ) res = CDR(res);
135135
return CAR(res) ;

inst/include/Rcpp/proxy/FieldProxy.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ class FieldProxyPolicy {
4242

4343
SEXP get() const {
4444
Shield<SEXP> call( Rf_lang3( R_DollarSymbol, parent, Rf_mkString(field_name.c_str()) ) ) ;
45-
return Rf_eval( call, R_GlobalEnv ) ;
45+
return Rcpp_eval( call, R_GlobalEnv ) ;
4646
}
4747
void set(SEXP x ) {
4848
SEXP dollarGetsSym = Rf_install( "$<-");
4949
Shield<SEXP> call( Rf_lang4( dollarGetsSym, parent, Rf_mkString(field_name.c_str()) , x ) ) ;
50-
parent.set__( Rf_eval( call, R_GlobalEnv ) );
50+
parent.set__( Rcpp_eval( call, R_GlobalEnv ) );
5151
}
5252
} ;
5353

@@ -67,7 +67,7 @@ class FieldProxyPolicy {
6767

6868
SEXP get() const {
6969
Shield<SEXP> call( Rf_lang3( R_DollarSymbol, parent, Rf_mkString(field_name.c_str()) ) ) ;
70-
return Rf_eval( call, R_GlobalEnv ) ;
70+
return Rcpp_eval( call, R_GlobalEnv ) ;
7171
}
7272
} ;
7373

inst/include/Rcpp/r_cast.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace Rcpp{
9595
// return Rf_coerceVector( x, STRSXP );
9696
// coerceVector does not work for some reason
9797
Shield<SEXP> call( Rf_lang2( Rf_install( "as.character" ), x ) ) ;
98-
Shield<SEXP> res( Rf_eval( call, R_GlobalEnv ) ) ;
98+
Shield<SEXP> res( Rcpp_eval( call, R_GlobalEnv ) ) ;
9999
return res ;
100100
}
101101
case CHARSXP:

inst/unitTests/cpp/language.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Language runit_lang_square_lv(){
6868
SEXP runit_lang_fun( Function fun, IntegerVector x ){
6969
Language call( fun );
7070
call.push_back(x) ;
71-
return Rf_eval( call, R_GlobalEnv ) ;
71+
return Rcpp_eval( call, R_GlobalEnv ) ;
7272
}
7373

7474
// [[Rcpp::export]]

src/barrier.cpp

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

31+
namespace Rcpp { SEXP Rcpp_eval(SEXP, SEXP); }
32+
3133
// [[Rcpp::register]]
3234
SEXP get_string_elt(SEXP x, int i) {
3335
return STRING_ELT(x, i);
@@ -95,7 +97,7 @@ SEXP get_rcpp_cache() {
9597
SEXP getNamespaceSym = Rf_install("getNamespace"); // cannot be gc()'ed once in symbol table
9698
Rcpp::Shield<SEXP> RcppString(Rf_mkString("Rcpp"));
9799
Rcpp::Shield<SEXP> call(Rf_lang2(getNamespaceSym, RcppString));
98-
Rcpp::Shield<SEXP> RCPP(Rf_eval(call, R_GlobalEnv));
100+
Rcpp::Shield<SEXP> RCPP(Rcpp_eval(call, R_GlobalEnv));
99101

100102
Rcpp_cache = Rf_findVarInFrame(RCPP, Rf_install(".rcpp_cache"));
101103
Rcpp_cache_know = true;
@@ -137,7 +139,7 @@ SEXP init_Rcpp_cache() {
137139
SEXP getNamespaceSym = Rf_install("getNamespace"); // cannot be gc()'ed once in symbol table
138140
Rcpp::Shield<SEXP> RcppString(Rf_mkString("Rcpp"));
139141
Rcpp::Shield<SEXP> call(Rf_lang2(getNamespaceSym, RcppString));
140-
Rcpp::Shield<SEXP> RCPP(Rf_eval(call, R_GlobalEnv));
142+
Rcpp::Shield<SEXP> RCPP(Rcpp_eval(call, R_GlobalEnv));
141143
Rcpp::Shield<SEXP> cache(Rf_allocVector(VECSXP, RCPP_CACHE_SIZE));
142144

143145
// the Rcpp namespace

0 commit comments

Comments
 (0)