[Rcpp-commits] r2491 - in pkg/Rcpp: R inst/include/Rcpp inst/include/Rcpp/module
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Nov 22 19:41:54 CET 2010
Author: romain
Date: 2010-11-22 19:41:54 +0100 (Mon, 22 Nov 2010)
New Revision: 2491
Modified:
pkg/Rcpp/R/00_classes.R
pkg/Rcpp/R/01_show.R
pkg/Rcpp/inst/include/Rcpp/Module.h
pkg/Rcpp/inst/include/Rcpp/module/Module_generated_class_constructor.h
Log:
docstring for constructors
Modified: pkg/Rcpp/R/00_classes.R
===================================================================
--- pkg/Rcpp/R/00_classes.R 2010-11-22 18:12:54 UTC (rev 2490)
+++ pkg/Rcpp/R/00_classes.R 2010-11-22 18:41:54 UTC (rev 2491)
@@ -54,7 +54,8 @@
pointer = "externalptr",
class_pointer = "externalptr",
nargs = "integer",
- signature = "character"
+ signature = "character",
+ docstring = "character"
)
)
Modified: pkg/Rcpp/R/01_show.R
===================================================================
--- pkg/Rcpp/R/01_show.R 2010-11-22 18:12:54 UTC (rev 2490)
+++ pkg/Rcpp/R/01_show.R 2010-11-22 18:41:54 UTC (rev 2491)
@@ -43,7 +43,9 @@
nctors <- length( ctors )
txt <- character( nctors )
for( i in seq_len(nctors) ){
- txt[i] <- sprintf( " %s", ctors[[i]]$signature )
+ ctor <- ctors[[i]]
+ doc <- ctor$docstring
+ txt[i] <- sprintf( " %s%s", ctor$signature, if( nchar(doc) ) sprintf( "\n docstring : %s", doc) else "" )
}
writeLines( "Constructors:" )
writeLines( paste( txt, collapse = "\n" ) )
Modified: pkg/Rcpp/inst/include/Rcpp/Module.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Module.h 2010-11-22 18:12:54 UTC (rev 2490)
+++ pkg/Rcpp/inst/include/Rcpp/Module.h 2010-11-22 18:41:54 UTC (rev 2491)
@@ -179,11 +179,13 @@
SignedConstructor(
Constructor_Base<Class>* ctor_,
- ValidConstructor valid_
- ) : ctor(ctor_), valid(valid_){}
+ ValidConstructor valid_,
+ const char* doc
+ ) : ctor(ctor_), valid(valid_), docstring(doc == 0 ? "" : doc){}
Constructor_Base<Class>* ctor ;
ValidConstructor valid ;
+ std::string docstring ;
inline int nargs(){ return ctor->nargs() ; }
inline const char* signature(const std::string& class_name){
@@ -195,7 +197,7 @@
class SignedMethod {
public:
typedef CppMethod<Class> METHOD ;
- SignedMethod( METHOD* m, ValidMethod valid_, const char* doc ) : method(m), valid(valid_), docstring(doc) {}
+ SignedMethod( METHOD* m, ValidMethod valid_, const char* doc ) : method(m), valid(valid_), docstring(doc == 0 ? "" : doc) {}
METHOD* method ;
ValidMethod valid ;
@@ -216,6 +218,7 @@
field( "nargs" ) = m->nargs() ;
std::string sign( m->signature(class_name) ) ;
field( "signature" ) = sign ;
+ field( "docstring" ) = m->docstring ;
}
} ;
@@ -337,13 +340,13 @@
~class_(){}
- self& AddConstructor( constructor_class* ctor, ValidConstructor valid ){
- singleton->constructors.push_back( new signed_constructor_class( ctor, valid ) );
+ self& AddConstructor( constructor_class* ctor, ValidConstructor valid, const char* docstring = 0 ){
+ singleton->constructors.push_back( new signed_constructor_class( ctor, valid, docstring ) );
return *this ;
}
- self& default_constructor( ValidConstructor valid = &yes_arity<0> ){
- return constructor( valid ) ;
+ self& default_constructor( const char* docstring= 0, ValidConstructor valid = &yes_arity<0> ){
+ return constructor( docstring, valid ) ;
}
#include <Rcpp/module/Module_generated_class_constructor.h>
Modified: pkg/Rcpp/inst/include/Rcpp/module/Module_generated_class_constructor.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/module/Module_generated_class_constructor.h 2010-11-22 18:12:54 UTC (rev 2490)
+++ pkg/Rcpp/inst/include/Rcpp/module/Module_generated_class_constructor.h 2010-11-22 18:41:54 UTC (rev 2491)
@@ -30,8 +30,8 @@
typename U4,
typename U5
>
- self& constructor( ValidConstructor valid = &yes_arity<6> ){
- AddConstructor( new Constructor_6<Class,U0,U1,U2,U3,U4,U5> , valid ) ;
+ self& constructor( const char* docstring = 0, ValidConstructor valid = &yes_arity<6> ){
+ AddConstructor( new Constructor_6<Class,U0,U1,U2,U3,U4,U5> , valid, docstring ) ;
return *this ;
}
@@ -42,8 +42,8 @@
typename U3,
typename U4
>
- self& constructor( ValidConstructor valid = &yes_arity<5>){
- AddConstructor( new Constructor_5<Class,U0,U1,U2,U3,U4> , valid ) ;
+ self& constructor( const char* docstring = 0, ValidConstructor valid = &yes_arity<5>){
+ AddConstructor( new Constructor_5<Class,U0,U1,U2,U3,U4> , valid, docstring ) ;
return *this ;
}
@@ -53,8 +53,8 @@
typename U2,
typename U3
>
- self& constructor( ValidConstructor valid = &yes_arity<4>){
- AddConstructor( new Constructor_4<Class,U0,U1,U2,U3> , valid ) ;
+ self& constructor( const char* docstring="", ValidConstructor valid = &yes_arity<4>){
+ AddConstructor( new Constructor_4<Class,U0,U1,U2,U3> , valid, docstring ) ;
return *this ;
}
@@ -64,8 +64,8 @@
typename U1,
typename U2
>
- self& constructor( ValidConstructor valid = &yes_arity<3>){
- AddConstructor( new Constructor_3<Class,U0,U1,U2> , valid ) ;
+ self& constructor( const char* docstring="", ValidConstructor valid = &yes_arity<3>){
+ AddConstructor( new Constructor_3<Class,U0,U1,U2> , valid, docstring ) ;
return *this ;
}
@@ -73,21 +73,21 @@
typename U0,
typename U1
>
- self& constructor( ValidConstructor valid = &yes_arity<2>){
- AddConstructor( new Constructor_2<Class,U0,U1> , valid ) ;
+ self& constructor( const char* docstring="", ValidConstructor valid = &yes_arity<2>){
+ AddConstructor( new Constructor_2<Class,U0,U1> , valid, docstring ) ;
return *this ;
}
template <
typename U0
>
- self& constructor( ValidConstructor valid = &yes_arity<1>){
- AddConstructor( new Constructor_1<Class,U0> , valid ) ;
+ self& constructor( const char* docstring="", ValidConstructor valid = &yes_arity<1>){
+ AddConstructor( new Constructor_1<Class,U0> , valid, docstring ) ;
return *this ;
}
- self& constructor( ValidConstructor valid = &yes ){
- AddConstructor( new Constructor_0<Class>, valid ) ;
+ self& constructor( const char* docstring="", ValidConstructor valid = &yes ){
+ AddConstructor( new Constructor_0<Class>, valid , docstring) ;
return *this ;
}
More information about the Rcpp-commits
mailing list