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

Unified Diff: tools/json_schema_compiler/cc_generator.py

Issue 279833002: Fix compile error if both inline and reference enums are used in a type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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 b6dfb6f22403584bf19449dea3055c9f4c205d37..eec0e3a28fe53c3f10fe08dd2e1ce406ccd2c081 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -497,9 +497,10 @@ class _Generator(object):
vardot = '(%s).' % var
return '%sDeepCopy()' % vardot
elif underlying_type.property_type == PropertyType.ENUM:
- classname = cpp_util.Classname(schema_util.StripNamespace(
- underlying_type.name))
- return 'new base::StringValue(%sToString(%s))' % (classname, var)
+ maybe_namespace = ''
+ if type_.property_type == PropertyType.REF:
+ maybe_namespace = '%s::' % underlying_type.namespace.unix_name
+ return 'new base::StringValue(%sToString(%s))' % (maybe_namespace, var)
elif underlying_type.property_type == PropertyType.BINARY:
if is_ptr:
vardot = var + '->'
@@ -888,8 +889,8 @@ class _Generator(object):
c.Append('// static')
maybe_namespace = '' if cpp_namespace is None else '%s::' % cpp_namespace
- c.Sblock('std::string %s%sToString(%s enum_param) {' %
- (maybe_namespace, classname, classname))
+ c.Sblock('std::string %sToString(%s enum_param) {' %
+ (maybe_namespace, classname))
c.Sblock('switch (enum_param) {')
for enum_value in self._type_helper.FollowRef(type_).enum_values:
(c.Append('case %s: ' % self._type_helper.GetEnumValue(type_, enum_value))
@@ -901,12 +902,6 @@ class _Generator(object):
.Append('return "";')
.Eblock('}')
)
-
- (c.Append()
- .Sblock('std::string %sToString(%s enum_param) {' %
- (maybe_namespace, classname))
- .Append('return %s%sToString(enum_param);' % (maybe_namespace, classname))
- .Eblock('}'))
return c
def _GenerateEnumFromString(self, cpp_namespace, type_):
« 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