[Rcpp-commits] r2875 - in pkg/Rcpp: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jan 22 18:30:29 CET 2011


Author: edd
Date: 2011-01-22 18:30:29 +0100 (Sat, 22 Jan 2011)
New Revision: 2875

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/src/Symbol.cpp
Log:
assign Rf_install to local SEXP in three places
also reindented by emacs' defaults


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2011-01-17 22:22:23 UTC (rev 2874)
+++ pkg/Rcpp/ChangeLog	2011-01-22 17:30:29 UTC (rev 2875)
@@ -1,3 +1,7 @@
+2011-01-22  Dirk Eddelbuettel  <edd at debian.org>
+
+	* src/Symbol.cpp (Rcpp): Assign Rf_install() result to local SEXP
+
 2011-01-13  Douglas Bates  <bates at stat.wisc.edu>
 
 	* src/Reference.cpp: Protect the value being set in Reference::FieldProxy::set
@@ -4,9 +8,9 @@
 
 2011-01-11  Romain Francois <romain at r-enthusiasts.com>
 
-	* inst/include/Rcpp/vector/string_proxy.h: fix implicit conversion to int, 
+	* inst/include/Rcpp/vector/string_proxy.h: fix implicit conversion to int,
 	reported by Daniel Sabanes Bove on Rcpp-devel
-	
+
 	* inst/unitTests/runit.vector.R: unit test for the above fix
 
 2011-01-08  Dirk Eddelbuettel  <edd at debian.org>

Modified: pkg/Rcpp/src/Symbol.cpp
===================================================================
--- pkg/Rcpp/src/Symbol.cpp	2011-01-17 22:22:23 UTC (rev 2874)
+++ pkg/Rcpp/src/Symbol.cpp	2011-01-22 17:30:29 UTC (rev 2875)
@@ -23,42 +23,45 @@
 
 namespace Rcpp {
 
-	Symbol::Symbol( SEXP x ) throw(not_compatible) : RObject() {
-		if( x != R_NilValue ){
-			int type = TYPEOF(x) ;
-			switch( type ){
-			case SYMSXP:
-				setSEXP( x ) ;
-				break; /* nothing to do */
-			case CHARSXP:
-				setSEXP( Rf_install(CHAR(x)) ) ;
-				break ;
-			case STRSXP:
-				{
-					/* FIXME: check that there is at least one element */
-					setSEXP( Rf_install( CHAR(STRING_ELT(x, 0 )) ) );
-					break ;
-				}
-			default:
-				throw not_compatible("cannot convert to symbol (SYMSXP)") ;
-			}
-		} 
-	}
+    Symbol::Symbol( SEXP x ) throw(not_compatible) : RObject() {
+	if( x != R_NilValue ){
+	    int type = TYPEOF(x) ;
+	    switch( type ){
+	    case SYMSXP:
+		setSEXP( x ) ;
+		break; /* nothing to do */
+	    case CHARSXP: {
+		SEXP charSym = Rf_install(CHAR(x)); 	// cannot be gc()'ed  once in symbol table
+		setSEXP( charSym ) ;
+		break ;
+	    }
+	    case STRSXP: {
+		/* FIXME: check that there is at least one element */
+		SEXP charSym = Rf_install( CHAR(STRING_ELT(x, 0 )) ); // cannot be gc()'ed  once in symbol table
+		setSEXP( charSym );
+		break ;
+	    }
+	    default:
+		throw not_compatible("cannot convert to symbol (SYMSXP)") ;
+	    }
+	} 
+    }
 	
-	Symbol::Symbol(const std::string& symbol): RObject(){
-		setSEXP( Rf_install(symbol.c_str()) );
-	}
+    Symbol::Symbol(const std::string& symbol): RObject(){
+	SEXP charSym = Rf_install(symbol.c_str()); 	// cannot be gc()'ed  once in symbol table
+	setSEXP( charSym );
+    }
 	
-	Symbol::Symbol( const Symbol& other) : RObject() {
-		setSEXP( other.asSexp() );
-	}
+    Symbol::Symbol( const Symbol& other) : RObject() {
+	setSEXP( other.asSexp() );
+    }
 	
-	Symbol& Symbol::operator=(const Symbol& other){
-		setSEXP( other.asSexp() );
-		return *this;
-	}
+    Symbol& Symbol::operator=(const Symbol& other){
+	setSEXP( other.asSexp() );
+	return *this;
+    }
 	
-	Symbol::~Symbol(){}
+    Symbol::~Symbol(){}
 	
 } // namespace Rcpp
 



More information about the Rcpp-commits mailing list