Fix problem with .options file and extension fields.

The options for an extension field were being looked up under wrong name
(MessageName instead of MessageName.fieldname).

Fixed the problem and added regression test. Created a new subfolder for
regression test cases.

Update issue 125
Status: FixedInGit
This commit is contained in:
Petteri Aimonen
2014-07-20 14:02:56 +03:00
parent 788d2825b0
commit f2f9f8a9ed
6 changed files with 34 additions and 2 deletions

View File

@@ -645,7 +645,7 @@ def parse_file(fdesc, file_options):
enums.append(Enum(names, enum, enum_options)) enums.append(Enum(names, enum, enum_options))
for names, extension in iterate_extensions(fdesc, base_name): for names, extension in iterate_extensions(fdesc, base_name):
field_options = get_nanopb_suboptions(extension, file_options, names) field_options = get_nanopb_suboptions(extension, file_options, names + extension.name)
if field_options.type != nanopb_pb2.FT_IGNORE: if field_options.type != nanopb_pb2.FT_IGNORE:
extensions.append(ExtensionField(names, extension, field_options)) extensions.append(ExtensionField(names, extension, field_options))

View File

@@ -141,6 +141,6 @@ import os.path
env['VARIANT_DIR'] = 'build' env['VARIANT_DIR'] = 'build'
env['BUILD'] = '#' + env['VARIANT_DIR'] env['BUILD'] = '#' + env['VARIANT_DIR']
env['COMMON'] = '#' + env['VARIANT_DIR'] + '/common' env['COMMON'] = '#' + env['VARIANT_DIR'] + '/common'
for subdir in Glob('*/SConscript'): for subdir in Glob('*/SConscript') + Glob('regression/*/SConscript'):
SConscript(subdir, exports = 'env', variant_dir = env['VARIANT_DIR'] + '/' + os.path.dirname(str(subdir))) SConscript(subdir, exports = 'env', variant_dir = env['VARIANT_DIR'] + '/' + os.path.dirname(str(subdir)))

View File

@@ -0,0 +1,9 @@
# Regression test for Issue 125: Wrong identifier name for extension fields
Import("env")
env.NanopbProto(["extensionbug", "extensionbug.options"])
env.Object('extensionbug.pb.c')
env.Match(['extensionbug.pb.h', 'extensionbug.expected'])

View File

@@ -0,0 +1,3 @@
pb_extension_type_t Message2_extras
uint32_t field2

View File

@@ -0,0 +1,4 @@
* type:FT_IGNORE
Message2.extras type:FT_STATIC
Message2.field2 type:FT_STATIC

View File

@@ -0,0 +1,16 @@
message Message1
{
optional uint32 fieldA = 1;
extensions 30 to max;
}
message Message2
{
extend Message1
{
optional Message2 extras = 30;
}
optional uint32 field1 = 1;
optional uint32 field2 = 2;
}