Skip to content
Prev 5388 / 10988 Next

[Rcpp-devel] reference classes in C++ :is it possible?

Hello

First thanks Dirk for the quick reply and the hint; Mr.  John Chamber's
implementation is great! gone through the documentation and followed his
instructions. Worked well.  Only one way though -- as you pointed out.

I was able to get the fields from the extended class; if someone could
point into the direction how to get/execute methods of a Reference Class
then it may be doable??

 ..... c++ class ......
    void set_reference( SEXP xptr_){
        Rcpp::Reference ref(xptr_);
        ref.field("some_field"));   // get the field data

// -------  this is not implemented, any hints?  --------
        ref.method("some_method")( x, y);  // this would be nice to have
    }
...... end .......

setRcppClass("World",
    module="yada",
    fields = list( some_field = "character"),
    methods = list(
          initialize = function(){
                some_field <<- "field value set"
                callSuper()                # call constructor
                set_reference( .self ) # pass 'this'
          }
     ),saveAs="genWorld"
)
On Thu, Feb 28, 2013 at 8:15 AM, Dirk Eddelbuettel <edd at debian.org> wrote:

            
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130301/aa90e387/attachment.html>