Comment #11 on issue 187 by ken...@google.com: Command-line argument to override the "optimize_for" option
http://code.google.com/p/protobuf/issues/detail?id=187

Hi all,

Attached is a little protoc plugin written in Python which converts all the inputs to LITE_RUNTIME -- including renaming so that they do not conflict -- and then passes them on to some other plugin. See readme.txt in the archive for details. Basically with this you can do:

  protoc --litify_out=cpp:. foo.proto

And this will produce foo_lite.pb.h and foo_lite.pb.cc, which contain foo's types compiled with optimize_for=LITE_RUNTIME. You can do Java too:

  protoc --litify_out=java:. foo.proto

You can easily modify this plugin's code to produce any arbitrary transformation you want. It's just a Python script that processes the FileDescriptorProtos representing the inputs.

I like this approach because it is completely general. There is nothing that you can't express in a Turing-complete language. In contrast, *none* of the other proposals made so far can express even what this simple plugin does (in particular no one has proposed a solution for the renaming part).

I also like that this requires no modification whatsoever to protoc. Not just because I want to avoid work, but because keeping the code code as simple as possible ensures that it retains agile.

What do you think?

Attachments:
        litify.tar.gz  4.1 KB

--
You received this message because you are subscribed to the Google Groups "Protocol 
Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to 
protobuf+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to