[Rcpp-commits] r2886 - in pkg/Rcpp: . inst/include/Rcpp
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Jan 25 22:18:42 CET 2011
Author: edd
Date: 2011-01-25 22:18:42 +0100 (Tue, 25 Jan 2011)
New Revision: 2886
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/include/Rcpp/DataFrame.h
pkg/Rcpp/inst/include/Rcpp/DottedPair.h
pkg/Rcpp/inst/include/Rcpp/Module.h
pkg/Rcpp/inst/include/Rcpp/grow.h
Log:
More Rf_install() to local SEXP
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2011-01-25 20:59:41 UTC (rev 2885)
+++ pkg/Rcpp/ChangeLog 2011-01-25 21:18:42 UTC (rev 2886)
@@ -2,6 +2,10 @@
* inst/include/Rcpp/DataFrame_generated.h: Assign Rf_install() result
to local SEXP (by modifying generator script creating the file)
+ * inst/include/Rcpp/DataFrame.h: Assign Rf_install() result to local SEXP
+ * inst/include/Rcpp/DottedPair.h: idem
+ * inst/include/Rcpp/grow.h: idem
+ * inst/include/Rcpp/Module.h: idem
2011-01-25 Douglas Bates <bates at stat.wisc.edu>
Modified: pkg/Rcpp/inst/include/Rcpp/DataFrame.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/DataFrame.h 2011-01-25 20:59:41 UTC (rev 2885)
+++ pkg/Rcpp/inst/include/Rcpp/DataFrame.h 2011-01-25 21:18:42 UTC (rev 2886)
@@ -1,4 +1,4 @@
-// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 4 -*-
//
// DataFrame.h: Rcpp R/C++ interface class library -- data frames
//
@@ -27,53 +27,54 @@
namespace Rcpp{
- namespace internal{
- inline SEXP empty_data_frame(){
- return ::Rf_eval( ::Rf_lang1( ::Rf_install("data.frame") ), R_GlobalEnv ) ;
- }
+ namespace internal{
+ inline SEXP empty_data_frame(){
+ SEXP dataFrameSym = ::Rf_install( "data.frame"); // cannot be gc()ed once in symbol table
+ return ::Rf_eval( ::Rf_lang1( dataFrameSym ), R_GlobalEnv ) ;
}
+ }
- class DataFrame : public List {
- public:
- DataFrame(): List( internal::empty_data_frame() ){}
+ class DataFrame : public List {
+ public:
+ DataFrame(): List( internal::empty_data_frame() ){}
- DataFrame(SEXP x) throw(not_compatible) : List(){
- set(x) ;
- }
+ DataFrame(SEXP x) throw(not_compatible) : List(){
+ set(x) ;
+ }
- DataFrame( const DataFrame& other): List(other.asSexp()) {}
+ DataFrame( const DataFrame& other): List(other.asSexp()) {}
- DataFrame( const RObject::SlotProxy& proxy ) throw(not_compatible){ set(proxy); }
- DataFrame( const RObject::AttributeProxy& proxy ) throw(not_compatible){ set(proxy); }
+ DataFrame( const RObject::SlotProxy& proxy ) throw(not_compatible){ set(proxy); }
+ DataFrame( const RObject::AttributeProxy& proxy ) throw(not_compatible){ set(proxy); }
- DataFrame& operator=( DataFrame& other){
- setSEXP( other.asSexp() ) ;
- return *this ;
- }
+ DataFrame& operator=( DataFrame& other){
+ setSEXP( other.asSexp() ) ;
+ return *this ;
+ }
- DataFrame& operator=( SEXP x) throw( not_compatible) {
- set(x) ;
- return *this ;
- }
+ DataFrame& operator=( SEXP x) throw( not_compatible) {
+ set(x) ;
+ return *this ;
+ }
- ~DataFrame(){}
+ ~DataFrame(){}
- static DataFrame create(){ return DataFrame() ; }
+ static DataFrame create(){ return DataFrame() ; }
#include <Rcpp/DataFrame_generated.h>
- private:
- void set(SEXP x) throw(not_compatible) {
- if( ::Rf_inherits( x, "data.frame" )){
- setSEXP( x ) ;
- } else{
- SEXP y = internal::convert_using_rfunction( x, "as.data.frame" ) ;
- setSEXP( y ) ;
- }
- }
-
- } ;
+ private:
+ void set(SEXP x) throw(not_compatible) {
+ if( ::Rf_inherits( x, "data.frame" )){
+ setSEXP( x ) ;
+ } else{
+ SEXP y = internal::convert_using_rfunction( x, "as.data.frame" ) ;
+ setSEXP( y ) ;
+ }
+ }
+ } ;
+
}
#endif
Modified: pkg/Rcpp/inst/include/Rcpp/DottedPair.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/DottedPair.h 2011-01-25 20:59:41 UTC (rev 2885)
+++ pkg/Rcpp/inst/include/Rcpp/DottedPair.h 2011-01-25 21:18:42 UTC (rev 2886)
@@ -167,7 +167,8 @@
template <typename U>
Proxy& operator=(const traits::named_object<U>& rhs){
SETCAR( node, rhs.object ) ;
- SET_TAG( node, Rf_install( rhs.name.c_str() ) ) ;
+ SEXP rhsNameSym = ::Rf_install( rhs.name.c_str() ); // cannot be gc()ed once in symbol table
+ SET_TAG( node, rhsNameSym ) ;
return *this ;
}
Modified: pkg/Rcpp/inst/include/Rcpp/Module.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Module.h 2011-01-25 20:59:41 UTC (rev 2885)
+++ pkg/Rcpp/inst/include/Rcpp/Module.h 2011-01-25 21:18:42 UTC (rev 2886)
@@ -739,7 +739,10 @@
} \
void _rcpp_module_##name##_init()
-#define LOAD_RCPP_MODULE(NAME) Rf_eval( Rf_lang2( Rf_install("Module"), _rcpp_module_boot_##NAME() ), R_GlobalEnv )
+#define LOAD_RCPP_MODULE(NAME) \
+ SEXP moduleSym = Rf_install("Module"); \
+ Rf_eval( Rf_lang2( moduleSym, _rcpp_module_boot_##NAME() ), R_GlobalEnv )
+
#endif
Modified: pkg/Rcpp/inst/include/Rcpp/grow.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/grow.h 2011-01-25 20:59:41 UTC (rev 2885)
+++ pkg/Rcpp/inst/include/Rcpp/grow.h 2011-01-25 21:18:42 UTC (rev 2886)
@@ -61,8 +61,9 @@
template <typename T>
SEXP grow__dispatch( ::Rcpp::traits::true_type, const T& head, SEXP tail ){
SEXP y = PROTECT( wrap( head.object) ) ;
- SEXP x = PROTECT( Rf_cons( y , tail) ) ;
- SET_TAG( x, Rf_install( head.name.c_str() ) );
+ SEXP x = PROTECT( Rf_cons( y , tail) ) ;
+ SEXP headNameSym = ::Rf_install( head.name.c_str() ); // cannot be gc()ed once in symbol table
+ SET_TAG( x, headNameSym );
UNPROTECT(2);
return x;
}
More information about the Rcpp-commits
mailing list