[Rcpp-devel] Preferred way to create an instance of a C++ class exported in a module?
On Tue, Nov 30, 2010 at 10:31 AM, <romain at r-enthusiasts.com> wrote:
I'd say up to you. I prefer the new( Class , ?... ) construct. Also, with Rcpp 0.8.9 with populate, you dont need to use the $ so much. You can, in your .onLoad call populate once and then just use the class. See the Rcpp-modules vignette.
Is there a PDF of a recent version of the Rcpp-modules vignette online somewhere? I get a segfault when trying to build it during the package build process (svn revision 2624) cp -f Rcpp-modules/Rcpp-modules.Rnw . Rscript --vanilla -e "require(highlight); driver <- HighlightWeaveLatex(boxes = TRUE, bg = 'white' ); Sweave( 'Rcpp-modules.Rnw', driver = driver ); " WARNING: ignoring environment value of R_HOME Loading required package: highlight Loading required package: tools Loading required package: codetools Loading required package: parser Loading required package: Rcpp *** caught segfault *** address 0x2b43e97181d0, cause 'invalid permissions' Traceback: 1: .Call(Module__get_function, pointer, name) 2: .get_Module_function(module, fun, xp) 3: Module(module, mustStart = TRUE) 4: .getModulePointer(x) 5: module$set_data_path 6: module$set_data_path 7: fun(...) 8: doTryCatch(return(expr), name, parentenv, handler) ...
Romain Le 30 nov. 2010 ? 05:21 PM, Douglas Bates <bates at stat.wisc.edu> a ?crit :
I have seen a couple of ways of creating an instance of a C++ class
exported in a module
mod <- Module("myMod", "myPackage")
cls <- mod$myClass
inst <- cls$new(constructorArgs)
and
inst <- new(mod$myClass, constructorArgs)
Is one of these the preferred way?
_______________________________________________ Rcpp-devel mailing list Rcpp-devel at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel