[Rcpp-commits] r4321 - in pkg/Rcpp: . R inst man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue May 21 12:36:05 CEST 2013


Author: jjallaire
Date: 2013-05-21 12:36:04 +0200 (Tue, 21 May 2013)
New Revision: 4321

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/R/Attributes.R
   pkg/Rcpp/inst/NEWS.Rd
   pkg/Rcpp/man/pluginsAttribute.Rd
Log:
Lookup plugins in inline package if they aren't found within the Rcpp package

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-05-18 01:48:15 UTC (rev 4320)
+++ pkg/Rcpp/ChangeLog	2013-05-21 10:36:04 UTC (rev 4321)
@@ -1,3 +1,9 @@
+2013-05-21  J.J. Allaire <jj at rstudio.org>
+
+        * R/Attributes.R: Lookup plugins in inline package if they aren't
+        found within the Rcpp package
+        * man/pluginsAttribute.Rd: Documentation updates.
+
 2013-05-17  J.J. Allaire <jj at rstudio.org>
 
         * src/attributes.cpp: prevent gc problems with RNGScope destructor

Modified: pkg/Rcpp/R/Attributes.R
===================================================================
--- pkg/Rcpp/R/Attributes.R	2013-05-18 01:48:15 UTC (rev 4320)
+++ pkg/Rcpp/R/Attributes.R	2013-05-21 10:36:04 UTC (rev 4321)
@@ -198,7 +198,7 @@
         
         # append plugin includes
         for (pluginName in plugins) {
-            plugin <- .plugins[[pluginName]]
+            plugin <- .findPlugin(pluginName)
             settings <- plugin()
             scaffolding <- c(scaffolding, settings$includes, recursive=TRUE)
         }
@@ -445,6 +445,25 @@
              error = function(e) NULL) 
 }
 
+# Lookup a plugin (first in our package then in the inline package)
+.findPlugin <- function(pluginName) {
+    # lookup in our plugins
+    plugin <- .plugins[[pluginName]]
+    
+    # if necessary lookup in the inline package
+    if (is.null(plugin))
+        if (length(find.package("inline", quiet=TRUE)) > 0)
+            plugin <- inline:::plugins[[pluginName]]
+    
+    # error if plugin not found
+    if (is.null(plugin))
+        stop("Inline plugin '", pluginName, "' could not be found ",
+             "within either the Rcpp or inline package. You should be ",
+             "sure to call registerPlugin before using a plugin.")
+    
+    return(plugin)
+}
+
 # Setup the build environment based on the specified dependencies. Returns an
 # opaque object that can be passed to .restoreEnvironment to reverse whatever
 # changes that were made
@@ -507,9 +526,7 @@
     
     # process plugins
     for (pluginName in plugins) {
-        plugin <- .plugins[[pluginName]]
-        if (is.null(plugin))
-            stop("Inline plugin '", pluginName, "' could not be found.")
+        plugin <- .findPlugin(pluginName)
         setDependenciesFromPlugin(plugin)
     }
     

Modified: pkg/Rcpp/inst/NEWS.Rd
===================================================================
--- pkg/Rcpp/inst/NEWS.Rd	2013-05-18 01:48:15 UTC (rev 4320)
+++ pkg/Rcpp/inst/NEWS.Rd	2013-05-21 10:36:04 UTC (rev 4321)
@@ -11,6 +11,8 @@
       RNGScope destructor could cause a crash.
       \item Don't include package header file in generated C++ interface
       header files.
+      \item Lookup plugins in \pkg{inline} package if they aren't found
+      within the \pkg{Rcpp} package.
     }
     \item Changes in Rcpp API:
     \itemize{

Modified: pkg/Rcpp/man/pluginsAttribute.Rd
===================================================================
--- pkg/Rcpp/man/pluginsAttribute.Rd	2013-05-18 01:48:15 UTC (rev 4320)
+++ pkg/Rcpp/man/pluginsAttribute.Rd	2013-05-21 10:36:04 UTC (rev 4321)
@@ -21,6 +21,9 @@
 Plugins must be registered using the \code{\link{registerPlugin}}
 function. 
 
+If a plugin is not found within the \pkg{Rcpp} package then the 
+\pkg{inline} package will also be searched for a matching plugin.
+
 When included within a \code{\link{sourceCpp}} translation unit,
 the configuration-related fields of the plugin (e.g. \code{env} and 
 \code{LinkingTo}) are utilized, however the code-generation fields



More information about the Rcpp-commits mailing list