[Rcpp-commits] r3051 - scripts

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Jun 7 15:45:52 CEST 2011


Author: romain
Date: 2011-06-07 15:45:51 +0200 (Tue, 07 Jun 2011)
New Revision: 3051

Modified:
   scripts/generator_Module_CppMethod.R
Log:
updated generator

Modified: scripts/generator_Module_CppMethod.R
===================================================================
--- scripts/generator_Module_CppMethod.R	2011-06-07 13:16:59 UTC (rev 3050)
+++ scripts/generator_Module_CppMethod.R	2011-06-07 13:45:51 UTC (rev 3051)
@@ -30,6 +30,27 @@
 		Method met ;
 	} ;
 	
+	template < typename Class, typename T, %s >
+	class CppMethod%d <Class, result<T>, %s> : public CppMethod<Class> {
+	public:
+		typedef result<T> (Class::*Method)(%s) ;
+		typedef CppMethod<Class> method_class ;
+		
+		CppMethod%d(Method m) : method_class(), met(m) {} 
+		SEXP operator()( Class* object, SEXP* args){
+		    T* ptr = (object->*met)( %s ) ;
+			return internal::make_new_object<T>(ptr) ;
+		}
+		inline int nargs(){ return %d ; }
+		inline bool is_void(){ return false ; }
+		inline bool is_const(){ return false ; }
+		inline void signature(std::string& s, const char* name ){ Rcpp::signature<result<T>,%s>(s, name) ; }
+		
+	private:
+		Method met ;
+	} ;
+	
+	
 	template < typename Class, %s > class CppMethod%d<Class,void,%s> : public CppMethod<Class> {
 	public:
 		typedef void (Class::*Method)(%s) ;
@@ -48,6 +69,8 @@
 		Method met ;
 	} ;
 
+	
+	
 
 
 	template < typename Class, typename OUT, %s > class const_CppMethod%d : public CppMethod<Class> {
@@ -68,6 +91,26 @@
 		Method met ;
 	} ;
 	
+	template < typename Class, typename T, %s > 
+	class const_CppMethod%d <Class, result<T>, %s> : public CppMethod<Class> {
+	public:
+		typedef result<T> (Class::*Method)(%s) const ;
+		typedef CppMethod<Class> method_class ;
+		
+		const_CppMethod%d(Method m) : method_class(), met(m){} 
+		SEXP operator()( Class* object, SEXP* args){
+		    T* ptr = (object->*met)( %s ) ;
+			return internal::make_new_object<T>(ptr) ;
+		}
+		inline int nargs(){ return %d ; }
+		inline bool is_void(){ return false ; }
+		inline bool is_const(){ return true ; }
+		inline void signature(std::string& s, const char* name ){ Rcpp::signature<result<T>,%s>(s, name) ; }
+		
+	private:
+		Method met ;
+	} ;
+	
 	template < typename Class, %s > class const_CppMethod%d<Class,void,%s> : public CppMethod<Class> {
 	public:
 		typedef void (Class::*Method)(%s) const ;
@@ -97,7 +140,16 @@
 U,
 
 typenames,  # typename U0, ...
+i,           
+U, 
+u,          # U0 u0, ...
 i, 
+as,         # Rcpp::as<U0>( args[0] ) , ...
+i, 
+U,
+
+typenames,  # typename U0, ...
+i, 
 U, 			# U0, ...
 u,          # U0 u0, ...
 i,
@@ -115,7 +167,16 @@
 U, 
 
 typenames,  # typename U0, ...
+i,           
+U, 
+u,          # U0 u0, ...
 i, 
+as,         # Rcpp::as<U0>( args[0] ) , ...
+i, 
+U,
+
+typenames,  # typename U0, ...
+i, 
 U, 			 # U0, ...
 u,          # U0 u0, ...
 i, 
@@ -123,7 +184,6 @@
 i,
 U 
 
-
 )   
 
 }
@@ -187,7 +247,29 @@
 	private:
 		Method met ;
 	} ;
+	
+	template <typename Class, typename T> 
+	class CppMethod0< Class, result<T> > : public CppMethod<Class> {
+	public:
+		typedef result<T> (Class::*Method)(void) ;
+		typedef CppMethod<Class> method_class ;
+		typedef XPtr<T> XP ;
+		CppMethod0( Method m) : method_class(), met(m){} 
+		SEXP operator()( Class* object, SEXP* ){
+		    T* ptr = (object->*met)( ) ;
+			return internal::make_new_object<T>(ptr) ; 
+		}
+		inline int nargs(){ return 0 ; }
+		inline bool is_void(){ return false ; }
+		inline bool is_const(){ return false ; }
+		inline void signature(std::string& s, const char* name){ Rcpp::signature< result<T> >(s, name) ; }
+		
+	private:
+		Method met ;
+	} ;
+	
 
+	
 	template <typename Class, typename OUT> class const_CppMethod0 : public CppMethod<Class> {
 	public:
 		typedef OUT (Class::*Method)(void) const ;
@@ -223,6 +305,27 @@
 		Method met ;
 	} ;
 
+	template <typename Class, typename T> 
+	class const_CppMethod0< Class, result<T> > : public CppMethod<Class> {
+	public:
+		typedef result<T> (Class::*Method)(void) const ;
+		typedef CppMethod<Class> method_class ;
+		typedef XPtr<T> XP ;
+		const_CppMethod0( Method m) : method_class(), met(m){} 
+		SEXP operator()( Class* object, SEXP* ){
+		    T* ptr = (object->*met)( ) ;
+			return internal::make_new_object<T>(ptr) ; 
+		}
+		inline int nargs(){ return 0 ; }
+		inline bool is_void(){ return false ; }
+		inline bool is_const(){ return false ; }
+		inline void signature(std::string& s, const char* name){ Rcpp::signature< result<T> >(s, name) ; }
+		
+	private:
+		Method met ;
+	} ;
+	
+	
 %s
 
 #endif



More information about the Rcpp-commits mailing list