[Rcpp-commits] r3871 - in pkg/Rcpp: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Oct 31 14:39:02 CET 2012
Author: jjallaire
Date: 2012-10-31 14:39:02 +0100 (Wed, 31 Oct 2012)
New Revision: 3871
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/R/Attributes.R
pkg/Rcpp/man/sourceCpp.Rd
Log:
sourceCpp: change 'local' param to (more clear) 'envir' param
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2012-10-31 13:20:12 UTC (rev 3870)
+++ pkg/Rcpp/ChangeLog 2012-10-31 13:39:02 UTC (rev 3871)
@@ -1,9 +1,11 @@
2012-10-30 JJ Allaire <jj at rstudio.org>
+ * R/Attributes.R: change 'local' param to (more explicit) 'envir'
* src/Attributes.cpp: factored parser into it's own file; eliminated
tranposition of roxygen comments.
* src/AttributesParser.h: attributes parser header
* src/AttributesParser.cpp: attributes parser implementation
+ * man/source.Cpp.Rd: documentation updates
2012-10-31 Romain Francois <romain at r-enthusiasts.com>
Modified: pkg/Rcpp/R/Attributes.R
===================================================================
--- pkg/Rcpp/R/Attributes.R 2012-10-31 13:20:12 UTC (rev 3870)
+++ pkg/Rcpp/R/Attributes.R 2012-10-31 13:39:02 UTC (rev 3871)
@@ -19,7 +19,7 @@
# Source C++ code from a file
sourceCpp <- function(file = "",
code = NULL,
- local = FALSE,
+ envir = globalenv(),
rebuild = FALSE,
show.output = verbose,
verbose = getOption("verbose")) {
@@ -124,12 +124,7 @@
# source the R script
scriptPath <- file.path(context$buildDirectory, context$rSourceFilename)
- if (is.environment(local))
- source(scriptPath, local = local)
- else if (local)
- source(scriptPath, local = parent.frame())
- else
- source(scriptPath, local = FALSE)
+ source(scriptPath, local = envir)
# return (invisibly) a list of exported functions
invisible(context$exportedFunctions)
@@ -143,8 +138,8 @@
"// [[Rcpp::export]]", code, sep="\n")
# source cpp into environment we create to hold the function
- env <- new.env()
- exported <- sourceCpp(code = code, local = env)
+ envir <- new.env()
+ exported <- sourceCpp(code = code, envir = envir)
# verify that a single function was exported and return it
if (length(exported) == 0)
@@ -153,7 +148,7 @@
stop("More than one function definition")
else {
functionName <- exported[[1]]
- get(functionName, env)
+ get(functionName, envir)
}
}
Modified: pkg/Rcpp/man/sourceCpp.Rd
===================================================================
--- pkg/Rcpp/man/sourceCpp.Rd 2012-10-31 13:20:12 UTC (rev 3870)
+++ pkg/Rcpp/man/sourceCpp.Rd 2012-10-31 13:39:02 UTC (rev 3871)
@@ -7,7 +7,7 @@
\code{sourceCpp} parses the specified C++ file or source code and looks for functions marked with the \code{\link[=exportAttribute]{Rcpp::export}} attribute. A shared library is then built and its exported functions are made available as R functions in the specified environment.
}
\usage{
-sourceCpp(file, code = NULL, local = FALSE, rebuild = FALSE,
+sourceCpp(file, code = NULL, envir = globalenv(), rebuild = FALSE,
show.output = verbose, verbose = getOption("verbose"), code)
}
%- maybe also 'usage' for other objects documented here.
@@ -18,8 +18,8 @@
\item{code}{
A character string with C++ source code to compile
}
- \item{local}{
- \code{TRUE}, \code{FALSE} or an environment, determining where the R functions will be made available. \code{FALSE} (the default) corresponds to the user's workspace (the global environment) and \code{TRUE} to the environment from which source is called
+ \item{envir}{
+ Environment where the R functions should be made available
}
\item{rebuild}{
Force a rebuild of the shared library by passing \code{--preclean} to \code{R CMD SHLIB}
More information about the Rcpp-commits
mailing list