mikevoyt / protobuf-embedded-c

Automatically exported from code.google.com/p/protobuf-embedded-c
0 stars 0 forks source link

default value don't seem to be supported #12

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Downloaded 1.0M2 version
2. Downloaded proto example from google 

package tutorial;

message Person {
  required string name = 1;
  required int32 id = 2;
  optional string email = 3;

  enum PhoneType {
    MOBILE = 0;
    HOME = 1;
    WORK = 2;
  }

  message PhoneNumber {
    required string number = 1;
    optional PhoneType type = 2 [default = HOME];
  }

  repeated PhoneNumber phone = 4;
}

message AddressBook {
  repeated Person person = 1;
}

What is the expected output? What do you see instead?

Ran java -jar protoc-1.0M2.jar  protocol/addressbook.proto, expected to get a 
C-file generated

Got :
line 16:32 no viable alternative at character '['
line 16:47 no viable alternative at character ']'
line 6:2 mismatched input 'optional' expecting '}'
line 16:4 mismatched input 'optional' expecting '}' 
(zip)

=> it looks like syntax [default= ... ] is not supported ?

What version of the product are you using? On what operating system?

Win 7

D:\code\protbuff_test>ver
Microsoft Windows [Version 6.1.7601]
D:\code\protbuff_test>java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)

Please provide any additional information below.

If this is not supported (or some other stuff is not), would it be possible to 
have a clear "limitation" page stating what is supposed to work and what is not 
?

Original issue reported on code.google.com by florent....@gmail.com on 24 May 2012 at 3:14

GoogleCodeExporter commented 9 years ago
From our point of view, "default values" are useful in combination with 
"optional" fields, so we merge both issues.

Original comment by nvp...@gmail.com on 11 Dec 2012 at 10:34