[Rcpp-commits] r2500 - scripts

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Nov 23 14:39:50 CET 2010


Author: romain
Date: 2010-11-23 14:39:50 +0100 (Tue, 23 Nov 2010)
New Revision: 2500

Modified:
   scripts/generator_Module_CppFunction.R
   scripts/generator_Module_function.R
Log:
docstring for exposed C++ functions

Modified: scripts/generator_Module_CppFunction.R
===================================================================
--- scripts/generator_Module_CppFunction.R	2010-11-23 12:45:52 UTC (rev 2499)
+++ scripts/generator_Module_CppFunction.R	2010-11-23 13:39:50 UTC (rev 2500)
@@ -9,7 +9,7 @@
 class CppFunction%d : public CppFunction {
 	public:
 
-		CppFunction%d(OUT (*fun)(%s) ) : CppFunction(), ptr_fun(fun){}
+		CppFunction%d(OUT (*fun)(%s) , const char* docstring = 0) : CppFunction(docsring), ptr_fun(fun){}
 		
 		SEXP operator()(SEXP* args) throw(std::exception){
 			return Rcpp::wrap( ptr_fun( %s ) ) ;
@@ -24,7 +24,7 @@
 template <%s>
 class CppFunction%d<void,%s> : public CppFunction {
 	public:
-		CppFunction%d(void (*fun)(%s) ) : CppFunction(), ptr_fun(fun){}
+		CppFunction%d(void (*fun)(%s) , const char* docstring = 0) : CppFunction(docstring), ptr_fun(fun){}
 		
 		SEXP operator()(SEXP* args) throw(std::exception) {
 			ptr_fun( %s ) ;
@@ -86,7 +86,7 @@
 template <typename OUT>
 class CppFunction0 : public CppFunction {
 	public:
-		CppFunction0(OUT (*fun)(void) ) : CppFunction(), ptr_fun(fun){}
+		CppFunction0(OUT (*fun)(void), const char* docstring = 0 ) : CppFunction(docstring), ptr_fun(fun){}
 		SEXP operator()(SEXP*) throw(std::range_error) {
 			return Rcpp::wrap( ptr_fun() ) ;
 		}
@@ -101,7 +101,7 @@
 template <>
 class CppFunction0<void> : public CppFunction {
 	public:
-		CppFunction0(void (*fun)(void) ) : CppFunction(), ptr_fun(fun){} ;
+		CppFunction0(void (*fun)(void), const char* docstring = 0 ) : CppFunction(docstring), ptr_fun(fun){} ;
 		
 		SEXP operator()(SEXP*) throw(std::exception) {
 			ptr_fun() ;

Modified: scripts/generator_Module_function.R
===================================================================
--- scripts/generator_Module_function.R	2010-11-23 12:45:52 UTC (rev 2499)
+++ scripts/generator_Module_function.R	2010-11-23 13:39:50 UTC (rev 2500)
@@ -3,10 +3,10 @@
 	
 txt <- sprintf( '
 template <typename OUT%s>                                                                   
-void function( const char* name_,  OUT (*fun)(%s)){
+void function( const char* name_,  OUT (*fun)(%s), const char* docstring = 0){
   Rcpp::Module* scope = ::getCurrentScope() ;
   if( scope ){
-    scope->Add( name_, new CppFunction%d<OUT%s>( fun ) ) ;
+    scope->Add( name_, new CppFunction%d<OUT%s>( fun, docstring ) ) ;
   }
 }
 ', 



More information about the Rcpp-commits mailing list