[Rcpp-devel] How to create a new plugin?

Romain Francois romain at r-enthusiasts.com
Sat Dec 18 10:08:20 CET 2010


Le 18/12/10 00:02, Dominick Samperi a écrit :
> On Fri, Dec 17, 2010 at 12:37 PM, Romain Francois
> <romain at r-enthusiasts.com <mailto:romain at r-enthusiasts.com>> wrote:
>
>     Le 17/12/10 01:28, Dominick Samperi a écrit :
>
>         Hello,
>
>         I managed to create a new plugin by copy/paste/adapt
>         Rcpp.plugin.maker. Is there a better way?
>
>         Thanks,
>         Dominick
>
>
>     Rcpp.plugin.maker is a sort of undocumented function we use for
>     packages we write, just to avoid copy and paste.
>
>     See how packages RcppArmadillo and RcppGSL use it.
>
>
> Thanks Romain, that was a good tip. Now my adaptation has been reduced
> to the following:
>
> inlineCxxPlugin <- Rcpp:::Rcpp.plugin.maker(
>           include.before = "#include <cxxPack.hpp>",
>           libs = cxxPack:::LdFlags(),
>           package = "cxxPack"
> )
>
> The only loose end is that sometimes I get a warning like this after
> the unit testing completes for the first time (no warning if the unit
> test is run again):
>
> Warning messages:
> 1: In file(con, "r") :
>    file("") only supports open = "w+" and open = "w+b": using the former
> 2: In file(con, "r") :
>    file("") only supports open = "w+" and open = "w+b": using the former
>
> I suspect this has something to do with how the Makefiles are opened.

By default, Rcpp.plugin.maker looks for a Makevars and Makevars.win in 
the skeleton directory of your package. See again how RcppArmadillo does 
it.

These are only used when you want to convert your inline function to a 
package with package.skeleton, so if you only care about making an 
inline function, you can do Makevars = NULL, Makevars.win = NULL

> BTW, it might be safer to leave it up to the test C++ code (assigned to
> src) to optionally use 'using namespace whatever' instead of doing this
> automatically, for the reasons Doug mentioned earlier.

Feel free to write a safeRcpp plugin and use registerPlugin to register 
it with registerPlugin

> Thanks,
> Dominick
>
>
>     Whether there is something better than what you have done is hard to
>     tell since you are very sparse on details adn you did not show what
>     ypu mean by copy/paste/adapt.
>
>     Romain

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/fT2rZM : highlight 0.2-5
|- http://bit.ly/gpCSpH : Evolution of Rcpp code size
`- http://bit.ly/hovakS : RcppGSL initial release




More information about the Rcpp-devel mailing list