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

Unified Diff: tools/json_schema_compiler/cpp_type_generator.py

Issue 10022005: Let json schema compiler handle using arrays as types (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Minor style changes 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/cc_generator.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 04e008051368f5e67974a04463ea715b70428c08..c73589e5124423c4af582c1d659f12294a6eb956 100644
--- a/tools/json_schema_compiler/cpp_type_generator.py
+++ b/tools/json_schema_compiler/cpp_type_generator.py
@@ -173,11 +173,12 @@ class CppTypeGenerator(object):
for namespace, types in sorted(self._NamespaceTypeDependencies().items()):
c.Append('namespace %s {' % namespace.name)
for type_ in types:
- c.Append('struct %s;' % type_)
+ if namespace.types[type_].type_ != PropertyType.ARRAY:
+ c.Append('struct %s;' % type_)
c.Append('}')
c.Concat(self.GetNamespaceStart())
for (name, type_) in self._namespace.types.items():
- if not type_.functions:
+ if not type_.functions and type_.type_ != PropertyType.ARRAY:
c.Append('struct %s;' % name)
c.Concat(self.GetNamespaceEnd())
return c
@@ -192,9 +193,6 @@ class CppTypeGenerator(object):
self._cpp_namespaces[dependency]))
return c
- def _QualifyName(self, namespace, name):
- return '.'.join([namespace.name, name])
-
def _ResolveTypeNamespace(self, ref_type):
"""Resolves a type name to its enclosing namespace.
@@ -215,6 +213,20 @@ class CppTypeGenerator(object):
return None
+ def GetReferencedProperty(self, prop):
+ """Returns the property a property of type REF is referring to.
+
+ If the property passed in is not of type PropertyType.REF, it will be
+ returned unchanged.
+ """
+ if prop.type_ != PropertyType.REF:
+ return prop
+ return self._ResolveTypeNamespace(prop.ref_type).types.get(prop.ref_type,
+ None)
+
+ def _QualifyName(self, namespace, name):
+ return '.'.join([namespace.name, name])
+
def _NamespaceTypeDependencies(self):
"""Returns a dict containing a mapping of model.Namespace to the C++ type
of type dependencies for self._namespace.
« no previous file with comments | « tools/json_schema_compiler/cc_generator.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