[Rcpp-commits] r1302 - in pkg/Rcpp: . R inst inst/unitTests src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri May 21 10:12:47 CEST 2010
Author: romain
Date: 2010-05-21 10:12:47 +0200 (Fri, 21 May 2010)
New Revision: 1302
Modified:
pkg/Rcpp/NEWS
pkg/Rcpp/R/exceptions.R
pkg/Rcpp/inst/ChangeLog
pkg/Rcpp/inst/unitTests/runit.Language.R
pkg/Rcpp/src/Evaluator.cpp
Log:
evaluating expression in environment did not work (reported by Doug on Rcpp-deve)
Modified: pkg/Rcpp/NEWS
===================================================================
--- pkg/Rcpp/NEWS 2010-05-20 19:06:26 UTC (rev 1301)
+++ pkg/Rcpp/NEWS 2010-05-21 08:12:47 UTC (rev 1302)
@@ -1,3 +1,7 @@
+0.8.1 (under development)
+
+ o Evaluating a call inside an environment did not work properly
+
0.8.0 2010-05-17
o All Rcpp headers have been moved to the inst/include directory,
Modified: pkg/Rcpp/R/exceptions.R
===================================================================
--- pkg/Rcpp/R/exceptions.R 2010-05-20 19:06:26 UTC (rev 1301)
+++ pkg/Rcpp/R/exceptions.R 2010-05-21 08:12:47 UTC (rev 1302)
@@ -52,14 +52,15 @@
}
# simplified version of utils::tryCatch
-rcpp_tryCatch <- function(expr,env){
+rcpp_tryCatch <- function(expr, unused){ # unused is kept for compatibility, but is indeed not used
resetCurrentError()
rcpp_doTryCatch <- function(expr, env) {
.Internal(.addCondHands("error", list(.rcpp_error_recorder),
env, environment(), FALSE))
expr
}
- value <- rcpp_doTryCatch( return(expr), env )
+ parentenv <- parent.frame()
+ value <- rcpp_doTryCatch( return(expr), parentenv )
if (is.null(value[[1L]])) {
# a simple error; message is stored internally
# and call is in result; this defers all allocs until
Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog 2010-05-20 19:06:26 UTC (rev 1301)
+++ pkg/Rcpp/inst/ChangeLog 2010-05-21 08:12:47 UTC (rev 1302)
@@ -1,3 +1,24 @@
+2010-05-21 Romain Francois <romain at r-enthusiasts.com>
+
+ * R/exceptions.R: rework rcpp_tryCatch to prevent evaluating the expression
+ too early (reported by Doug Bates on Rcpp-devel)
+
+ * src/Evaluator.cpp: rework Evaluator::run() so that it correctly evaluates
+ inside an environment (reported by Doug Bates on Rcpp-devel)
+
+2010-05-20 Romain Francois <romain at r-enthusiasts.com>
+
+ * inst/include/Rcpp/Vector.h : correct throw specs for vector_from_string
+ (reported by Brian Ripley from solaris)
+
+ * inst/include/Rcpp/internal/Proxy_Iterator.h: fixed constness of several
+ operators in Proxy_Iterator to try to suite suncc/solaris
+
+ * inst/include/Rcpp/config.h: define RCPP_ENABLE_MODULES to hide
+ the experimental module features from the official api
+
+ * R/getDLL.R: removed and promoted to getDynLib in inline
+
2010-05-19 Romain Francois <romain at r-enthusiasts.com>
* inst/include/Rcpp/as.h: add throw specification to as
Modified: pkg/Rcpp/inst/unitTests/runit.Language.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Language.R 2010-05-20 19:06:26 UTC (rev 1301)
+++ pkg/Rcpp/inst/unitTests/runit.Language.R 2010-05-21 08:12:47 UTC (rev 1302)
@@ -189,3 +189,15 @@
checkEquals( res, exp, msg = "std::generate" )
}
+test.Language.in.env <- function(){
+
+ fx <- cppfunction( signature(x = "environment" ), '
+ Environment env(x) ;
+ Language call( "sum", Symbol("y") ) ;
+ return call.eval( env ) ;
+ ' )
+
+ e <- new.env()
+ e[["y"]] <- 1:10
+ checkEquals( fx(e), sum(1:10), msg = "Language::eval( SEXP )" )
+}
Modified: pkg/Rcpp/src/Evaluator.cpp
===================================================================
--- pkg/Rcpp/src/Evaluator.cpp 2010-05-20 19:06:26 UTC (rev 1301)
+++ pkg/Rcpp/src/Evaluator.cpp 2010-05-21 08:12:47 UTC (rev 1302)
@@ -24,7 +24,12 @@
namespace Rcpp {
SEXP Evaluator::run(SEXP expr, SEXP env) throw(eval_error) {
- SEXP call = PROTECT( Rf_lang3( Rf_install("rcpp_tryCatch") , expr, env ) ) ;
+ SEXP call = PROTECT(
+ Rf_lang2(
+ Rf_install("rcpp_tryCatch") ,
+ Rf_lang3( Rf_install( "evalq") , expr, env )
+ )
+ ) ;
Environment RCPP = Environment::Rcpp_namespace();
More information about the Rcpp-commits
mailing list