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

Unified Diff: tools/json_schema_compiler/cc_generator.py

Issue 437883002: Make the root_namespace argument to json_schema_compiler.gypi a string (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: un-escape %% for windows 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/cc_generator.py
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py
index 61f5bf1f04b87266d90e7854cf84a40f56d892e2..43434b8892389a788b02b092a9b57c3779d16c06 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -9,25 +9,23 @@ import schema_util
import util_cc_helper
class CCGenerator(object):
- def __init__(self, type_generator, cpp_namespace):
+ def __init__(self, type_generator, cpp_namespace_pattern):
self._type_generator = type_generator
- self._cpp_namespace = cpp_namespace
+ self._cpp_namespace_pattern = cpp_namespace_pattern
def Generate(self, namespace):
return _Generator(namespace,
self._type_generator,
- self._cpp_namespace).Generate()
+ self._cpp_namespace_pattern).Generate()
class _Generator(object):
"""A .cc generator for a namespace.
"""
- def __init__(self, namespace, cpp_type_generator, cpp_namespace):
+ def __init__(self, namespace, cpp_type_generator, cpp_namespace_pattern):
self._namespace = namespace
self._type_helper = cpp_type_generator
- self._cpp_namespace = cpp_namespace
- self._target_namespace = (
- self._type_helper.GetCppNamespaceName(self._namespace))
+ self._cpp_namespace_pattern = cpp_namespace_pattern
self._util_cc_helper = (
util_cc_helper.UtilCCHelper(self._type_helper))
self._generate_error_messages = namespace.compiler_options.get(
@@ -36,6 +34,9 @@ class _Generator(object):
def Generate(self):
"""Generates a Code object with the .cc for a single namespace.
"""
+ cpp_namespace = cpp_util.GetCppNamespace(self._cpp_namespace_pattern,
+ self._namespace.unix_name)
+
c = Code()
(c.Append(cpp_util.CHROMIUM_LICENSE)
.Append()
@@ -52,8 +53,7 @@ class _Generator(object):
.Append()
.Append('using base::UTF8ToUTF16;')
.Append()
- .Concat(cpp_util.OpenNamespace(self._cpp_namespace))
- .Cblock(self._type_helper.GetNamespaceStart())
+ .Concat(cpp_util.OpenNamespace(cpp_namespace))
)
if self._namespace.properties:
(c.Append('//')
@@ -91,9 +91,7 @@ class _Generator(object):
)
for event in self._namespace.events.values():
c.Cblock(self._GenerateEvent(event))
- (c.Concat(self._type_helper.GetNamespaceEnd())
- .Cblock(cpp_util.CloseNamespace(self._cpp_namespace))
- )
+ c.Cblock(cpp_util.CloseNamespace(cpp_namespace))
c.Append()
return c

Powered by Google App Engine
This is Rietveld 408576698