Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Unified Diff: tools/json_schema_compiler/cc_generator.py

Issue 1100333006: Make the JSON Schema compiler handle enums declared in other namespaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: typo Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/json_schema_compiler/h_generator.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/cc_generator.py
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py
index 73413efaeadf2300339b79763ece40a4452dd6db..6faac39751815d5910326658b21d4bb6583fde5a 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)
« no previous file with comments | « no previous file | tools/json_schema_compiler/h_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698