[Rcpp-devel] Preferred way to create an instance of a C++ class exported in a module?
romain at r-enthusiasts.com
romain at r-enthusiasts.com
Tue Nov 30 18:05:52 CET 2010
Le 30 nov. 2010 à 06:01 PM, Douglas Bates <bates at stat.wisc.edu> a écrit :
> 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?
On cran, or off dirk's rcpp page.
> I get a segfault when trying to build it during the
> package build process (svn revision 2624)
That's because you need to reinstall highlight. There has been lots if binary changes in the module code, so code compiled against an older rcpp might break.
> 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
>>
More information about the Rcpp-devel
mailing list