summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler/cc_generator.py
diff options
context:
space:
mode:
Diffstat (limited to 'tools/json_schema_compiler/cc_generator.py')
-rw-r--r--tools/json_schema_compiler/cc_generator.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py
index 73413ef..6faac39 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -363,11 +363,16 @@ class _Generator(object):
for prop in type_.properties.values():
prop_var = 'this->%s' % prop.unix_name
if prop.optional:
- # Optional enum values are generated with a NONE enum value.
underlying_type = self._type_helper.FollowRef(prop.type_)
if underlying_type.property_type == PropertyType.ENUM:
- c.Sblock('if (%s != %s) {' %
+ # Optional enum values are generated with a NONE enum value,
+ # potentially from another namespace.
+ maybe_namespace = ''
+ if underlying_type.namespace != self._namespace:
+ maybe_namespace = '%s::' % underlying_type.namespace.unix_name
+ c.Sblock('if (%s != %s%s) {' %
(prop_var,
+ maybe_namespace,
self._type_helper.GetEnumNoneValue(prop.type_)))
else:
c.Sblock('if (%s.get()) {' % prop_var)