[Rprotobuf-yada] linking against R shared library

Dirk Eddelbuettel edd at debian.org
Sat Nov 7 16:51:23 CET 2009


This compiles, but is otherwise nonsensical.  Does this get you going?

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

-- 
Three out of two people have difficulties with fractions.


More information about the Rprotobuf-yada mailing list