[Rcpp-devel] New function for exposing C++ classes

2013-10-09 Thread John Chambers
The function exposeClass() has been added to Rcpp. The idea is to call it to create C++ and R files in a package source in order to export a C++ class, given basic information about the class. The function writes the Module source in C++ and a corresponding call to setRcppClass in R. Like com

Re: [Rcpp-devel] check validity of object created from Rcpp module

2012-06-27 Thread John Chambers
ns ptr. I can say from experience that this all gets rather complicated. However I haven't looked at John Chambers' new code for Rcpp classes in R and he might have addressed the issue. Well, no, and it doesn't seem particularly a modules issue, but rather a general point in u

Re: [Rcpp-devel] R classes extending C++ classes

2012-04-24 Thread John Chambers
The two limitations mentioned below, export patterns and loading warning from CMD check, should have been fixed in the current versions of r-devel and 2.15 patched. The "global variables" note remains, but it's been remarked often in other contexts as well. John On 4/20/1

[Rcpp-devel] R classes extending C++ classes

2012-04-20 Thread John Chambers
As of a recent version of Rcpp on r-forge (rev. 3582 or later), there is a new facility for defining an R class extending a C++ class extracted from a module. The main tool is setRcppClass in package Rcpp. See its documentation. Also in the unittests directory of package Rcpp is an example p

Re: [Rcpp-devel] Idiom for accessing scalars

2012-01-06 Thread John Chambers
At the risk of derailing this thread into the quicksand of programming style Except when required by the specific application, my preference would be to stay with the Rcpp idiom. Mixing in the older C API seems to risk more programming error. Of course, each application is different and

Re: [Rcpp-devel] idiom for determining the (S3) class of an R object?

2010-12-02 Thread John Chambers
Sorry, didn't see this before my last mail. Looks like a better solution. On 12/2/10 1:55 PM, Romain Francois wrote: Le 02/12/10 22:51, Romain Francois a écrit : Le 02/12/10 22:40, Douglas Bates a écrit : I currently use constructions like if (as(lst.attr("class")) != "family") throw std::ru

Re: [Rcpp-devel] idiom for determining the (S3) class of an R object?

2010-12-02 Thread John Chambers
There is a related routine in R_HOME/src/main/attrib.c: EXP R_data_class(SEXP obj, Rboolean singleString) { SEXP value, klass = getAttrib(obj, R_ClassSymbol); int n = length(klass); if(n == 1 || (n > 0 && !singleString)) return(klass); if(n == 0) { SEXP dim = getAttrib(obj

Re: [Rcpp-devel] Designing Rcpp modules - allow access to fields or to field accessor methods?

2010-11-19 Thread John Chambers
Romain's solution is almost certainly the way to go. Just for completeness, note that you can define a field on the R side to be an accessor function as well, using the standard mechanism for active bindings; i.e., an R function (anonymous if you want) that returns the field if called without

Re: [Rcpp-devel] Modules and default constructors

2010-11-19 Thread John Chambers
There was a problem in that creating a subclass in R of an Rcpp class attempts to call a default constructor. I have code that fixed the problem, by creating a suitable $initialize() method based on the existence or not of the default C++ constructor, but unfortunately I have yet to fully test

Re: [Rcpp-devel] Rcpp and reference classes in R-2.12.0 and later

2010-11-01 Thread John Chambers
On 11/1/10 12:28 PM, Douglas Bates wrote: I should probably ask this question on R-devel as it is not directly an Rcpp question but the thread started here so ... I'm confused about accessor functions as described in help("setRefClass") under the argument "fields". It states The e