[Rcpp-commits] r3472 - pkg/Rcpp/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Feb 14 17:43:10 CET 2012


Author: edd
Date: 2012-02-14 17:43:10 +0100 (Tue, 14 Feb 2012)
New Revision: 3472

Modified:
   pkg/Rcpp/R/tools.R
Log:
adds a branch for R 2.15.0 to use assignInMyNamespace()


Modified: pkg/Rcpp/R/tools.R
===================================================================
--- pkg/Rcpp/R/tools.R	2012-02-14 01:56:01 UTC (rev 3471)
+++ pkg/Rcpp/R/tools.R	2012-02-14 16:43:10 UTC (rev 3472)
@@ -1,4 +1,4 @@
-# Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
+# Copyright (C) 2010 - 2012 Dirk Eddelbuettel and Romain Francois
 #
 # This file is part of Rcpp.
 #
@@ -16,19 +16,21 @@
 # along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
 
 externalptr_address <- function(xp){
-	.Call( as_character_externalptr, xp )	
+    .Call( as_character_externalptr, xp )
 }
 
-# just like assignInNamespace but first checks that the binding exists             
+# just like assignInNamespace but first checks that the binding exists
 forceAssignInNamespace <- function( x, value, env ){
-    is_ns <- isNamespace( env )
-    if( is_ns && exists( x, env ) && bindingIsLocked(x, env ) ){
-        unlockBinding( x, env )
+    if (getRversion() >= "2.15.0") {
+        assignInMyNamespace(x, value)
+    } else {
+        is_ns <- isNamespace( env )
+        if( is_ns && exists( x, env ) && bindingIsLocked(x, env ) ){
+            unlockBinding( x, env )
+        }
+        assign( x, value, env )
+        if( is_ns ){
+            lockBinding( x, env )
+        }
     }
-    
-    assign( x, value, env )
-    
-    if( is_ns ){
-        lockBinding( x, env )
-    }    
 }



More information about the Rcpp-commits mailing list