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

Unified Diff: tools/json_schema_compiler/cc_generator.py

Issue 12041098: Initial commit of the Dart Chrome Extension APIs generators (Closed) Base URL: http://git.chromium.org/chromium/src.git@file_path_bugfix
Patch Set: Kalman fixes 2 (nocompile ignored in bundle mode) Created 7 years, 10 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 | « build/json_schema_compile.gypi ('k') | tools/json_schema_compiler/code.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fff945762c379dd46c55d3e04446731444d33966..2cc2e5d15aee03e0c3ea1116269f676730150f20 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -11,11 +11,22 @@ import sys
import util_cc_helper
class CCGenerator(object):
+ def __init__(self, type_generator, cpp_namespace):
+ self._type_generator = type_generator
+ self._cpp_namespace = cpp_namespace
+
+ def Generate(self, namespace):
+ return _Generator(namespace,
+ self._type_generator,
+ self._cpp_namespace).Generate()
+
+class _Generator(object):
"""A .cc generator for a namespace.
"""
- def __init__(self, namespace, cpp_type_generator):
- self._type_helper = cpp_type_generator
+ def __init__(self, namespace, cpp_type_generator, cpp_namespace):
self._namespace = namespace
+ self._type_helper = cpp_type_generator
+ self._cpp_namespace = cpp_namespace
self._target_namespace = (
self._type_helper.GetCppNamespaceName(self._namespace))
self._util_cc_helper = (
@@ -36,7 +47,7 @@ class CCGenerator(object):
.Append('#include "%s/%s.h"' %
(self._namespace.source_file_dir, self._namespace.unix_name))
.Cblock(self._type_helper.GenerateIncludes(include_soft=True))
- .Concat(self._type_helper.GetRootNamespaceStart())
+ .Concat(cpp_util.OpenNamespace(self._cpp_namespace))
.Cblock(self._type_helper.GetNamespaceStart())
)
if self._namespace.properties:
@@ -76,7 +87,7 @@ class CCGenerator(object):
for event in self._namespace.events.values():
c.Cblock(self._GenerateEvent(event))
(c.Concat(self._type_helper.GetNamespaceEnd())
- .Cblock(self._type_helper.GetRootNamespaceEnd())
+ .Cblock(cpp_util.CloseNamespace(self._cpp_namespace))
)
return c
« no previous file with comments | « build/json_schema_compile.gypi ('k') | tools/json_schema_compiler/code.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698