Chromium Code Reviews| 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 8cea17b588af55ed93f5df205ca5076d9bf6080d..8e1881d0a67e272e48dbd26c234183fb00755128 100644 |
| --- a/tools/json_schema_compiler/cc_generator.py |
| +++ b/tools/json_schema_compiler/cc_generator.py |
| @@ -680,7 +680,8 @@ class CCGenerator(object): |
| return c |
| def _GenerateCreateCallbackArguments(self, function_scope, callback): |
| - """Generate all functions to create Value parameters for a callback. |
| + """Generate all functions to create Value parameters for a callback, and |
| + JSON from the Value. |
|
not at google - send to devlin
2012/07/24 23:04:29
We should only generate these for events, not func
mitchellwrosen
2012/07/25 17:08:20
Done.
|
| E.g for function "Bar", generate Bar::Results::Create |
| E.g for event "Baz", generate Baz::Create |
| @@ -714,9 +715,21 @@ class CCGenerator(object): |
| c.Append('return create_results.Pass();') |
| c.Eblock('}') |
| + c.Append() |
| + (c.Sblock('scoped_ptr<std::string> %(function_scope)s::' |
|
not at google - send to devlin
2012/07/24 23:04:29
as I mentioned in the bug, only need to return a s
mitchellwrosen
2012/07/25 17:08:20
Done.
|
| + 'ToJson(%(declaration_list)s) {') |
| + .Append('scoped_ptr<base::ListValue> create_results = ' |
| + 'Create(%(param_list)s);') |
| + .Append('scoped_ptr<std::string> json(new std::string());') |
| + .Append('base::JSONWriter::Write(create_results.get(), json.get());') |
| + .Append('return json.Pass();') |
| + ) |
| + c.Eblock('}') |
| + |
| c.Substitute({ |
| 'function_scope': function_scope, |
| - 'declaration_list': ', '.join(declaration_list) |
| + 'declaration_list': ', '.join(declaration_list), |
| + 'param_list': ', '.join([param.unix_name for param in param_list]) |
| }) |
| return c |