Note that to write your plugin, you do *not* have to copy the CppGenerator sources. Instead, write your plugin to use output_directory->OpenForInsert() to insert additional code into what the C++ code generator already generated. Specifically, you want to insert at the "namespace_scope" insertion point, documented here:
http://code.google.com/apis/protocolbuffers/docs/reference/cpp-generated.html#plugins Then you would invoke protoc like: protoc --cpp_out=dir --my_plugin_out=dir foo.proto The C++ generator will be executed first, then your plugin. Since they have the same output location, your plugin can insert into the code generated by the C++ code generator. On Wed, Mar 10, 2010 at 1:55 PM, awk <[email protected]> wrote: > I'm trying to throw together an alternative RPC mechanism using a > protoc plugin/CodeGenerator (rather than use the deprecated headers). > > I've hacked a new plugin together by liberally grabbing from the > current compiler/cpp generator sources. It works to output code that > looks good to my eyes however because I (deliberately) want to use the > Message subclasses etc. that are output from CppGenerator I get a > clash between the Service subclass definition output by my plugin and > the one output by CppGenerator. > > Other than removing the 'HasServices' call and the ServiceGenerator > subclass from the current compiler/cpp sources is there any other way > I can disable the CppGenerator output of my Service instance ? A > namespace doesn't really help since that's just driven from the > package clause in the .proto source > > Ideally what I'll have at the end of this is a protoc plugin that > basically does the same as the current CppGenerator for Services > (only) and could be used today by anyone who's already subclassed > Service, RpcController & RpcChannel, and can be used by others as a > basis to writing their own generator for services. > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<protobuf%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/protobuf?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.
