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

Unified Diff: tools/json_schema_compiler/cpp_type_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
« no previous file with comments | « tools/json_schema_compiler/compiler.py ('k') | tools/json_schema_compiler/cpp_type_generator_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/cpp_type_generator.py
diff --git a/tools/json_schema_compiler/cpp_type_generator.py b/tools/json_schema_compiler/cpp_type_generator.py
index 0a1768be035b302e0b2368253bd41481b64efc79..5afc91504e6ec22aaccb6ea41929a082e547da87 100644
--- a/tools/json_schema_compiler/cpp_type_generator.py
+++ b/tools/json_schema_compiler/cpp_type_generator.py
@@ -175,12 +175,19 @@ class CppTypeGenerator(object):
for namespace, types in sorted(self._NamespaceTypeDependencies().items()):
c.Append('namespace %s {' % namespace.name)
for type_ in types:
- if namespace.types[type_].type_ != PropertyType.ARRAY:
+ if namespace.types[type_].type_ == PropertyType.STRING:
+ c.Append('typedef std::string %s;' % type_)
+ elif namespace.types[type_].type_ == PropertyType.ARRAY:
+ c.Append('typedef std::vector<%(item_type)s> %(name)s;')
+ c.Substitute({'name': type_, 'item_type':
+ self.GetType(namespace.types[type_].item_type,
+ wrap_optional=True)})
+ else:
c.Append('struct %s;' % type_)
c.Append('}')
c.Concat(self.GetNamespaceStart())
for (name, type_) in self._namespace.types.items():
- if not type_.functions and type_.type_ != PropertyType.ARRAY:
+ if not type_.functions and type_.type_ == PropertyType.OBJECT:
c.Append('struct %s;' % name)
c.Concat(self.GetNamespaceEnd())
return c
« no previous file with comments | « tools/json_schema_compiler/compiler.py ('k') | tools/json_schema_compiler/cpp_type_generator_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698