msoucy / dproto

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

Error: no identifier for declarator BuffType!"int32" #75

Closed denizzzka closed 8 years ago

denizzzka commented 8 years ago
../../.dub/packages/dproto-2.0.0/import/dproto/dproto.d-mixin-27(116,18): Error: no identifier for declarator BuffType!"int32"
../../.dub/packages/dproto-2.0.0/import/dproto/dproto.d-mixin-27(116,48): Error: semicolon expected
../../.dub/packages/dproto-2.0.0/import/dproto/dproto.d-mixin-27(116,49): Error: declaration expected, not '('
../../.dub/packages/dproto-2.0.0/import/dproto/dproto.d-mixin-27(137,20): Error: no identifier for declarator BuffType!"int32"[]
../../.dub/packages/dproto-2.0.0/import/dproto/dproto.d-mixin-27(137,27): Error: (condition) expected following version
../../.dub/packages/dproto-2.0.0/import/dproto/dproto.d-mixin-27(137,27): Error: declaration expected following attribute, not ';'
osmproto/package.d(6,1): Error: mixin osmproto.ProtocolBuffer!"osmformat.proto" error instantiating

proto file:

option optimize_for = LITE_RUNTIME;
option java_package = "crosby.binary";
package osmproto.osmformat;

//////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////

message HeaderBlock {
  optional HeaderBBox bbox = 1;
  repeated string required_features = 4;
  repeated string optional_features = 5;

  optional string writingprogram = 16; 
  optional string source = 17; // From the bbox field.

  // replication timestamp, expressed in seconds since the epoch, 
  // otherwise the same value as in the "timestamp=..." field
  // in the state.txt file used by Osmosis
  optional int64 osmosis_replication_timestamp = 32;

  // replication sequence number (sequenceNumber in state.txt)
  optional int64 osmosis_replication_sequence_number = 33;

  // replication base URL (from Osmosis' configuration.txt file)
  optional string osmosis_replication_base_url = 34;
}

message HeaderBBox {
   required sint64 left = 1;
   required sint64 right = 2;
   required sint64 top = 3;
   required sint64 bottom = 4;
}

///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////

message PrimitiveBlock {
  required StringTable stringtable = 1;
  repeated PrimitiveGroup primitivegroup = 2;

  // Granularity, units of nanodegrees, used to store coordinates in this block
  optional int32 granularity = 17 [default=100]; 
  // Offset value between the output coordinates coordinates and the granularity grid in unites of nanodegrees.
  optional int64 lat_offset = 19 [default=0];
  optional int64 lon_offset = 20 [default=0]; 

// Granularity of dates, normally represented in units of milliseconds since the 1970 epoch.
  optional int32 date_granularity = 18 [default=1000]; 

  // Proposed extension:
  //optional BBox bbox = XX;
}

// Group of OSMPrimitives. All primitives in a group must be the same type.
message PrimitiveGroup {
  repeated Node     nodes = 1;
  optional DenseNodes dense = 2;
  repeated Way      ways = 3;
  repeated Relation relations = 4;
  repeated ChangeSet changesets = 5;
}

message StringTable {
   repeated bytes s = 1;
}

message Info {
   optional int32 version = 1 [default = -1];
   optional int64 timestamp = 2;
   optional int64 changeset = 3;
   optional int32 uid = 4;
   optional uint32 user_sid = 5; // String IDs

   // The visible flag is used to store history information. It indicates that
   // the current object version has been created by a delete operation on the
   // OSM API.
   // When a writer sets this flag, it MUST add a required_features tag with
   // value "HistoricalInformation" to the HeaderBlock.
   // If this flag is not available for some object it MUST be assumed to be
   // true if the file has the required_features tag "HistoricalInformation"
   // set.
   optional bool visible = 6;
}

message DenseInfo {
   repeated int32 version = 1 [packed = true]; 
   repeated sint64 timestamp = 2 [packed = true]; // DELTA coded
   repeated sint64 changeset = 3 [packed = true]; // DELTA coded
   repeated sint32 uid = 4 [packed = true]; // DELTA coded
   repeated sint32 user_sid = 5 [packed = true]; // String IDs for usernames. DELTA coded

   // The visible flag is used to store history information. It indicates that
   // the current object version has been created by a delete operation on the
   // OSM API.
   // When a writer sets this flag, it MUST add a required_features tag with
   // value "HistoricalInformation" to the HeaderBlock.
   // If this flag is not available for some object it MUST be assumed to be
   // true if the file has the required_features tag "HistoricalInformation"
   // set.
   repeated bool visible = 6 [packed = true];
}

// THIS IS STUB DESIGN FOR CHANGESETS. NOT USED RIGHT NOW.
// TODO:    REMOVE THIS?
message ChangeSet {
   required int64 id = 1;
//   
//   // Parallel arrays.
//   repeated uint32 keys = 2 [packed = true]; // String IDs.
//   repeated uint32 vals = 3 [packed = true]; // String IDs.
//
//   optional Info info = 4;

//   optional int64 created_at = 8;
//   optional int64 closetime_delta = 9;
//   optional bool open = 10;
//   optional HeaderBBox bbox = 11;
}

message Node {
   required sint64 id = 1;
   // Parallel arrays.
   repeated uint32 keys = 2 [packed = true]; // String IDs.
   repeated uint32 vals = 3 [packed = true]; // String IDs.

   optional Info info = 4; // May be omitted in omitmeta

   required sint64 lat = 8;
   required sint64 lon = 9;
}

message DenseNodes {
   repeated sint64 id = 1 [packed = true]; // DELTA coded

   //repeated Info info = 4;
   optional DenseInfo denseinfo = 5;

   repeated sint64 lat = 8 [packed = true]; // DELTA coded
   repeated sint64 lon = 9 [packed = true]; // DELTA coded

   // Special packing of keys and vals into one array. May be empty if all nodes in this block are tagless.
   repeated int32 keys_vals = 10 [packed = true]; 
}

message Way {
   required int64 id = 1;
   // Parallel arrays.
   repeated uint32 keys = 2 [packed = true];
   repeated uint32 vals = 3 [packed = true];

   optional Info info = 4;

   repeated sint64 refs = 8 [packed = true];  // DELTA coded
}

message Relation {
  enum MemberType {
    NODE = 0;
    WAY = 1;
    RELATION = 2;
  } 
   required int64 id = 1;

   // Parallel arrays.
   repeated uint32 keys = 2 [packed = true];
   repeated uint32 vals = 3 [packed = true];

   optional Info info = 4;

   // Parallel arrays
   repeated int32 roles_sid = 8 [packed = true];
   repeated sint64 memids = 9 [packed = true]; // DELTA encoded
   repeated MemberType types = 10 [packed = true];
}
bloche commented 8 years ago

Any update on this one? I'm running into the same issue.

bloche commented 8 years ago

This appears to only happen when the int32 declaration is the first member declaration in a message.

bloche commented 8 years ago

This may not be a bug at all, just a very confusing error message.

You can't have a variable named version in D. This should work if you change the Info and DenseInfo version members to something else.

msoucy commented 8 years ago

You have no idea how hard I hit my head when I read that...

This is incentive to clean up the errors it gives, at least.

msoucy commented 8 years ago

Minimal test case:

unittest
{
    import dproto.parse;
    enum pbstring = q{
message Info {
   optional int32 version = 1 [default = -1];
}
    };
    mixin ProtocolBufferFromString!pbstring;
}
bloche commented 8 years ago

I know how you feel, I had the same reaction when I finally saw it.