[Rcpp-commits] r1180 - pkg/Rcpp/inst/include/Rcpp scripts

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu May 6 14:29:45 CEST 2010


Author: romain
Date: 2010-05-06 14:29:45 +0200 (Thu, 06 May 2010)
New Revision: 1180

Modified:
   pkg/Rcpp/inst/include/Rcpp/preprocessor.h
   scripts/DataFrame.R
   scripts/preprocessor.R
Log:
forgot to commit the DataFrame::create code bloat generator

Modified: pkg/Rcpp/inst/include/Rcpp/preprocessor.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/preprocessor.h	2010-05-06 11:33:04 UTC (rev 1179)
+++ pkg/Rcpp/inst/include/Rcpp/preprocessor.h	2010-05-06 12:29:45 UTC (rev 1180)
@@ -105,7 +105,7 @@
 		         
 #define ___RCPP_RETURN___( __FUN__, __SEXP__ , __RCPPTYPE__ )						\
 	SEXP __TMP__ = __SEXP__ ;															\
-	switch( TYPEOF( __TMP__ ) ){														\
+	switch( TYPEOF( __TMP__ ) ){										 				\
 		___RCPP_HANDLE_CASE___( INTSXP  , __FUN__ , __TMP__ , __RCPPTYPE__ )			\
 		___RCPP_HANDLE_CASE___( REALSXP , __FUN__ , __TMP__ , __RCPPTYPE__ )			\
 		___RCPP_HANDLE_CASE___( RAWSXP  , __FUN__ , __TMP__ , __RCPPTYPE__ )			\
@@ -121,5 +121,12 @@
 #define RCPP_RETURN_VECTOR( _FUN_, _SEXP_ )  ___RCPP_RETURN___( _FUN_, _SEXP_ , Vector ) 
 #define RCPP_RETURN_MATRIX( _FUN_, _SEXP_ )  ___RCPP_RETURN___( _FUN_, _SEXP_ , Matrix )
 
+#define RCPP_REGISTER(__NAME__) 
 
+// from boost preprocessor library
+#include <boost/preprocessor/cat.hpp>
+
+#define RCPP_CLASS_START <Rcpp/class_start.h>
+#define RCPP_CLASS_STOP <Rcpp/class_stop.h>
+
 #endif

Modified: scripts/DataFrame.R
===================================================================
--- scripts/DataFrame.R	2010-05-06 11:33:04 UTC (rev 1179)
+++ scripts/DataFrame.R	2010-05-06 12:29:45 UTC (rev 1180)
@@ -7,11 +7,14 @@
 sprintf( '
 template <%s>
 static DataFrame create( %s ) throw(not_compatible){
-	return DataFrame( 
-		internal::convert_using_rfunction( 
-			List::create( %s ), 
-			"as.data.frame" 
-		) ) ;
+	try{
+		return DataFrame( 
+			internal::try_catch( 
+				::Rf_lcons( ::Rf_install( "data.frame"), pairlist( %s ) )
+				) ) ;
+	} catch( eval_error& __ex__){
+		throw not_compatible("error calling the data.frame function") ;
+	}
 }
 ', 
 paste( sprintf( "typename T%d", 1:i ), collapse = ", "), 

Modified: scripts/preprocessor.R
===================================================================
--- scripts/preprocessor.R	2010-05-06 11:33:04 UTC (rev 1179)
+++ scripts/preprocessor.R	2010-05-06 12:29:45 UTC (rev 1180)
@@ -7,6 +7,7 @@
 rcpp_function <- sapply( 0:65, function(i){
 	txt <- sprintf( '
 #define RCPP_FUNCTION_%d(__OUT__,__NAME__%s)        \\
+RCPP_REGISTER(__NAME__)                             \\
 extern "C" SEXP __NAME__##__rcpp_info__( ){         \\
     using Rcpp::_ ;                                 \\
 	Rcpp::List info = Rcpp::List::create(           \\
@@ -42,6 +43,7 @@
 rcpp_function_void <- sapply( 0:65, function(i){
 	txt <- sprintf( '
 #define RCPP_FUNCTION_VOID_%d(__NAME__%s)           \\
+RCPP_REGISTER(__NAME__)                             \\
 void RCPP_DECORATE(__NAME__)(%s) ;                  \\
 extern "C" SEXP __NAME__##__rcpp_info__( ){         \\
     using Rcpp::_ ;                                 \\
@@ -114,6 +116,7 @@
 rcpp_xp_method <- sapply( 0:65, function(i){
 	txt <- sprintf( '
 #define RCPP_XP_METHOD_%d(__NAME__,__CLASS__,__METHOD__ )   \\
+RCPP_REGISTER(__NAME__)                                     \\
 extern "C" SEXP __NAME__##__rcpp_info__( ){                 \\
     using Rcpp::_ ;                                         \\
 	Rcpp::List info = Rcpp::List::create(                    \\
@@ -144,6 +147,7 @@
 rcpp_xp_method_cast <- sapply( 0:65, function(i){
 	txt <- sprintf( '
 #define RCPP_XP_METHOD_CAST_%d(__NAME__,__CLASS__,__METHOD__,__CAST__)   \\
+RCPP_REGISTER(__NAME__)                                     \\
 extern "C" SEXP __NAME__##__rcpp_info__( ){                 \\
     using Rcpp::_ ;                                         \\
 	Rcpp::List info = Rcpp::List::create(                    \\
@@ -177,6 +181,7 @@
 rcpp_xp_method_void <- sapply( 0:65, function(i){
 	txt <- sprintf( '
 #define RCPP_XP_METHOD_VOID_%d(__NAME__,__CLASS__,__METHOD__)    \\
+RCPP_REGISTER(__NAME__)                             \\
 extern "C" SEXP __NAME__##__rcpp_info__( ){                 \\
     using Rcpp::_ ;                                         \\
 	Rcpp::List info = Rcpp::List::create(                    \\



More information about the Rcpp-commits mailing list