[Rcpp-commits] r2492 - 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 20:20:37 CET 2010
Author: romain
Date: 2010-11-22 20:20:37 +0100 (Mon, 22 Nov 2010)
New Revision: 2492
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_Add_Property.h
pkg/Rcpp/inst/include/Rcpp/module/Module_Field.h
pkg/Rcpp/inst/include/Rcpp/module/Module_Property.h
Log:
docstring for the fields
Modified: pkg/Rcpp/R/00_classes.R
===================================================================
--- pkg/Rcpp/R/00_classes.R 2010-11-22 18:41:54 UTC (rev 2491)
+++ pkg/Rcpp/R/00_classes.R 2010-11-22 19:20:37 UTC (rev 2492)
@@ -29,7 +29,8 @@
pointer = "externalptr",
cpp_class = "character",
read_only = "logical",
- class_pointer = "externalptr"
+ class_pointer = "externalptr",
+ docstring = "character"
)
)
Modified: pkg/Rcpp/R/01_show.R
===================================================================
--- pkg/Rcpp/R/01_show.R 2010-11-22 18:41:54 UTC (rev 2491)
+++ pkg/Rcpp/R/01_show.R 2010-11-22 19:20:37 UTC (rev 2492)
@@ -57,10 +57,12 @@
txt <- character(nfields)
for( i in seq_len(nfields) ){
f <- fields[[i]]
- txt[i] <- sprintf( " %s %s%s",
+ doc <- f$docstring
+ txt[i] <- sprintf( " %s %s%s%s",
f$cpp_class,
names[i],
- if( f$read_only ) " [readonly]" else ""
+ if( f$read_only ) " [readonly]" else "",
+ if( nchar(doc) ) sprintf( "\n docstring : %s", doc ) else ""
)
}
writeLines( paste( txt, collapse = "\n" ) )
Modified: pkg/Rcpp/inst/include/Rcpp/Module.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Module.h 2010-11-22 18:41:54 UTC (rev 2491)
+++ pkg/Rcpp/inst/include/Rcpp/Module.h 2010-11-22 19:20:37 UTC (rev 2492)
@@ -260,11 +260,13 @@
public:
typedef Rcpp::XPtr<Class> XP ;
- CppProperty(){} ;
+ CppProperty(const char* doc = 0) : docstring( doc == 0 ? "" : doc ) {} ;
virtual SEXP get(Class* ) throw(std::range_error){ throw std::range_error("cannot retrieve property"); }
virtual void set(Class*, SEXP) throw(std::range_error,Rcpp::not_compatible){ throw std::range_error("cannot set property"); }
virtual bool is_readonly(){ return false; }
virtual std::string get_class(){ return ""; }
+
+ std::string docstring ;
} ;
template <typename Class>
@@ -296,6 +298,7 @@
field( "cpp_class" ) = p->get_class();
field( "pointer" ) = Rcpp::XPtr< CppProperty<Class> >( p, false ) ;
field( "class_pointer" ) = class_xp ;
+ field( "docstring" ) = p->docstring ;
}
} ;
Modified: pkg/Rcpp/inst/include/Rcpp/module/Module_Add_Property.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/module/Module_Add_Property.h 2010-11-22 18:41:54 UTC (rev 2491)
+++ pkg/Rcpp/inst/include/Rcpp/module/Module_Add_Property.h 2010-11-22 19:20:37 UTC (rev 2492)
@@ -23,73 +23,73 @@
#define Rcpp_Module_Add_Property_h
template <typename PROP>
- self& property( const char* name_, PROP (Class::*GetMethod)(void) ){
- AddProperty( name_, new CppProperty_GetMethod<Class,PROP>(GetMethod) ) ;
+ self& property( const char* name_, PROP (Class::*GetMethod)(void), const char* docstring = 0){
+ AddProperty( name_, new CppProperty_GetMethod<Class,PROP>(GetMethod, docstring) ) ;
return *this ;
}
template <typename PROP>
- self& property( const char* name_, PROP (Class::*GetMethod)(void) const ){
- AddProperty( name_, new CppProperty_GetConstMethod<Class,PROP>(GetMethod) ) ;
+ self& property( const char* name_, PROP (Class::*GetMethod)(void) const, const char* docstring = 0){
+ AddProperty( name_, new CppProperty_GetConstMethod<Class,PROP>(GetMethod, docstring) ) ;
return *this ;
}
template <typename PROP>
- self& property( const char* name_, PROP (*GetMethod)(Class*) ){
- AddProperty( name_, new CppProperty_GetPointerMethod<Class,PROP>(GetMethod) ) ;
+ self& property( const char* name_, PROP (*GetMethod)(Class*), const char* docstring ){
+ AddProperty( name_, new CppProperty_GetPointerMethod<Class,PROP>(GetMethod,docstring) ) ;
return *this ;
}
template <typename PROP>
- self& property( const char* name_, PROP (Class::*GetMethod)(void), void (Class::*SetMethod)(PROP) ){
+ self& property( const char* name_, PROP (Class::*GetMethod)(void), void (Class::*SetMethod)(PROP), const char* docstring = 0){
AddProperty(
name_,
- new CppProperty_GetMethod_SetMethod<Class,PROP>(GetMethod, SetMethod)
+ new CppProperty_GetMethod_SetMethod<Class,PROP>(GetMethod, SetMethod, docstring)
) ;
return *this ;
}
template <typename PROP>
- self& property( const char* name_, PROP (Class::*GetMethod)(void) const, void (Class::*SetMethod)(PROP) ){
+ self& property( const char* name_, PROP (Class::*GetMethod)(void) const, void (Class::*SetMethod)(PROP), const char* docstring = 0){
AddProperty(
name_,
- new CppProperty_GetConstMethod_SetMethod<Class,PROP>(GetMethod, SetMethod)
+ new CppProperty_GetConstMethod_SetMethod<Class,PROP>(GetMethod, SetMethod, docstring)
) ;
return *this ;
}
template <typename PROP>
- self& property( const char* name_, PROP (Class::*GetMethod)(void), void (*SetMethod)(Class*,PROP) ){
+ self& property( const char* name_, PROP (Class::*GetMethod)(void), void (*SetMethod)(Class*,PROP), const char* docstring = 0 ){
AddProperty(
name_,
- new CppProperty_GetMethod_SetPointer<Class,PROP>(GetMethod, SetMethod)
+ new CppProperty_GetMethod_SetPointer<Class,PROP>(GetMethod, SetMethod, docstring )
) ;
return *this ;
}
template <typename PROP>
- self& property( const char* name_, PROP (Class::*GetMethod)(void) const , void (*SetMethod)(Class*,PROP) ){
+ self& property( const char* name_, PROP (Class::*GetMethod)(void) const , void (*SetMethod)(Class*,PROP), const char* docstring = 0 ){
AddProperty(
name_,
- new CppProperty_GetConstMethod_SetPointer<Class,PROP>(GetMethod, SetMethod)
+ new CppProperty_GetConstMethod_SetPointer<Class,PROP>(GetMethod, SetMethod, docstring)
) ;
return *this ;
}
template <typename PROP>
- self& property( const char* name_, PROP (*GetMethod)(Class*), void (Class::*SetMethod)(PROP) ){
+ self& property( const char* name_, PROP (*GetMethod)(Class*), void (Class::*SetMethod)(PROP), const char* docstring = 0 ){
AddProperty(
name_,
- new CppProperty_GetPointer_SetMethod<Class,PROP>(GetMethod, SetMethod)
+ new CppProperty_GetPointer_SetMethod<Class,PROP>(GetMethod, SetMethod, docstring)
) ;
}
template <typename PROP>
- self& property( const char* name_, PROP (*GetMethod)(Class*), void (*SetMethod)(Class*,PROP) ){
+ self& property( const char* name_, PROP (*GetMethod)(Class*), void (*SetMethod)(Class*,PROP), const char* docstring = 0 ){
AddProperty(
name_,
- new CppProperty_GetPointer_SetPointer<Class,PROP>(GetMethod, SetMethod)
+ new CppProperty_GetPointer_SetPointer<Class,PROP>(GetMethod, SetMethod, docstring)
) ;
return *this ;
}
Modified: pkg/Rcpp/inst/include/Rcpp/module/Module_Field.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/module/Module_Field.h 2010-11-22 18:41:54 UTC (rev 2491)
+++ pkg/Rcpp/inst/include/Rcpp/module/Module_Field.h 2010-11-22 19:20:37 UTC (rev 2492)
@@ -27,8 +27,10 @@
class CppProperty_Getter_Setter : public CppProperty<Class> {
public:
typedef PROP Class::*pointer ;
+ typedef CppProperty<Class> prop_class ;
- CppProperty_Getter_Setter( pointer ptr_ ) : ptr(ptr_), class_name(DEMANGLE(PROP)) {}
+ CppProperty_Getter_Setter( pointer ptr_ , const char* doc) :
+ prop_class(doc), ptr(ptr_), class_name(DEMANGLE(PROP)) {}
SEXP get(Class* object) throw(std::range_error){ return Rcpp::wrap( object->*ptr ) ; }
void set(Class* object, SEXP value) throw(std::range_error,Rcpp::not_compatible){ object->*ptr = Rcpp::as<PROP>( value ) ; }
@@ -46,8 +48,10 @@
class CppProperty_Getter : public CppProperty<Class> {
public:
typedef PROP Class::*pointer ;
+ typedef CppProperty<Class> prop_class ;
- CppProperty_Getter( pointer ptr_ ) : ptr(ptr_), class_name(DEMANGLE(PROP)) {}
+ CppProperty_Getter( pointer ptr_, const char* doc = 0 ) :
+ prop_class(doc), ptr(ptr_), class_name(DEMANGLE(PROP)) {}
SEXP get(Class* object) throw(std::range_error){ return Rcpp::wrap( object->*ptr ) ; }
void set(Class* object, SEXP value) throw(std::range_error,Rcpp::not_compatible){ throw std::range_error("read only data member") ; }
@@ -61,17 +65,17 @@
template <typename T>
- self& field( const char* name_, T Class::*ptr ){
+ self& field( const char* name_, T Class::*ptr, const char* docstring = 0){
AddProperty( name_,
- new CppProperty_Getter_Setter<T>( ptr )
+ new CppProperty_Getter_Setter<T>( ptr, docstring )
) ;
return *this ;
}
template <typename T>
- self& field_readonly( const char* name_, T Class::*ptr ){
+ self& field_readonly( const char* name_, T Class::*ptr, const char* docstring = 0 ){
AddProperty( name_,
- new CppProperty_Getter<T>( ptr )
+ new CppProperty_Getter<T>( ptr, docstring )
) ;
return *this ;
}
Modified: pkg/Rcpp/inst/include/Rcpp/module/Module_Property.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/module/Module_Property.h 2010-11-22 18:41:54 UTC (rev 2491)
+++ pkg/Rcpp/inst/include/Rcpp/module/Module_Property.h 2010-11-22 19:20:37 UTC (rev 2492)
@@ -29,7 +29,8 @@
typedef PROP (Class::*GetMethod)(void) ;
typedef CppProperty<Class> prop_class ;
- CppProperty_GetMethod( GetMethod getter_ ) : getter(getter_), class_name(DEMANGLE(PROP)){}
+ CppProperty_GetMethod( GetMethod getter_, const char* doc = 0 ) :
+ prop_class(doc), getter(getter_), class_name(DEMANGLE(PROP)){}
SEXP get(Class* object) throw(std::range_error){ return Rcpp::wrap( (object->*getter)() ) ; }
void set(Class*, SEXP) throw(std::range_error,Rcpp::not_compatible){ throw std::range_error("property is read only") ; }
@@ -49,7 +50,8 @@
typedef PROP (Class::*GetMethod)(void) const ;
typedef CppProperty<Class> prop_class ;
- CppProperty_GetConstMethod( GetMethod getter_ ) : getter(getter_), class_name(DEMANGLE(PROP)){}
+ CppProperty_GetConstMethod( GetMethod getter_ , const char* doc = 0) :
+ prop_class(doc), getter(getter_), class_name(DEMANGLE(PROP)){}
SEXP get(Class* object) throw(std::range_error){ return Rcpp::wrap( (object->*getter)() ) ; }
void set(Class*, SEXP) throw(std::range_error,Rcpp::not_compatible){ throw std::range_error("property is read only") ; }
@@ -70,7 +72,8 @@
typedef PROP (*GetMethod)(Class*) ;
typedef CppProperty<Class> prop_class ;
- CppProperty_GetPointerMethod( GetMethod getter_ ) : getter(getter_), class_name(DEMANGLE(PROP)){}
+ CppProperty_GetPointerMethod( GetMethod getter_ , const char* doc = 0) :
+ prop_class(doc), getter(getter_), class_name(DEMANGLE(PROP)){}
SEXP get(Class* object) throw(std::range_error){ return Rcpp::wrap( getter(object) ) ; }
void set(Class*, SEXP) throw(std::range_error,Rcpp::not_compatible){ throw std::range_error("property is read only") ; }
@@ -91,7 +94,8 @@
typedef void (Class::*SetMethod)(PROP) ;
typedef CppProperty<Class> prop_class ;
- CppProperty_GetMethod_SetMethod( GetMethod getter_, SetMethod setter_) : getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
+ CppProperty_GetMethod_SetMethod( GetMethod getter_, SetMethod setter_, const char* doc = 0) :
+ prop_class(doc), getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
SEXP get(Class* object) throw(std::range_error){
return Rcpp::wrap( (object->*getter)() ) ;
@@ -116,7 +120,8 @@
typedef void (Class::*SetMethod)(PROP) ;
typedef CppProperty<Class> prop_class ;
- CppProperty_GetConstMethod_SetMethod( GetMethod getter_, SetMethod setter_) : getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
+ CppProperty_GetConstMethod_SetMethod( GetMethod getter_, SetMethod setter_, const char* doc = 0) :
+ prop_class(doc), getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
SEXP get(Class* object) throw(std::range_error){
return Rcpp::wrap( (object->*getter)() ) ;
@@ -147,7 +152,8 @@
typedef void (*SetMethod)(Class*,PROP) ;
typedef CppProperty<Class> prop_class ;
- CppProperty_GetMethod_SetPointer( GetMethod getter_, SetMethod setter_) : getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
+ CppProperty_GetMethod_SetPointer( GetMethod getter_, SetMethod setter_, const char* doc = 0) :
+ prop_class(doc), getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
SEXP get(Class* object) throw(std::range_error){
return Rcpp::wrap( (object->*getter)() ) ;
@@ -173,7 +179,8 @@
typedef void (*SetMethod)(Class*,PROP) ;
typedef CppProperty<Class> prop_class ;
- CppProperty_GetConstMethod_SetPointer( GetMethod getter_, SetMethod setter_) : getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
+ CppProperty_GetConstMethod_SetPointer( GetMethod getter_, SetMethod setter_, const char* doc = 0) :
+ prop_class(doc), getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
SEXP get(Class* object) throw(std::range_error){
return Rcpp::wrap( (object->*getter)() ) ;
@@ -201,7 +208,8 @@
typedef void (Class::*SetMethod)(PROP) ;
typedef CppProperty<Class> prop_class ;
- CppProperty_GetPointer_SetMethod( GetMethod getter_, SetMethod setter_) : getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
+ CppProperty_GetPointer_SetMethod( GetMethod getter_, SetMethod setter_, const char* doc = 0) :
+ prop_class(doc), getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
SEXP get(Class* object) throw(std::range_error){
return Rcpp::wrap( getter(object) ) ;
@@ -230,7 +238,8 @@
typedef void (*SetMethod)(Class*,PROP) ;
typedef CppProperty<Class> prop_class ;
- CppProperty_GetPointer_SetPointer( GetMethod getter_, SetMethod setter_) : getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
+ CppProperty_GetPointer_SetPointer( GetMethod getter_, SetMethod setter_, const char* doc = 0) :
+ prop_class(doc), getter(getter_), setter(setter_), class_name(DEMANGLE(PROP)){}
SEXP get(Class* object) throw(std::range_error){
return Rcpp::wrap( getter(object) ) ;
More information about the Rcpp-commits
mailing list