summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-04-01 16:47:53 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2014-04-01 16:47:53 +0300
commit6c90e824c4e8f54c71645b63b1ea33b1e028cb97 (patch)
tree8f0c3a54dbd789940b5225fde3d24db5f5c37c5f
parentf4949119ada32e28959e25e46b4f3314805b5ed1 (diff)
Fix compile error when default value given for extension field.
Update issue 111 Status: FixedInGit
-rwxr-xr-xgenerator/nanopb_generator.py2
-rw-r--r--tests/extensions/extensions.proto2
2 files changed, 3 insertions, 1 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py
index c32b26ad..0660d20e 100755
--- a/generator/nanopb_generator.py
+++ b/generator/nanopb_generator.py
@@ -351,6 +351,8 @@ class Field:
result += '0)'
elif self.pbtype in ['BYTES', 'STRING'] and self.allocation != 'STATIC':
result += '0)' # Arbitrary size default values not implemented
+ elif self.rules == 'OPTEXT':
+ result += '0)' # Default value for extensions is not implemented
else:
result += '&%s_default)' % (self.struct_name + self.name)
diff --git a/tests/extensions/extensions.proto b/tests/extensions/extensions.proto
index d85e8193..da8432e0 100644
--- a/tests/extensions/extensions.proto
+++ b/tests/extensions/extensions.proto
@@ -1,7 +1,7 @@
import 'alltypes.proto';
extend AllTypes {
- optional int32 AllTypes_extensionfield1 = 255;
+ optional int32 AllTypes_extensionfield1 = 255 [default = 5];
}
message ExtensionMessage {