I've also updated the skeleton generator so that loadRcppModules is used
by the the package that is generated.
However, it should be noted that things are directly exported into the
namespace, where before only the module was exported.
So when you do:
> Rcpp.package.skeleton( "testmod", module = TRUE )
> require( testmod )
> foo()
> w <- new( World )
> w$greet()
> w$set( "bonjour")
> w$greet()
[1] "bonjour"
you can use functions (e.g. foo) or classes (e.g. World ) directly.
Hope this is useful.
Romain
Le 11/04/11 11:41, Romain Francois a ?crit :
Hello,
I've added an experimental feature to Rcpp minutes ago.
This is to simplify (yet again) dealing with modules. Now, when one
wants to use C++ functions and classes that are declared in a module,
the only things you have to do are:
* declare them in the "RcppModules" field of DESCRIPTION file, for
example (taken from the testRcppModule package, part of Rcpp's testing
universe):
Package: testRcppModule
Type: Package
Title: Some test examples using Rcpp with the Module feature
Version: 0.1
Date: 2010-09-06
Author: JMC
Maintainer: <jmc at stat.stanford.edu>
Description: Some examples taken (and perhaps modified) from the Rcpp
Modules documentation.
License: GPL(>=2)
LazyLoad: yes
Depends: methods, Rcpp (>= 0.8.5)
LinkingTo: Rcpp
RcppModules: yada, stdVector, NumEx
Packaged: 2010-09-09 18:42:28 UTC; jmc
The relevant line being:
RcppModules: yada, stdVector, NumEx
* load them. We used to have to load them individually by calling Module
and maybe populate. Now, this is simpler. You just need a .onLoad
function that looks like this:
.onLoad <- function(libname, pkgname){
loadRcppModules()
}
This will load the declared modules, and populate them into your
package's namespace.
I will update the Rcpp-modules vignette accordingly.
Suggestions, comments, improvements, "what are you ? nuts !", ... are
always welcome.
Romain