[Rprotobuf-yada] linking against R shared library
Romain Francois
romain.francois at dbmail.com
Sat Nov 7 17:48:53 CET 2009
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 ?
> edd at ron:~/svn/rprotobuf$ cat pkg/src/readconnection.cpp
>
>
> #define NEED_CONNECTION_PSTREAMS 1
> #include<Rinternals.h>
>
> #include "rprotobuf.h"
>
>
> namespace rprotobuf {
>
> /**
> * read a message from a connection
> *
> * @param xp external pointer to a Descriptor*
> * @param connname name of the connection
> *
> * @return a new "protobufMessage" S4 instance
> */
> SEXP readMessageFromConnection( SEXP xp, SEXP pdata ){
>
> Descriptor* desc = GET_DESCRIPTOR_POINTER_FROM_XP( xp );
>
> // these inits are just to silence the compiler...
> R_inpstream_t stream = NULL;
> Rconnection con = NULL;
> R_pstream_format_t type = R_pstream_binary_format;
> SEXP (*phook)(SEXP, SEXP) = NULL;
> R_InitConnInPStream(stream, con, type, phook, pdata);
>
> Message * message = (Message*)MessageFactory::generated_factory()->GetPrototype( desc )->New();
> if ( !message ) {
> throwException( "could not call factory->GetPrototype(desc)->New()", "MessageCreationException" ) ;
> }
>
> // do work...
>
> return( new_RS4_Message_( message ) ) ;
>
> }
>
> } // namespace rprotobuf
>
--
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