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

Unified Diff: tools/json_schema_compiler/cc_generator.py

Issue 197873009: Support scoped types in PPAPI IDL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed tests. Created 6 years, 9 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 | « ppapi/generators/idl_parser.py ('k') | tools/json_schema_compiler/cpp_type_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 2c47b5ed00b192ba9a38c2f53058f0253d31e6f8..10c8d67eb532fb38ada5250a7d387b2c163d55a1 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -718,7 +718,7 @@ class _Generator(object):
('*%(src_var)s', '&%(dst_var)s')))
.Append(' return %(failure_value)s;'))
elif underlying_type.property_type == PropertyType.ENUM:
- c.Concat(self._GenerateStringToEnumConversion(type_,
+ c.Concat(self._GenerateStringToEnumConversion(underlying_type,
src_var,
dst_var,
failure_value))
@@ -797,8 +797,14 @@ class _Generator(object):
type |type_| in |dst_var|. In the generated code, if |src_var| is not
a valid enum name then the function will return |failure_value|.
"""
+ if type_.property_type != PropertyType.ENUM:
+ raise TypeError(type_)
c = Code()
enum_as_string = '%s_as_string' % type_.unix_name
+ cpp_type_namespace = ''
+ if type_.namespace != self._namespace:
+ cpp_type_namespace = '%s::' % type_.namespace.unix_name
+ cpp_type_name = self._type_helper.GetCppType(type_)
(c.Append('std::string %s;' % enum_as_string)
.Sblock('if (!%s->GetAsString(&%s)) {' % (src_var, enum_as_string))
.Concat(self._GenerateError(
@@ -806,11 +812,13 @@ class _Generator(object):
self._util_cc_helper.GetValueTypeString('%%(src_var)s', True)))
.Append('return %s;' % failure_value)
.Eblock('}')
- .Append('%s = Parse%s(%s);' % (dst_var,
- self._type_helper.GetCppType(type_),
- enum_as_string))
- .Sblock('if (%s == %s) {' % (dst_var,
- self._type_helper.GetEnumNoneValue(type_)))
+ .Append('%s = %sParse%s(%s);' % (dst_var,
+ cpp_type_namespace,
+ cpp_util.Classname(type_.name),
+ enum_as_string))
+ .Sblock('if (%s == %s%s) {' % (dst_var,
+ cpp_type_namespace,
+ self._type_helper.GetEnumNoneValue(type_)))
.Concat(self._GenerateError(
'\"\'%%(key)s\': expected \\"' +
'\\" or \\"'.join(
« no previous file with comments | « ppapi/generators/idl_parser.py ('k') | tools/json_schema_compiler/cpp_type_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698