[Rcpp-commits] r1081 - in pkg/Rcpp: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Mon Apr 19 12:12:38 CEST 2010


Author: romain
Date: 2010-04-19 12:12:36 +0200 (Mon, 19 Apr 2010)
New Revision: 1081

Modified:
   pkg/Rcpp/R/cppfunction.R
   pkg/Rcpp/man/cppfunction.Rd
Log:
add the forward.exceptions argument to cppfunction

Modified: pkg/Rcpp/R/cppfunction.R
===================================================================
--- pkg/Rcpp/R/cppfunction.R	2010-04-18 23:27:01 UTC (rev 1080)
+++ pkg/Rcpp/R/cppfunction.R	2010-04-19 10:12:36 UTC (rev 1081)
@@ -66,7 +66,7 @@
 cppfunction <- function (sig = character(), body = character(), includes = character(), 
     otherdefs = character(), verbose = FALSE, 
     cppargs = character(), cxxargs = character(), libargs = character(), 
-    namespace = TRUE ){
+    namespace = TRUE, forward.exceptions = TRUE ){
 	
     ok <- HAVEINLINE                                                                                
 	if( !ok){
@@ -86,6 +86,9 @@
 	if( isTRUE( namespace ) ){
 		includes <- c( includes, "using namespace Rcpp;" )
 	}
+	if( isTRUE( forward.exceptions ) ){
+		body <- sprintf( "try{ %s } catch( std::exception& __ex__){ forward_exception_to_r( __ex__ ) ; } ", body )
+	}
 	fx <- cfunction( sig = sig, body = body, includes = includes, 
 		otherdefs = otherdefs, language = "C++", convention = ".Call", 
 		Rcpp = TRUE, cppargs = cppargs, cxxargs = cxxargs, libargs = libargs, 

Modified: pkg/Rcpp/man/cppfunction.Rd
===================================================================
--- pkg/Rcpp/man/cppfunction.Rd	2010-04-18 23:27:01 UTC (rev 1080)
+++ pkg/Rcpp/man/cppfunction.Rd	2010-04-19 10:12:36 UTC (rev 1081)
@@ -23,6 +23,8 @@
 \item{libargs}{See \link[inline]{cfunction}}
 \item{namespace}{If \code{TRUE} the line "using namespace Rcpp; " is added
 to the includes list}
+\item{forward.exceptions}{If \code{TRUE}, the body is explicitely wrapped so that 
+c++ exceptions are forwarded as R conditions. }
 }
 \details{
 	As opposed to \link[inline]{cfunction}, this function can only code 



More information about the Rcpp-commits mailing list