[Rcpp-commits] r2521 - in pkg/Rcpp: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Nov 25 13:28:32 CET 2010
Author: romain
Date: 2010-11-25 13:28:32 +0100 (Thu, 25 Nov 2010)
New Revision: 2521
Added:
pkg/Rcpp/R/populate.R
pkg/Rcpp/man/populate.Rd
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/DESCRIPTION
pkg/Rcpp/NAMESPACE
Log:
+populate : to dump a module in a namespace or an environment
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2010-11-25 12:11:49 UTC (rev 2520)
+++ pkg/Rcpp/ChangeLog 2010-11-25 12:28:32 UTC (rev 2521)
@@ -8,6 +8,11 @@
* R/Module.R: using the formal argument specification if available
+ * R/populate.R: new R function populate to dump the contents of a module
+ into an environment or a namespace
+
+ * man/populate.Rd: documentation for populate
+
2010-11-24 Romain Francois <romain at r-enthusiasts.com>
* R/00_classes.R: formals<- method for C++Function that allows to set default
Modified: pkg/Rcpp/DESCRIPTION
===================================================================
--- pkg/Rcpp/DESCRIPTION 2010-11-25 12:11:49 UTC (rev 2520)
+++ pkg/Rcpp/DESCRIPTION 2010-11-25 12:28:32 UTC (rev 2521)
@@ -1,6 +1,6 @@
Package: Rcpp
Title: Seamless R and C++ Integration
-Version: 0.8.8.3
+Version: 0.8.8.4
Date: $Date$
Author: Dirk Eddelbuettel and Romain Francois, with contributions
by Douglas Bates, John Chambers, Simon Urbanek, and David Reiss;
Modified: pkg/Rcpp/NAMESPACE
===================================================================
--- pkg/Rcpp/NAMESPACE 2010-11-25 12:11:49 UTC (rev 2520)
+++ pkg/Rcpp/NAMESPACE 2010-11-25 12:28:32 UTC (rev 2521)
@@ -39,6 +39,6 @@
exportMethods( prompt, show, .DollarNames, "formals<-" )
export(
- Module, Rcpp.package.skeleton
+ Module, Rcpp.package.skeleton, populate
)
Added: pkg/Rcpp/R/populate.R
===================================================================
--- pkg/Rcpp/R/populate.R (rev 0)
+++ pkg/Rcpp/R/populate.R 2010-11-25 12:28:32 UTC (rev 2521)
@@ -0,0 +1,39 @@
+# Copyright (C) 2010 John Chambers, Dirk Eddelbuettel and Romain Francois
+#
+# This file is part of Rcpp.
+#
+# Rcpp is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# Rcpp is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
+
+populate <- function( module, env ){
+
+ # make sure the module is loaded
+ module <- Module( module, mustStart = TRUE )
+
+ storage <- get( "storage", as.environment(module ) )
+ symbols <- ls( storage )
+
+ is_ns <- isNamespace( env )
+ for( x in symbols ){
+ if( is_ns && exists( x, env ) && bindingIsLocked(x, env ) ){
+ unlockBinding( x, env )
+ }
+
+ assign( x, storage[[x]], env )
+
+ if( is_ns ){
+ lockBinding( x, env )
+ }
+ }
+}
+
Added: pkg/Rcpp/man/populate.Rd
===================================================================
--- pkg/Rcpp/man/populate.Rd (rev 0)
+++ pkg/Rcpp/man/populate.Rd 2010-11-25 12:28:32 UTC (rev 2521)
@@ -0,0 +1,17 @@
+\name{populate}
+\alias{populate}
+\title{
+Populates a namespace or an environment with the content of a module
+}
+\description{
+Populates a namespace or an environment with the content of a module
+}
+\usage{
+populate(module, env)
+}
+\arguments{
+ \item{module}{Rcpp module}
+ \item{env}{environment or namespace}
+}
+\keyword{manip}
+
More information about the Rcpp-commits
mailing list