The best you can do is to get the pointer to the function (not sure if that does what you are hoping for):
func <- Rcpp::cppFunction("int foo() { return 1; }") > body(func) .Primitive(".Call")(<pointer: 0x103bf0f40>) On Fri, Jul 28, 2017 at 8:00 PM, Iñaki Úcar <i.uca...@gmail.com> wrote: > 2017-07-29 0:29 GMT+02:00 Dirk Eddelbuettel <e...@debian.org>: > > > > On 28 July 2017 at 19:14, Iñaki Úcar wrote: > > | Hi all, > > | > > | I found this interesting thread by Davor Cubranic in which Romain came > > | up with a solution for calling a C routine from the 'stats' package: > > | http://lists.r-forge.r-project.org/pipermail/rcpp- > devel/2010-June/000753.html > > | > > | In a nutshell, I would like to do the same, but with a user-provided > > | function compiled with Rcpp::cppfunction. Namely, > > | > > | 1) get the externalptr > > | 2) get the DL_FUNC with R_ExternalPtrAddrFn > > | 3) use it > > | > > | Thanks to Romain, 2) and 3) are straightforward. The problem is the > > | first step. I saw that, if I compile a function like this > > | > > | > Rcpp::cppFunction("int foo() { return 1; }") > > | > > | then I can obtain the externalptr with > > | > > | > getNativeSymbolInfo("sourceCpp_ID_foo") > > | > > | but the problem is that you have to figure out this ID. Is there a > > | general way to obtain the name of the native symbol that Rcpp > > | produces? (Also I suppose that the initial "sourceCpp_" part could > > | change in the future). > > > > I recall that clever trick. > > > > The problem is that R Core really does not want us to access such > unexported > > access points. > > R Core may or may not want us to do 2) and 3), AKA the tricky part. > But all I'm asking is how to get the externalptr from a cppFunction, > which is just another (*kinda*) valid R data type. ;) R core provides > getNativeSymbolInfo and Rcpp sets up the symbol name: it should be > easy for Rcpp to expose the externalptr (if it's not already the > case). > > Iñaki > _______________________________________________ > Rcpp-devel mailing list > Rcpp-devel@lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel >
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel