[Rcpp-devel] Rcpp Makevars COPYING policy?

Dirk Eddelbuettel edd at debian.org
Wed Oct 16 05:52:29 CEST 2013


On 15 October 2013 at 22:34, Jonathan Olmsted wrote:
| Dirk, If I just looked in the right spot of xts, I'd have seen the header trick
| on the "host package" spelled out in plain English. *sigh*

Well that is actually almost something else...  Anyway I found the examples
of xts exports (some of which I committed to xts) easiest for me to figure
out -- it is all at a plain C level and less involved than the lme4/Matrix
example.

Eg the following is from the xtsAPI.h header file in the xts package. We set
the file xtsAPI.h up to clearly delineate what is available for others in the
API -- here we define xtsNaOmit() by going to the C function na_omit_xts()
from package xts:


SEXP attribute_hidden xtsNaOmit(SEXP x) {
    static SEXP(*fun)(SEXP) = NULL;
    if (fun == NULL) 
        fun = (SEXP(*)(SEXP)) R_GetCCallable("xts","na_omit_xts");
    return fun(x);
}


In RcppXts, this is then accessed via an Rcpp Modules declaration

    function("xtsNaOmit",
             &xtsNaOmit,
             List::create(Named("x")),
             "Omit NA values");

which simply points to xtsNaOmit -- and that is all.  You do of course need
that type of handshake for every pair of exported and importing functions.
I access just about all core C functions from xts in RcppXts. (Still a pretty
raw package which needs more hand-holding -- but all this works now.)

Feel free to fill the lack of documentation with a nice Rcpp Gallery post :)

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list