You can use extensions for this.
message BarMsg {
extensions 100 to max;
}
Then, in some other file that knows about both FooMsg and BarMsg, do:
extend BarMsg {
optional FooMsg foo_ext = 100;
}
On Fri, Dec 11, 2009 at 2:37 PM, atkretsch <[email protected]> wrote:
> Hi all,
>
> Just wondering if it is at all possible to include protobuf messages
> that aren't resolved at generation time. What I mean is, I'd like to
> be able to more or less declare a message type as "extern", and be
> able to use it in my .proto file, then resolve the "extern" by having
> the generated class with the package and name in my classpath. Is
> this even remotely possible?
>
> An example:
> Foo.jar contains the compiled Java code for the following protobuf:
> option java_package = "com.foo";
> message FooMsg {
> optional int32 a = 1;
> optional int32 b = 2;
> ...
> }
>
> In my code, I want to do this:
> option java_package = "com.bar";
> message BarMsg {
> optional com.foo.FooMsg my_foo = 1;
> ...
> }
>
> However, for the purposes of this discussion, I do not have access to
> the proto file for FooMsg, and thus cannot simply do an "import
> FooMsg.proto".
>
> Just want to know if this is possible as it would be very convenient
> for me.
>
> Thanks!
> Andy
>
> --
>
> 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.