msoucy / dproto

D Protocol Buffer mixins to create structures at compile time
Boost Software License 1.0
37 stars 16 forks source link

Support package specifiers #91

Open WebDrake opened 8 years ago

WebDrake commented 8 years ago

The proto2 specification allows for imported data structures to be specified precisely using package specifiers, as described here: https://developers.google.com/protocol-buffers/docs/proto#packages

However, dproto fails to handle package specifiers, emitting an undefined identifier error. This makes it very difficult to have shared .proto definition files between, say, a D app and a Java app (since protoc will fail to compile for Java if the package specifiers are missing).

As an example, consider the two following .proto files:

inner.proto

package innerproto;

message InnerMessage {
    optional uint64 id = 1;
    optional string message = 2;
}

outer.proto

import "inner.proto";

message OuterMessage {
    optional uint64 id = 1;
    optional innerproto.InnerMessage message1 = 2;
    optional innerproto.InnerMessage message2 = 3;
}

If the innerproto. package specifier is removed from outer.proto, then protoc will fail to compile it for Java. OTOH dproto will fail to handle outer.proto if the package specifier is present.

timotheecour commented 7 years ago

@msoucy This feature would be great to correctly implement spec and interoperate with systems that use these; how much work would that be? Any pointers (eg what to change) would help!