Hello,
I commited some code that allows one to declare formal argument
specification for an exposed C++ function. Here is an example:
require( inline )
require( Rcpp )
fx <- cxxfunction(, "", includes =
'using namespace Rcpp ;
double norm( double x, double y ){
return sqrt( x*x + y*y ) ;
}
RCPP_MODULE(mod){
function( "norm", &norm, List::create( _["x"] = 0.0, _["y"] = 0.0
), "bla bla nla" ) ;
}
', plugin = "Rcpp" )
mod <- Module( "mod", getDynLib(fx) )
norm <- mod$norm
> norm()
[1] 0
> norm( x = 3, y = 4 )
[1] 5
It is also possible to set a formal argument with no default value:
function( "norm", &norm, List::create( _["x"] = 0.0, _["y"] =
R_MissingArg ), "bla bla nla" ) ;
or even to use the ...
function( "norm", &norm, List::create( _["x"] = 0.0, _["..."] =
R_MissingArg ), "bla bla nla" ) ;
Romain