Le 09/06/10 03:04, Davor Cubranic a écrit :

Hi there,

I have a question about the murky world of R internals, DLLs, and their 
interaction with Rcpp.

There are some C routines in the 'stats' package that I would like to call 
directly from my Rcpp-based package, e.g., loess_raw. However, 'stats' only 
exposes them to R callers, not C or C++. (I.e., it does not use 
R_RegisterCCallable, but they are among R_CMethodDef's passed in 
R_registerRoutines.)

Reading the information on writing R extensions, it sounds like there may not 
be a way to get to the address of an object in another package's DLL. (In this 
case, in stats.so.) However, there is a NativeSymbolInfo for 
stats:::R_loess_raw, which includes all sorts of info about the C method. Is 
there a way that this can be used to get a function pointer to it from within 
my code? And if this is too unportable, is there a cleaner way?

Thanks,

Davor

Hi,

I see

> getNativeSymbolInfo( "loess_raw" )
$name
[1] "loess_raw"

$address
<pointer: 0x103092820>
attr(,"class")
[1] "NativeSymbol"

$package
DLL name: stats
Filename:

/Library/Frameworks/R.framework/Resources/library/stats/libs/x86_64/stats.so
Dynamic lookup: FALSE

$numParameters
[1] 24

attr(,"class")
[1] "CRoutine"         "NativeSymbolInfo"

So I'd probably look into the implementation of getNativeSymbolInfo (R_getSymbol in file Rdynload.c) and figure out what sort of pointer is the $address here. once you know that I suppose you can use it.

There is a good chance the pointer is a DL_FUNC. You probably want to look at the Rdynpriv.h file too.

Maybe this question is more suited to R-devel.

Romain

--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/98Uf7u : Rcpp 0.8.1
|- http://bit.ly/c6YnCi : graph gallery collage
`- http://bit.ly/bZ7ltC : inline 0.3.5

_______________________________________________
Rcpp-devel mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to