[Rcpp-commits] r316 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 8 14:32:58 CET 2010


Author: romain
Date: 2010-01-08 14:32:56 +0100 (Fri, 08 Jan 2010)
New Revision: 316

Modified:
   pkg/src/RcppCommon.cpp
   pkg/src/RcppCommon.h
   pkg/src/exceptions.cpp
Log:
fancy exception handling only for GCC, at least until we know better for other compilers

Modified: pkg/src/RcppCommon.cpp
===================================================================
--- pkg/src/RcppCommon.cpp	2010-01-08 13:06:33 UTC (rev 315)
+++ pkg/src/RcppCommon.cpp	2010-01-08 13:32:56 UTC (rev 316)
@@ -68,8 +68,8 @@
 }
 
 SEXP capabilities(){
-	SEXP cap = PROTECT( Rf_allocVector( LGLSXP, 2) ) ;
-	SEXP names = PROTECT( Rf_allocVector( STRSXP, 2 ) ) ;
+	SEXP cap = PROTECT( Rf_allocVector( LGLSXP, 3) ) ;
+	SEXP names = PROTECT( Rf_allocVector( STRSXP, 3 ) ) ;
 #ifdef HAS_VARIADIC_TEMPLATES
 	LOGICAL(cap)[0] = TRUE ;
 #else
@@ -80,9 +80,16 @@
 #else
 	LOGICAL(cap)[1] = FALSE ;
 #endif
-	
+#ifdef __GNUC__
+	LOGICAL(cap)[2] = TRUE ;
+#else
+	/* just because I don't know */
+	LOGICAL(cap)[2] = FALSE ;
+#endif
+
 	SET_STRING_ELT(names, 0, Rf_mkChar("variadic templates") ) ;
 	SET_STRING_ELT(names, 1, Rf_mkChar("initializer lists") ) ;
+	SET_STRING_ELT(names, 2, Rf_mkChar("exception handling") ) ;
 	Rf_setAttrib( cap, R_NamesSymbol, names ) ;
 	UNPROTECT(2) ;
 	return cap ;

Modified: pkg/src/RcppCommon.h
===================================================================
--- pkg/src/RcppCommon.h	2010-01-08 13:06:33 UTC (rev 315)
+++ pkg/src/RcppCommon.h	2010-01-08 13:32:56 UTC (rev 316)
@@ -70,7 +70,10 @@
 #endif
 
 /* in exceptions.cpp */
+#ifdef __GNUC__
 void forward_uncaught_exceptions_to_r() ;
+#endif 
+
 RcppExport SEXP initUncaughtExceptionHandler() ; 
 
 /* just testing variadic templates */

Modified: pkg/src/exceptions.cpp
===================================================================
--- pkg/src/exceptions.cpp	2010-01-08 13:06:33 UTC (rev 315)
+++ pkg/src/exceptions.cpp	2010-01-08 13:32:56 UTC (rev 316)
@@ -20,6 +20,11 @@
 // along with Rcpp.  If not, see <http://www.gnu.org/licenses/>.
 
 #include <Rcpp.h>
+
+/* for now, the fancy exception handling is only available in GCC, 
+   simply because we've not investigated if it is available in other 
+   compilers */
+#ifdef __GNUC__
 #include <typeinfo>
 #include <exception>
 #include <exception_defines.h>
@@ -74,8 +79,17 @@
 	     ) ; 
 }
 
+
 SEXP initUncaughtExceptionHandler(){
+    /* FIXME: we might want to restore the original handler as the package
+              gets unloaded */
     std::set_terminate(forward_uncaught_exceptions_to_r);
     return R_NilValue ;
 }
+#else
+SEXP initUncaughtExceptionHandler(){
+	Rf_warning( "exception handling not supported by your compiler" ) ; 
+	return R_NilValue ;
+}
+#endif
 



More information about the Rcpp-commits mailing list