Dgeodjo / nanopb

Automatically exported from code.google.com/p/nanopb
zlib License
0 stars 1 forks source link

Short enum names in imported proto files are not honoured #118

Open GoogleCodeExporter opened 9 years ago

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

1. Create 2 .proto files, one of which imports the other.  

2. In the imported .proto, define an enum with:

    enum ENUM_NAME {
        option (nanopb_enumopt).long_names = false;
        ENUM_PREFIX_DEFAULT_VALUE = 1;
    }  

3. Reference this imported enum from a message in the other .proto file via an 
optional field, specifying a value as the default:

    optional ENUM_NAME field = 1 [default = DEFAULT_VALUE];

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

The generated .pb.c file should have:

const ENUM_NAME MESSAGE_NAME_field_default = ENUM_PREFIX_DEFAULT_VALUE;

Instead, I get:

const ENUM_NAME MESSAGE_NAME_field_default = 
ENUM_NAME_ENUM_PREFIX_DEFAULT_VALUE;

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

0.2.8, Linux

Please provide any additional information below.

Original issue reported on code.google.com by j...@jonread.com on 22 May 2014 at 4:37

GoogleCodeExporter commented 9 years ago

Original comment by Petteri.Aimonen on 22 May 2014 at 4:41

GoogleCodeExporter commented 9 years ago
Apologies, 

   optional ENUM_NAME field = 1 [default = DEFAULT_VALUE];

Should read

   optional ENUM_NAME field = 1 [default = ENUM_PREFIX_DEFAULT_VALUE];

If both enum and message are in the same .proto, this works fine - just not 
when imported from another.

Original comment by j...@jonread.com on 22 May 2014 at 4:42

GoogleCodeExporter commented 9 years ago
Yeah. It may be somewhat difficult to get information about settings from other 
file, but have to check if there is some way.

Original comment by Petteri.Aimonen on 22 May 2014 at 4:49