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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jun 21 13:56:11 CEST 2012


Author: edd
Date: 2012-06-21 13:56:11 +0200 (Thu, 21 Jun 2012)
New Revision: 3634

Modified:
   pkg/Rcpp/R/loadRcppModules.R
Log:
whitespace / indentation change 
use lib.loc on packageDescription() call as suggested by Kurt


Modified: pkg/Rcpp/R/loadRcppModules.R
===================================================================
--- pkg/Rcpp/R/loadRcppModules.R	2012-06-20 19:23:44 UTC (rev 3633)
+++ pkg/Rcpp/R/loadRcppModules.R	2012-06-21 11:56:11 UTC (rev 3634)
@@ -16,41 +16,41 @@
 # along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
 
 loadRcppModules <- function(direct=TRUE){
-   # hunt for the namespace of the package that calls this
-   calls <- sys.calls()
-   w <- which( sapply( calls, function(call){
-      identical( call[[1L]], as.name( "runHook" ) ) 
-   } ) )
-   if( !length(w) ) 
-    stop( "loadRcppModules can only be used within a .onLoad function" )
-   w <- w[ length(w) ]
-   call <- calls[[w]]
-   if( !identical( call[[2L]], ".onLoad" ) ) 
-    stop( "loadRcppModules can only be used within a .onLoad function" )
-   f <- sys.frame( w )
-   ns <- get("env", f )
-   if( !isNamespace( ns ) ) 
-    stop( "loadRcppModules not called from a namespace" )
-   pkg <- get( "pkgname", f )
-    
-   # look for declared modules in the DESCRIPTION fields
-   description <- packageDescription( pkg )
-   modules <- description[["RcppModules"]]
-   if( !is.null( modules ) ){
+    ## hunt for the namespace of the package that calls this
+    calls <- sys.calls()
+    w <- which( sapply( calls, function(call){
+        identical( call[[1L]], as.name( "runHook" ) )
+    } ) )
+    if( !length(w) )
+        stop( "loadRcppModules can only be used within a .onLoad function" )
+    w <- w[ length(w) ]
+    call <- calls[[w]]
+    if( !identical( call[[2L]], ".onLoad" ) )
+        stop( "loadRcppModules can only be used within a .onLoad function" )
+    f <- sys.frame( w )
+    ns <- get("env", f )
+    if( !isNamespace( ns ) )
+        stop( "loadRcppModules not called from a namespace" )
+    pkg <- get( "pkgname", f )
+    lib <- get( "libname", f )
+
+    ## look for declared modules in the DESCRIPTION fields
+    description <- packageDescription(pkg, lib.loc=lib)
+    modules <- description[["RcppModules"]]
+    if( !is.null( modules ) ){
         modules <- strsplit( modules, "[[:space:]]*,[[:space:]]*")[[1L]]
         for( m in modules ){
             tryCatch( {
                 mod <- Module( m, pkg, mustStart = TRUE)
                 if(isTRUE(direct)){
-                   populate( mod, ns )
+                    populate( mod, ns )
                 } else {
-                    forceAssignInNamespace( m, mod, ns ) 
+                    forceAssignInNamespace( m, mod, ns )
                 }
                 assign(.moduleMetaName(m), mod, envir = ns)
             }, error = function(e){
-                stop( sprintf( "failed to load module %s from package %s\n%s", m, pkg, conditionMessage(e) ) )  
+                stop( sprintf( "failed to load module %s from package %s\n%s", m, pkg, conditionMessage(e) ) )
             })
         }
    }
-    
 }



More information about the Rcpp-commits mailing list