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 10206034: JSON schema compiler can't handle strings as types (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Small style change Created 8 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
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 eaf6fb3e6e48dcc9f2e4e2c4308676ab36e654bf..b8adaafe6c147e234a729cbe836170601d88455e 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -354,7 +354,7 @@ class CCGenerator(object):
return '%s.release()' % self._util_cc_helper.CreateValueFromArray(
self._cpp_type_generator.GetReferencedProperty(prop), var,
prop.optional)
- elif prop.type_.is_fundamental:
+ elif self._IsFundamentalOrFundamentalRef(prop):
if prop.optional:
var = '*' + var
return {
@@ -461,17 +461,22 @@ class CCGenerator(object):
.Append(' return %(failure_value)s;')
)
- if prop.type_.is_fundamental:
+ if self._IsFundamentalOrFundamentalRef(prop):
if prop.optional:
(c.Append('%(ctype)s temp;')
.Append('if (%s)' %
- cpp_util.GetAsFundamentalValue(prop, value_var, '&temp'))
+ cpp_util.GetAsFundamentalValue(
+ self._cpp_type_generator.GetReferencedProperty(prop),
+ value_var,
+ '&temp'))
.Append(' %(dst)s->%(name)s.reset(new %(ctype)s(temp));')
)
else:
(c.Append('if (!%s)' %
cpp_util.GetAsFundamentalValue(
- prop, value_var, '&%s->%s' % (dst, prop.unix_name)))
+ self._cpp_type_generator.GetReferencedProperty(prop),
+ value_var,
+ '&%s->%s' % (dst, prop.unix_name)))
.Append('return %(failure_value)s;')
)
elif self._IsObjectOrObjectRef(prop):
@@ -657,3 +662,10 @@ class CCGenerator(object):
"""
return (self._cpp_type_generator.GetReferencedProperty(prop).type_ ==
PropertyType.ARRAY)
+
+ def _IsFundamentalOrFundamentalRef(self, prop):
+ """Determines if this property is a Fundamental type or is a ref to a
+ Fundamental type.
+ """
+ return (self._cpp_type_generator.GetReferencedProperty(prop).type_.
+ is_fundamental)
« no previous file with comments | « chrome/common/extensions/docs/experimental.fontSettings.html ('k') | tools/json_schema_compiler/compiler.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698