[Rd] external pointers

From: Patrick Leyshock <ngkbr8es_at_gmail.com>
Date: Tue, 27 Dec 2011 21:07:00 -0800

I have an external pointer object that I'd like to pass from my R code to some C code. Per Section 5.13 of "Writing R Extensions", I've noted that
"external pointers should only be used as part of an object with normal
semantics, for example an attribute or an element of a list." So I've written up a workable C function as such:

SEXP my_c_function(SEXP param) {

     SEXP temp = getAttrib(param, install("ptr_attribute"));
     void * ptr = R_ExternalPtrAddr(temp);
     ...   // do useful things with ptr


I can pass my_c_function() an object with "normal" semantics (such as an integer vector), where the external pointer object is a parameter named
"ptr_attribute". The function extracts the pointer object from param; i.e.

this function does what I want it to do.

My question is: is there a way to do this using the .C() interface, rather than .Call()? Using call_R seems a possibility - has anyone had luck going this route?

Any suggestions appreciated.

Thanks, Patrick

        [[alternative HTML version deleted]]

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 28 Dec 2011 - 05:09:46 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 28 Dec 2011 - 15:40:20 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive