Skip to content

Commit ee0a5b8

Browse files
authored
Merge pull request #1011 from RcppCore/feature/add_more_shields
Feature/add more shields
2 parents 76c0ab1 + da4b705 commit ee0a5b8

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
* DESCRIPTION (Version, Date): Roll minor version
44

5+
* inst/include/Rcpp/Reference.h: Shield Rf_mkstring inside Rf_lang2
6+
* inst/include/Rcpp/Environment.h: Idem (inside Rf_lang4)
7+
* inst/include/Rcpp/proxy/FieldProxy.h: Idem (inside Rf_lang3 and 4)
8+
59
2019-10-31 Romain Francois <[email protected]>
610

711
* inst/include/Rcpp/DataFrame.h: Protect temporaries from gc

inst/include/Rcpp/Environment.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
//
33
// Environment.h: Rcpp R/C++ interface class library -- access R environments
44
//
5-
// Copyright (C) 2009 - 2013 Dirk Eddelbuettel and Romain Francois
6-
// Copyright (C) 2014 Dirk Eddelbuettel, Romain Francois and Kevin Ushey
5+
// Copyright (C) 2009 - 2013 Dirk Eddelbuettel and Romain Francois
6+
// Copyright (C) 2014 - 2019 Dirk Eddelbuettel, Romain Francois and Kevin Ushey
77
//
88
// This file is part of Rcpp.
99
//
@@ -246,9 +246,8 @@ namespace Rcpp{
246246
we have to go back to R to do this operation */
247247
SEXP internalSym = Rf_install( ".Internal" );
248248
SEXP removeSym = Rf_install( "remove" );
249-
Shield<SEXP> call( Rf_lang2(internalSym,
250-
Rf_lang4(removeSym, Rf_mkString(name.c_str()), Storage::get__(), Rf_ScalarLogical( FALSE ))
251-
) );
249+
Shield<SEXP> str(Rf_mkString(name.c_str()));
250+
Shield<SEXP> call(Rf_lang2(internalSym, Rf_lang4(removeSym, str, Storage::get__(), Rf_ScalarLogical(FALSE))));
252251
Rcpp_fast_eval( call, R_GlobalEnv ) ;
253252
}
254253
} else{

inst/include/Rcpp/Reference.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// Reference.h: Rcpp R/C++ interface class library -- Reference class objects
44
//
5-
// Copyright (C) 2010 - 2015 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -58,7 +58,8 @@ namespace Rcpp{
5858
*/
5959
Reference_Impl( const std::string& klass ) {
6060
SEXP newSym = Rf_install("new");
61-
Shield<SEXP> call( Rf_lang2( newSym, Rf_mkString( klass.c_str() ) ) );
61+
Shield<SEXP> str(Rf_mkString(klass.c_str()));
62+
Shield<SEXP> call(Rf_lang2(newSym, str));
6263
Storage::set__( Rcpp_fast_eval( call , Rcpp::internal::get_Rcpp_namespace()) );
6364
}
6465

inst/include/Rcpp/proxy/FieldProxy.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ class FieldProxyPolicy {
4141
const std::string& field_name ;
4242

4343
SEXP get() const {
44-
Shield<SEXP> call( Rf_lang3( R_DollarSymbol, parent, Rf_mkString(field_name.c_str()) ) ) ;
44+
Shield<SEXP> str(Rf_mkString(field_name.c_str()));
45+
Shield<SEXP> call(Rf_lang3(R_DollarSymbol, parent, str));
4546
return Rcpp_fast_eval( call, R_GlobalEnv ) ;
4647
}
4748
void set(SEXP x ) {
4849
SEXP dollarGetsSym = Rf_install( "$<-");
49-
Shield<SEXP> call( Rf_lang4( dollarGetsSym, parent, Rf_mkString(field_name.c_str()) , x ) ) ;
50+
Shield<SEXP> str(Rf_mkString(field_name.c_str()));
51+
Shield<SEXP> call(Rf_lang4(dollarGetsSym, parent, str, x));
5052
parent.set__( Rcpp_fast_eval( call, R_GlobalEnv ) );
5153
}
5254
} ;
@@ -66,7 +68,8 @@ class FieldProxyPolicy {
6668
const std::string& field_name ;
6769

6870
SEXP get() const {
69-
Shield<SEXP> call( Rf_lang3( R_DollarSymbol, parent, Rf_mkString(field_name.c_str()) ) ) ;
71+
Shield<SEXP> str(Rf_mkString(field_name.c_str()));
72+
Shield<SEXP> call(Rf_lang3(R_DollarSymbol, parent, str));
7073
return Rcpp_fast_eval( call, R_GlobalEnv ) ;
7174
}
7275
} ;

0 commit comments

Comments
 (0)