[Rprotobuf-yada] skeletic implementation of proto messages using external pointers
Romain Francois
romain.francois at dbmail.com
Thu Oct 29 11:38:36 CET 2009
On 10/29/2009 11:21 AM, Dirk Eddelbuettel wrote:
>
> On 29 October 2009 at 11:01, Romain François wrote:
> | I've commited some R and C (maybe need to C++ it at some point) that
> | prepare the space for mirroring proto messages as R S4 objects of class
> | "protobufMessage".
> |
> | The design is much inspired from the new features of rJava. Here are
> | some insights. The "P" function takes either a message type (i.e.
> | "tutorial.Person") or a proto file, goes C internal, grabs a pointer to
> | some descriptor object (not sure what this will be right now), and
> | creates an R object of S4 class "protobufDescriptor".
> |
> | Then, we can throw the created descriptor into "new", made generic by
> | the package. So you'd create a Person message like this :
> |
> | message<- new( P("tutorial.Person" ) )
> |
> | I've also added hooks so that
> |
> | message$name
> |
> | goes internal to grab the "name" field from the message.
>
> Very nice!
I'll be nicer when there is some actual code, at the moment I'm juggling
with nil external pointers and R_NilValue, etc ...
Some other thing I've done in rJava is the attach mechanism, which I
think will be easy enough to reproduce here, so we should have something
like this:
attachProtobufDescriptorPool() # or maybe a simpler name
message <- new( Person )
...
so that R internally asks our package for a binding to the "Person" name
as part of the search path lookup. I think the DescriptorPool :
http://code.google.com/apis/protocolbuffers/docs/reference/cpp/google.protobuf.descriptor.html#DescriptorPool
will provide all I need
Quick question, I want to include some header files from libproto, so
something like this is=n my rprotobuf.h
#include <google/protobuf/compiler/importer.h>
but I get this :
protoc --cpp_out=. addressbook.proto
g++ -c addressbook.pb.cc -fpic -shared
-I/usr/local/lib/R/library/Rcpp/lib -I/usr/include
g++ -I/usr/local/lib/R/include -I/usr/local/lib/R/library/Rcpp/lib
-I/usr/include -I/usr/local/include -fpic -g -O2 -c
list_people_R.cpp -o list_people_R.o
g++ -I/usr/local/lib/R/include -I/usr/local/lib/R/library/Rcpp/lib
-I/usr/include -I/usr/local/include -fpic -g -O2 -c rprotobuf.cpp -o
rprotobuf.o
In file included from /usr/include/google/protobuf/descriptor.pb.h:24,
from /usr/include/google/protobuf/compiler/parser.h:46,
from /usr/include/google/protobuf/compiler/importer.h:47,
from rprotobuf.h:14,
from rprotobuf.cpp:3:
/usr/include/google/protobuf/extension_set.h:378: error: expected
identifier before ‘(’ token
/usr/include/google/protobuf/extension_set.h:378: error: ‘parameter’
declared as function returning a function
/usr/include/google/protobuf/extension_set.h:378: error: expected ‘)’
before ‘,’ token
Any clue ? It's probably something minor ...
> I am a little swamped right now and may not be able to catch up immediately
> but I will try. Part of my home network conked out and I need to redo that.
>
> Saptarshi: did you get an r-forge id so that we can add you to the project?
> Can I assume that you are on this list?
I registered both of you. I have just registered the user "saptarshi" as
I don't think there are many, so both of you should have write access to
the svn repo.
> Dirk
>
--
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