bitmorse / protobuf-embedded-c

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

erroneous _read_delimited_from method call for enum #11

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1.Compile a .proto file with this:

message message_hello_request {
   required uint64 UserXuid = 1;
   required uint64 MachineXuid = 2;
   required string ContentVersion = 3;
   required DisplayNameType DisplayNameType = 4;
   repeated Pair_String_String RoutingOverrides = 5;
}
enum DisplayNameType {
   None = 0;
   Type1= 1;
   Type2 = 2;
}
message Pair_String_String {
 required string Key = 1;
 required string Value = 2;    
}

2. Look at the method generated for message_hello_request_read in the .c file.  
Notice the code inside the switch statement:

//tag of: _s_message_hello_request._DisplayNameType 
case 5 :
   offset = DisplayNameType_read_delimited_from(_buffer, &_s_bap_message_hello_request->_DisplayNameType, offset);
   break;

The method DisplayNameType_read_delimited_from does not exist.

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

The method should exist, or the switch statement should be different for the 
DisplayNameType.

What version of the product are you using? On what operating system?
Java build 1.6.0_31-b05
protoc-1.0M2

Please provide any additional information below.

Original issue reported on code.google.com by jhmi...@uw.edu on 5 Mar 2012 at 11:26

GoogleCodeExporter commented 9 years ago
Thank you for the bug-report. We will fix this error shortly. 

If you want to make your code work, you have to do the following steps:
1. delete the method DisplayNameType_write_with_tag. 
2. Instead of:

DisplayNameType_write_with_tag(&_message_hello_request->_DisplayNameType, 
_buffer, offset, 4); 

use

offset = write_raw_varint32((4<<3)+0, _buffer, offset);
offset = write_raw_varint32(_message_hello_request->_DisplayNameType, _buffer, 
offset);

3. Instead of

offset = DisplayNameType_read_delimited_from(_buffer, 
&_message_hello_request->_DisplayNameType, offset);

use

offset = read_raw_varint32(&tag, _buffer, offset);
_message_hello_request->_DisplayNameType = tag;

4. Change the struct into enum in the .h file:

struct DisplayNameType _DisplayNameType; 
into
enum DisplayNameType _DisplayNameType;

With these changes your code should compile without errors or warnings and 
encode/decode your messages.

Original comment by nvp...@gmail.com on 16 Mar 2012 at 7:06

GoogleCodeExporter commented 9 years ago
Issue 19 has been merged into this issue.

Original comment by nvp...@gmail.com on 23 Jan 2013 at 8:30

GoogleCodeExporter commented 9 years ago
Issue 14 has been merged into this issue.

Original comment by nvp...@gmail.com on 23 Jan 2013 at 8:32

GoogleCodeExporter commented 9 years ago
Fix is much more complicated than expected. Just declare the enums before the 
messages and it will work just fine. We will consider this issue in a future 
Milestone.

Original comment by nvp...@gmail.com on 31 Jan 2013 at 1:47