[Rcpp-commits] r1096 - in pkg/Rcpp: R inst/include/Rcpp inst/unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Apr 21 12:09:02 CEST 2010


Author: romain
Date: 2010-04-21 12:09:01 +0200 (Wed, 21 Apr 2010)
New Revision: 1096

Modified:
   pkg/Rcpp/R/cppfunction.R
   pkg/Rcpp/inst/include/Rcpp/preprocessor.h
   pkg/Rcpp/inst/unitTests/runit.environments.R
Log:
use BEGIN_RCPP and END_RCPP in cppfunction as well, add the catch(...) to END_RCPP

Modified: pkg/Rcpp/R/cppfunction.R
===================================================================
--- pkg/Rcpp/R/cppfunction.R	2010-04-21 09:43:52 UTC (rev 1095)
+++ pkg/Rcpp/R/cppfunction.R	2010-04-21 10:09:01 UTC (rev 1096)
@@ -52,7 +52,11 @@
 		includes <- c( includes, "using namespace Rcpp;" )
 	}
 	if( isTRUE( forward.exceptions ) ){
-		body <- sprintf( "try{ %s } catch( std::exception& __ex__){ forward_exception_to_r( __ex__ ) ; } ", body )
+		body <- sprintf( 
+"BEGIN_RCPP
+%s
+END_RCPP
+", body )
 	}
 	fx <- cfunction( sig = sig, body = body, includes = includes, 
 		otherdefs = otherdefs, language = "C++", convention = ".Call", 

Modified: pkg/Rcpp/inst/include/Rcpp/preprocessor.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/preprocessor.h	2010-04-21 09:43:52 UTC (rev 1095)
+++ pkg/Rcpp/inst/include/Rcpp/preprocessor.h	2010-04-21 10:09:01 UTC (rev 1096)
@@ -52,7 +52,7 @@
 #endif 
 
 #ifndef END_RCPP
-#define END_RCPP } catch( std::exception& __ex___ ){ forward_exception_to_r( __ex__ ) ; }
+#define END_RCPP } catch( std::exception& __ex__ ){ forward_exception_to_r( __ex__ ) ; } catch(...){ ::Rf_error( "c++ exception (unknown reason)" ) ; }
 #endif
 
 #include <Rcpp/preprocessor_generated.h>

Modified: pkg/Rcpp/inst/unitTests/runit.environments.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.environments.R	2010-04-21 09:43:52 UTC (rev 1095)
+++ pkg/Rcpp/inst/unitTests/runit.environments.R	2010-04-21 10:09:01 UTC (rev 1096)
@@ -291,7 +291,8 @@
 
 test.environment.remove <- function(){
 	funx <- cppfunction(signature( env = "environment", name = "character" ), '
-	return wrap( Environment(env).remove( as<std::string>(name) ) ) ;
+	bool res = Environment(env).remove( as<std::string>(name) ) ;
+	return wrap( res ) ;
 	'  )
 	
 	e <- new.env( )



More information about the Rcpp-commits mailing list