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

Romain Francois romain at r-enthusiasts.com
Wed Sep 10 15:44:20 CEST 2014


Le 10 sept. 2014 à 14:22, Gregory Jefferis <jefferis at mrc-lmb.cam.ac.uk> a écrit :

> 
> 
> Gregory Jefferis
> 
> On 10 Sep 2014, at 10:39, Romain Francois <romain at r-enthusiasts.com> wrote:
> 
>> RCPP_EXPOSED_CLASS(A)
>> 
>> before you declare class A and simply use this signature for the method. 
>> 
>> void DoSomethingWithInstanceOfA(const A& )
> 
> 
> I used this approach happily in the nabor package (on github) but the only caveat is that from R you need to call with something like:
> 
> A$method(B$.CppObject)
> 
> You can get some interesting crashes if you pass the R reference class (i.e. B) directly as the argument. I guess it might be better to have a derived R class that looks after extracting the .CppObject field. 
> 
> Best,
> 
> Greg.

That looks like a bug. Please submit it here: https://github.com/RcppCore/Rcpp/issues



More information about the Rcpp-devel mailing list