[Rcpp-devel] package .onLoad multiple modules

Romain Francois romain at r-enthusiasts.com
Tue May 31 10:19:35 CEST 2011


Hello,

I just added (rev 3043) a "direct" argument to loadRcppModules.
When TRUE (the default) it exposes the contents of the module
When FALSE it does what you want.

Romain

Le 29/05/11 08:56, baptiste auguie a écrit :
> Dear list,
>
> [Disclaimer: I am not very familiar with Rcpp/C++, and probably
> haven't followed all the relevant discussions on this list.]
>
> I'm trying to tidy up two packages on r-forge [*] before submitting
> them to CRAN. In "cda/zzz.r", I have the following code,
>
> NAMESPACE<- environment()
> cda<- new( "Module" )
> cdatests<- new( "Module" )
> cd<- new( "Module" )
> linear<- new( "Module" )
> array<- new( "Module" )
>
> .onLoad<- function(libname, pkgname){
>    unlockBinding( "cda" , NAMESPACE )
>    unlockBinding( "cdatests" , NAMESPACE )
>    unlockBinding( "cd" , NAMESPACE )
>    unlockBinding( "linear" , NAMESPACE )
>    assign( "cda", Module( "cda" ), NAMESPACE )
>    assign( "cdatests", Module( "cdatests" ), NAMESPACE )
>    assign( "cd", Module( "cd" ), NAMESPACE )
>    assign( "linear", Module( "linear" ), NAMESPACE )
>    lockBinding( "cda", NAMESPACE )
>    lockBinding( "cdatests", NAMESPACE )
>    lockBinding( "cd", NAMESPACE )
>    lockBinding( "linear", NAMESPACE )
>
>    unlockBinding( "array" , NAMESPACE )
>    assign( "array", Module( "array" ), NAMESPACE )
>    lockBinding( "array", NAMESPACE )
>
> }
>
> It seems to work, but is there something I can/should do to make this
> a wee cleaner?
>
> Thanks!
>
> baptiste
>
> [*]: https://r-forge.r-project.org/scm/viewvc.php/pkg/cda/?root=photonics
> https://r-forge.r-project.org/scm/viewvc.php/pkg/planar/?root=photonics
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
>


-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
http://romain-francois.com
|- http://bit.ly/hdKhCy : Rcpp article in JSS
|- http://bit.ly/elZJRJ : Montpellier Comedie Club - Avril 2011
`- http://bit.ly/fhqbRC : Rcpp workshop in Chicago on April 28th




More information about the Rcpp-devel mailing list