Skip to content

[Rcpp-devel] Pass an Rcpp module object to a method belonging to another module from R?

1 message · Christian Gunning

#
As an addendum to others' comments...

I've been working on a kinda-sorta similar problem: passing
user-supplied C++ worker functions to a module's method.  Not sure if
it helps, but it's a full example of passing XPtrs from C++ to R back
to a module's method, where it's called in C++:
https://code.google.com/p/unm-r-programming/source/browse/#git%2FRaggedArray

* In ./src/helpers.cpp, sapply_master(infun, cppfun=true) takes an R
function infun that returns an XPtr to a function that does something.
sapply_master pulls the XPtr, dereferences it to the C++ function, and
calls that function on a class member.
* In ./inst/tests/userFun.cpp are the user-specified worker functions,
and the associated XPtr-exporting wrapper functions that are passed to
sapply_master().

Incidentally, my plan is for this to be a gallery post in the not too
distant future.
-Christian