[Rcpp-devel] nicer show method for C++Class
Romain Francois
romain at r-enthusiasts.com
Mon Nov 22 16:08:32 CET 2010
Hello,
I've modified the show method for C++Class so that it prints more
information:
require( Rcpp )
require( inline )
inc <- '
class Simple {
public:
Simple( ) : d_x(10.0){} ;
Simple( double x ) : d_x(x){} ;
const double& x(){ return d_x ;}
void move( double x ){ d_x += x ; }
private:
double d_x ;
} ;
double bla( Simple* data ){ return 3; }
RCPP_MODULE(mod){
class_<Simple>( "Simple" )
.constructor()
.constructor<double>( )
.property( "x" , &Simple::x )
.method( "move", &Simple::move, "some documentation for the move
method" )
.method( "bla", &bla, "bla bla" )
;
}
'
fx <- cxxfunction( , '', includes = inc, plugin = "Rcpp" )
mod <- Module( "mod", getDynLib( fx ) )
Simple <- mod$Simple
> show( Simple )
C++ class 'Simple' <0x1005278f0>
Fields:
double x [readonly]
Methods:
double bla()
docstring : bla bla
void move(double)
docstring : some documentation for the move method
Formatting advice are welcome.
Things to do:
- add a docstring to fields
- grab reflection (typenames of parameters) from constructors
- add docstring to constructors
- maybe pull out the const-ness of methods
Maybe later.
Romain
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9VOd3l : ZAT! 2010
|- http://bit.ly/c6DzuX : Impressionnism with R
`- http://bit.ly/czHPM7 : Rcpp Google tech talk on youtube
More information about the Rcpp-devel
mailing list