[Rprotobuf-yada] linking against R shared library
Romain Francois
romain.francois at dbmail.com
Sat Nov 7 19:07:07 CET 2009
On 11/07/2009 06:46 PM, Dirk Eddelbuettel wrote:
>
>
> On 7 November 2009 at 17:48, Romain Francois wrote:
> | On 11/07/2009 04:51 PM, Dirk Eddelbuettel wrote:
> |>
> |>
> |> This compiles, but is otherwise nonsensical. Does this get you going?
> |
> | I think I still need to call getConnection to get the Rconn* that
> | corresponds to the connection index. What do you pass as pdata here ?
>
> Dunno, I never used these. I just thought I'd help you to get it out of
> Rinternals and to make it available.
>
> I would have to look at the R sources to see what they do with the
> connections. I guess I misunderstood your snippet
>
> Rconnection con ;
> struct R_outpstream_st out;
> R_pstream_format_t type = R_pstream_binary_format ;
> SEXP (*hook)(SEXP, SEXP) = NULL ;
> con = getConnection(Rf_asInteger(connection));
> R_InitConnOutPStream(&out, con, type, 0, hook, R_NilValue );
>
> as you're ahead of me and only missing getConnection. My bad.
>
> Looking at $R/src/main/connections.c, getConnection is clearly hidden so I am
> not sure what we can do ... short of patching R or re-implementing the
> connection business outside of R. Either way, this sucks :-/
>
> Dirk
I'm close to give up. I don't see why they would make this available:
void R_InitConnOutPStream(R_outpstream_t stream, Rconnection con,
R_pstream_format_t type, int version,
SEXP (*phook)(SEXP, SEXP), SEXP pdata);
when there seems to be no way to get hold of __any__ Rconnection. If I
could get to some Rconnection, then knowing its number I'd be able to
jump to the one I'm interested in I think since they are in an array ...
The closest I can get is to the con->exp_ptr which is this guy:
> f <- file( "/tmp/foo", open = "w" )
> attr( f, "conn_id")
<pointer: 0x30>
which would be useful if the external pointer did point to something
useful, but that's not what I gather from these :
con->ex_ptr = R_MakeExternalPtr(con->id, install("connection"),
R_NilValue);
setAttrib(ans, install("conn_id"), con->ex_ptr);
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/BcPw : celebrating R commit #50000
|- http://tr.im/ztCu : RGG #158:161: examples of package IDPmisc
`- http://tr.im/yw8E : New R package : sos
More information about the Rprotobuf-yada
mailing list