summaryrefslogtreecommitdiffstats
path: root/tools/json_schema_compiler/cc_generator.py
diff options
context:
space:
mode:
authorkalman <kalman@chromium.org>2015-04-23 17:33:29 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-24 00:33:39 +0000
commit16a9133a26d076f649a7bf402a88c5aa709a45da (patch)
treeeb4467b4564f010ad8046fe69945f5172a5cb735 /tools/json_schema_compiler/cc_generator.py
parent83e6f6f8603ab57e1a4d16a7d6e7802e4b8ffc2b (diff)
downloadchromium_src-16a9133a26d076f649a7bf402a88c5aa709a45da.zip
chromium_src-16a9133a26d076f649a7bf402a88c5aa709a45da.tar.gz
chromium_src-16a9133a26d076f649a7bf402a88c5aa709a45da.tar.bz2
Make the JSON Schema compiler handle enums declared in other namespaces.
BUG=477457 R=rdevlin.cronin@chromium.org Review URL: https://codereview.chromium.org/1100333006 Cr-Commit-Position: refs/heads/master@{#326703}
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)