On Fri, Aug 28, 2009 at 1:28 AM, Kenton Varda<ken...@google.com> wrote:
> Yep, it's a very annoying problem.  The solution I prefer is to add a dummy
> usage of one of the classes in your .proto somewhere high-up in your
> program, in a place that should logically "know" that the file is needed.

This is really not feasible. There is no such place, unfortunately.

> BTW, if you aren't actually explicitly using the extension anywhere, then
> the only reason to force it to be linked in is if you want it to appear
> correctly when using reflection or TextFormat.  Otherwise you should just
> let it go into the UnknownFieldSet.

The situation is this: I have a main program which parses incoming
messages, and some of these messages have extensions set. These
extensions are (sometimes) only known to "plugins" to the main
program. The incoming message has an identifier so that the main
program knows which plugin it should send the message to, but the main
program itself doesn't know anything about the plugin. The problem I
had was that when the message was passed to the plugin, the plugin
fails to get the extension, i.e. the extension field was unset (i.e.
HasExtension(foo::foo_ext) returned false).

Does the UnknownFieldSet allow the plugin to extract the "unknown field"?

The original solution to this I had before I read up on extensions was
to store the messages to/from the plugins as seralized byte-streams in
the top-level package. This actually worked fine, with the exception
of having to encode/copy the message twice at both ends.

-- 
/Jesper

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to protobuf@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