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

Unified Diff: tools/json_schema_compiler/cpp_type_generator.py

Issue 487533005: Add support for references in different paths in apis (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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/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 de6d1306287511d5419ed199174aae6b1663ac17..d97ac30b6c8d9faadadd4eeb2f9eb741f742ab99 100644
--- a/tools/json_schema_compiler/cpp_type_generator.py
+++ b/tools/json_schema_compiler/cpp_type_generator.py
@@ -21,6 +21,12 @@ class _TypeDependency(object):
return '%s.%s' % (self.type_.namespace.name, self.type_.name)
+def GetNamespacePattern(namespace):
+ if namespace.environment:
not at google - send to devlin 2014/08/26 20:16:06 Again, when will there not be an environment? I wo
lfg 2014/08/26 21:18:43 Done.
+ return namespace.environment.namespace_pattern
+ return ''
+
+
class CppTypeGenerator(object):
"""Manages the types of properties and provides utilities for getting the
C++ type out of a model.Property
@@ -96,7 +102,10 @@ class CppTypeGenerator(object):
if self._default_namespace is type_.namespace:
cpp_type = cpp_util.Classname(type_.name)
else:
- cpp_type = '%s::%s' % (type_.namespace.unix_name,
+ cpp_namespace = cpp_util.GetCppNamespace(
+ GetNamespacePattern(type_.namespace),
+ type_.namespace.unix_name)
+ cpp_type = '%s::%s' % (cpp_namespace,
cpp_util.Classname(type_.name))
elif type_.property_type == PropertyType.ANY:
cpp_type = 'base::Value'
@@ -130,7 +139,7 @@ class CppTypeGenerator(object):
PropertyType.OBJECT,
PropertyType.CHOICES))
- def GenerateForwardDeclarations(self, cpp_namespace_pattern):
+ def GenerateForwardDeclarations(self):
"""Returns the forward declarations for self._default_namespace.
"""
c = Code()
@@ -144,7 +153,7 @@ class CppTypeGenerator(object):
if not filtered_deps:
continue
- cpp_namespace = cpp_util.GetCppNamespace(cpp_namespace_pattern,
+ cpp_namespace = cpp_util.GetCppNamespace(GetNamespacePattern(namespace),
namespace.unix_name)
c.Concat(cpp_util.OpenNamespace(cpp_namespace))
for dep in filtered_deps:

Powered by Google App Engine
This is Rietveld 408576698