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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 31 17:45:27 CET 2012


Author: jjallaire
Date: 2012-10-31 17:45:26 +0100 (Wed, 31 Oct 2012)
New Revision: 3875

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/R/Attributes.R
   pkg/Rcpp/man/cppFunction.Rd
   pkg/Rcpp/man/sourceCpp.Rd
Log:
add parameter to onBuild hook to indicate if the source was from a 'code' parameter; rename show.output to showOutput

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2012-10-31 16:22:28 UTC (rev 3874)
+++ pkg/Rcpp/ChangeLog	2012-10-31 16:45:26 UTC (rev 3875)
@@ -1,7 +1,9 @@
 2012-10-31  JJ Allaire <jj at rstudio.org>
 
 	* R/Attributes.R: add cppFunction for inline-style definitions; 
-	change 'local' param to (more clear and explicit) 'envir' param.
+	change 'local' param to (more clear and explicit) 'envir' param;
+	change 'show.output' param to 'showOutput'; add parameter to 
+	onBuild hook to indicate if the source was from a 'code' parameter
 	* src/Attributes.cpp: factored parser into it's own file; eliminated 
 	tranposition of roxygen comments.
 	* src/AttributesParser.h: attributes parser header

Modified: pkg/Rcpp/R/Attributes.R
===================================================================
--- pkg/Rcpp/R/Attributes.R	2012-10-31 16:22:28 UTC (rev 3874)
+++ pkg/Rcpp/R/Attributes.R	2012-10-31 16:45:26 UTC (rev 3875)
@@ -21,7 +21,7 @@
                       code = NULL,
                       envir = globalenv(), 
                       rebuild = FALSE,
-                      show.output = verbose,
+                      showOutput = verbose,
                       verbose = getOption("verbose")) {
     
     # resolve code into a file if necessary
@@ -60,7 +60,8 @@
         # call the onBuild hook. note that this hook should always be called
         # after .setupBuildEnvironment so subscribers are able to examine
         # the build environment
-        if (!.callBuildHook(context$cppSourcePath, show.output)) {
+        fromCode <- !missing(code)
+        if (!.callBuildHook(context$cppSourcePath, fromCode, showOutput)) {
             .restoreEnvironment(envRestore)
             setwd(cwd)
             return (invisible(NULL))
@@ -81,21 +82,21 @@
             })
         }
            
-        # prepare the command (output if we are in show.output mode)
+        # prepare the command (output if we are in showOutput mode)
         cmd <- paste(R.home(component="bin"), .Platform$file.sep, "R ",
                      "CMD SHLIB ",  
                      "-o ", shQuote(context$dynlibFilename), " ",
                      ifelse(rebuild, "--preclean ", ""),
                      shQuote(context$cppSourceFilename), sep="")
-        if (show.output)
+        if (showOutput)
             cat(cmd, "\n")
         
-        # execute the build -- suppressWarnings b/c when show.output = FALSE
+        # execute the build -- suppressWarnings b/c when showOutput = FALSE
         # we are going to explicitly check for an error and print the output
-        result <- suppressWarnings(system(cmd, intern = !show.output))
+        result <- suppressWarnings(system(cmd, intern = !showOutput))
         
         # check build results
-        if(!show.output) {
+        if(!showOutput) {
             # capture output
             output <- result
             attributes(output) <- NULL
@@ -136,6 +137,7 @@
                         includes = NULL,
                         envir = parent.frame(),
                         rebuild = FALSE,
+                        showOutput = verbose,
                         verbose = getOption("verbose")) {
     
     # generate required scaffolding
@@ -174,6 +176,7 @@
     exported <- sourceCpp(code = code, 
                           envir = envir, 
                           rebuild = rebuild, 
+                          showOutput = showOutput,
                           verbose = verbose)
     
     # verify that a single function was exported and return it
@@ -366,11 +369,11 @@
 
 # Call the onBuild hook. This hook is provided so that external tools
 # can perform processing (e.g. lint checking or other diagnostics) prior
-# to the execution of a build). The show.output flag is there to inform the
+# to the execution of a build). The showOutput flag is there to inform the
 # subscriber whether they'll be getting output in the onBuildComplete hook
 # or whether it will need to be scraped from the console (for verbose=TRUE)
 # The onBuild hook is always called from within the temporary build directory
-.callBuildHook <- function(file, show.output) {
+.callBuildHook <- function(file, fromCode, showOutput) {
         
     for (fun in .getHooksList("sourceCpp.onBuild")) {
         
@@ -379,7 +382,7 @@
         
         # allow the hook to cancel the build (errors in the hook explicitly
         # do not cancel the build since they are unexpected bugs)
-        continue <- tryCatch(fun(file, show.output),
+        continue <- tryCatch(fun(file, fromCode, showOutput),
                              error = function(e) TRUE)
         
         if (!continue)
@@ -391,7 +394,7 @@
 
 # Call the onBuildComplete hook. This hook is provided so that external tools
 # can do analysis of build errors and (for example) present them in a 
-# navigable list. Note that the output parameter will be NULL when show.output
+# navigable list. Note that the output parameter will be NULL when showOutput
 # is TRUE. Tools can try to scrape the output from the console (in an 
 # implemenentation-dependent fashion) or can simply not rely on output 
 # processing in that case (since the user explicitly asked for output to be

Modified: pkg/Rcpp/man/cppFunction.Rd
===================================================================
--- pkg/Rcpp/man/cppFunction.Rd	2012-10-31 16:22:28 UTC (rev 3874)
+++ pkg/Rcpp/man/cppFunction.Rd	2012-10-31 16:45:26 UTC (rev 3875)
@@ -9,7 +9,7 @@
 \usage{
 cppFunction(code, plugin = NULL, includes = NULL, 
             envir = parent.frame(), rebuild = FALSE, 
-            verbose = getOption("verbose"))
+            showOutput = verbose, verbose = getOption("verbose"))
 }
 
 \arguments{
@@ -28,6 +28,9 @@
   \item{rebuild}{
     Force a rebuild of the shared library.
 }
+  \item{showOutput}{
+    \code{TRUE} to print \code{R CMD SHLIB} output to the console.
+}
   \item{verbose}{
     \code{TRUE} to print detailed information about generated code to the console.
 }

Modified: pkg/Rcpp/man/sourceCpp.Rd
===================================================================
--- pkg/Rcpp/man/sourceCpp.Rd	2012-10-31 16:22:28 UTC (rev 3874)
+++ pkg/Rcpp/man/sourceCpp.Rd	2012-10-31 16:45:26 UTC (rev 3875)
@@ -8,7 +8,7 @@
 }
 \usage{
 sourceCpp(file, code = NULL, envir = globalenv(), rebuild = FALSE, 
-          show.output = verbose, verbose = getOption("verbose"), code)
+          showOutput = verbose, verbose = getOption("verbose"), code)
 }
 %- maybe also 'usage' for other objects documented here.
 \arguments{
@@ -24,7 +24,7 @@
   \item{rebuild}{
     Force a rebuild of the shared library.
 }
-  \item{show.output}{
+  \item{showOutput}{
     \code{TRUE} to print \code{R CMD SHLIB} output to the console.
 }
   \item{verbose}{



More information about the Rcpp-commits mailing list