Skip to content

[Rcpp-devel] [Rd] R inline package

5 messages · Troy Robertson, Dirk Eddelbuettel

#
At Dirks suggestion I have moved my question here to rcpp-devel
On 19/03/2012 9:54 AM, Dirk Eddelbuettel wrote:
I realise this #include is not required.  I was just using it to 
demonstrate my problem.
The same issue occurs if I drop the Rcpp.h include and replace it with 
an include for my library only.
Yes, I would like to create S4 methods using the setCMethod function if 
possible.
Has anyone else had success with this function and the use of includes?
I have an R package (EPOC - Ecological modelling system) which allows 
users to create and add R code methods to extend the
functionality of existing S4 classes in a plug-and-play sort of way.  
This is all good.

I have now included C++ source in my package which builds to a shared 
library.  All fine, I can dyn.load my library and make
.Call(s) on it.

My aim is to now allow users of my package to create additional methods 
which contain inline C++ code which is able to take
advantage of the packages shared library.  This is where I am stuck.  
The striped back example above demonstrates the problem
without getting into the complexities of my modelling package or it's 
shared library.

Dirk, are you saying that inline should really only be used for testing 
or is my dynamic creation of setCMethod calls fit within
that definition?
Is anyone able to replicate the issue above or is it something wierd 
with my setup?

Thanks,
  Troy
#
On 19/03/2012 12:50 PM, Troy Robertson wrote:
Okay, after having a look at the source for the inline package, I see 
that ... arguments to setCMethod()
are not passed on in its internal call to cfunction(), hence my cppargs 
and libargs (and indeed Rcpp=TRUE)
are ignored?

Troy
1 day later
#
On 19 March 2012 at 14:32, Troy Robertson wrote:
| Okay, after having a look at the source for the inline package, I see 
| that ... arguments to setCMethod()
| are not passed on in its internal call to cfunction(), hence my cppargs 
| and libargs (and indeed Rcpp=TRUE)
| are ignored?

As I said before, we extended the inline package with cxxfunction() for use
with Rcpp et al, and essentially only use cxxfunction.

As for S4 methods, there are some example tucked away in the unittests you
could look at.  

For the rest, I am not entirely clear as to what it is you want to do.  Maybe
Rcpp modules could help you, though it is closer to Reference Classes than to
S4 classes.

Hoep this helps,  Dirk
#
Hi Dirk,

It's okay.  I just created my own copy of the setCMethod and added the 
missing ellipses to it's call to cfunction() and it works fine.
It now passes on the Rcpp=TRUE and the cppargs and libargs and finds 
both the Rcpp and my own library.

Troy
On 21/03/2012 12:19 AM, Dirk Eddelbuettel wrote:
#
Hi Troy,

Glad to hear you're covered.
On 21 March 2012 at 07:45, Troy Robertson wrote:
| Hi Dirk,
| 
| It's okay.  I just created my own copy of the setCMethod and added the 
| missing ellipses to it's call to cfunction() and it works fine.
| It now passes on the Rcpp=TRUE and the cppargs and libargs and finds 
| both the Rcpp and my own library.

That's how we started too, prior to cxxfunction().

I am wondering if I could interest you in looking at the cxxfunction code
maybe thinking about extending to whichever form it takes to let you create
S4 methods that way. Any interest?

Cheers, Dirk

| 
| Troy
|
| On 21/03/2012 12:19 AM, Dirk Eddelbuettel wrote:
| > On 19 March 2012 at 14:32, Troy Robertson wrote:
| > | Okay, after having a look at the source for the inline package, I see
| > | that ... arguments to setCMethod()
| > | are not passed on in its internal call to cfunction(), hence my cppargs
| > | and libargs (and indeed Rcpp=TRUE)
| > | are ignored?
| >
| > As I said before, we extended the inline package with cxxfunction() for use
| > with Rcpp et al, and essentially only use cxxfunction.
| >
| > As for S4 methods, there are some example tucked away in the unittests you
| > could look at.
| >
| > For the rest, I am not entirely clear as to what it is you want to do.  Maybe
| > Rcpp modules could help you, though it is closer to Reference Classes than to
| > S4 classes.
| >
| > Hoep this helps,  Dirk
| >