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

Unified Diff: tools/json_schema_compiler/h_generator.py

Issue 10796114: Added ToJson to JSON schema compiler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed scope Created 8 years, 5 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/cpp_util.py ('k') | tools/json_schema_compiler/test/content_settings.json » ('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 4cc0e6f89baeff52345d8d9172c066da12e75cfc..03879ca0ac73db84e99de049f76230e615850132 100644
--- a/tools/json_schema_compiler/h_generator.py
+++ b/tools/json_schema_compiler/h_generator.py
@@ -230,7 +230,8 @@ class HGenerator(object):
"""
c = Code()
(c.Sblock('namespace %s {' % cpp_util.Classname(event.name))
- .Concat(self._GenerateCreateCallbackArguments(event))
+ .Concat(self._GenerateCreateCallbackArguments(event,
+ generate_to_json=True))
.Eblock('};')
)
return c
@@ -324,7 +325,7 @@ class HGenerator(object):
cpp_util.Classname(prop.name)))
return c
- def _GenerateCreateCallbackArguments(self, function):
+ def _GenerateCreateCallbackArguments(self, function, generate_to_json=False):
"""Generates functions for passing paramaters to a callback.
"""
c = Code()
@@ -341,6 +342,8 @@ class HGenerator(object):
param, self._cpp_type_generator.GetType(param)))
c.Append('scoped_ptr<base::ListValue> Create(%s);' %
', '.join(declaration_list))
+ if generate_to_json:
+ c.Append('std::string ToJson(%s);' % ', '.join(declaration_list))
return c
def _GenerateFunctionResults(self, callback):
« no previous file with comments | « tools/json_schema_compiler/cpp_util.py ('k') | tools/json_schema_compiler/test/content_settings.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698