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

Unified Diff: tools/json_schema_compiler/h_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 | « tools/json_schema_compiler/dart_generator.py ('k') | tools/json_schema_compiler/idl_schema.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/json_schema_compiler/h_generator.py
diff --git a/tools/json_schema_compiler/h_generator.py b/tools/json_schema_compiler/h_generator.py
index 43d14f8f7724c75436fd9ec3b4ca031111bb93a6..140670d7d0df34731b2ee9e0defa493f280d1888 100644
--- a/tools/json_schema_compiler/h_generator.py
+++ b/tools/json_schema_compiler/h_generator.py
@@ -8,11 +8,22 @@ import cpp_util
import schema_util
class HGenerator(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 .h 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))
@@ -44,7 +55,7 @@ class HGenerator(object):
.Append()
)
- c.Concat(self._type_helper.GetRootNamespaceStart())
+ c.Concat(cpp_util.OpenNamespace(self._cpp_namespace))
# TODO(calamity): These forward declarations should be #includes to allow
# $ref types from other files to be used as required params. This requires
# some detangling of windows and tabs which will currently lead to circular
@@ -96,7 +107,7 @@ class HGenerator(object):
for event in self._namespace.events.values():
c.Cblock(self._GenerateEvent(event))
(c.Concat(self._type_helper.GetNamespaceEnd())
- .Cblock(self._type_helper.GetRootNamespaceEnd())
+ .Concat(cpp_util.CloseNamespace(self._cpp_namespace))
.Append('#endif // %s' % ifndef_name)
.Append()
)
@@ -242,6 +253,7 @@ class HGenerator(object):
is_in_container=True)))
)
(c.Eblock()
+ .Append()
.Sblock(' private:')
.Append('DISALLOW_COPY_AND_ASSIGN(%(classname)s);')
.Eblock('};')
@@ -320,6 +332,7 @@ class HGenerator(object):
.Cblock(self._GenerateTypes(p.type_ for p in function.params))
.Cblock(self._GenerateFields(function.params))
.Eblock()
+ .Append()
.Sblock(' private:')
.Append('Params();')
.Append()
« no previous file with comments | « tools/json_schema_compiler/dart_generator.py ('k') | tools/json_schema_compiler/idl_schema.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698