Re: [Rcpp-devel] Creating pointers to objects and wrapping them

2011-04-21 Thread Romain Francois
Le 21/04/11 11:01, schattenpfla...@arcor.de a écrit : Now, for Rcpp classes to be aware of a custom wrap, you need some gymnatics, as described in the Rcpp-extending vignette. You need to include RcppCommon.h first, define you class and declare the custom wrap, then include Rcpp.h, then define yo

Re: [Rcpp-devel] Creating pointers to objects and wrapping them

2011-04-21 Thread schattenpflanze
Now, for Rcpp classes to be aware of a custom wrap, you need some gymnatics, as described in the Rcpp-extending vignette. You need to include RcppCommon.h first, define you class and declare the custom wrap, then include Rcpp.h, then define you wrap. I'm pasting a full pass at it below. Thanks a

Re: [Rcpp-devel] Creating pointers to objects and wrapping them

2011-04-21 Thread Romain Francois
Hello, The approach here is to use a callback to the new function of R, to mimic the call : b <- new( B, 0L ) which you can do for example using the Language class: namespace Rcpp { template <> SEXP wrap( const B& object ){ Language call( "new", Symbol( "B" ), object.get_i()

Re: [Rcpp-devel] Creating pointers to objects and wrapping them

2011-04-18 Thread schattenpflanze
The way you try to implement it would require the class B to be wrappable. You can have a look at the Rcpp-extending vignette for how to enable wrap for custom classes. The vignette states that I should specialize the wrap template or implement the operator SEXP() for my class B. Unfortunately, i

Re: [Rcpp-devel] Creating pointers to objects and wrapping them

2011-04-18 Thread Romain Francois
Le 18/04/11 10:04, schattenpfla...@arcor.de a écrit : Dirk, Could you mock up a small example? Here is a small, abstract example which demonstrates one of the scenarios where I would like to create and return object pointers. There are two classes, A and B. Instances of A contain pointers to i

Re: [Rcpp-devel] Creating pointers to objects and wrapping them

2011-04-18 Thread schattenpflanze
Dirk, Could you mock up a small example? Here is a small, abstract example which demonstrates one of the scenarios where I would like to create and return object pointers. There are two classes, A and B. Instances of A contain pointers to instances of B. I would like to create the B objects p

Re: [Rcpp-devel] Creating pointers to objects and wrapping them

2011-04-17 Thread Dirk Eddelbuettel
Peter, On 17 April 2011 at 10:45, schattenpfla...@arcor.de wrote: | Hello, | | I have made progress exposing my C++ classes to R with Rcpp-Modules and | I really like the way it works. Thanks for this great package! | | There are, however, lots of aspects about Rcpp which I do not yet fully |

[Rcpp-devel] Creating pointers to objects and wrapping them

2011-04-17 Thread schattenpflanze
Hello, I have made progress exposing my C++ classes to R with Rcpp-Modules and I really like the way it works. Thanks for this great package! There are, however, lots of aspects about Rcpp which I do not yet fully understand. Here is one of them: I have exposed a C++ class MyClass to R via an