OLD | NEW |
---|---|
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 from code import Code | 5 from code import Code |
6 from model import PropertyType | 6 from model import PropertyType |
7 import cpp_util | 7 import cpp_util |
8 import schema_util | 8 import schema_util |
9 | 9 |
10 class HGenerator(object): | 10 class HGenerator(object): |
(...skipping 17 matching lines...) Expand all Loading... | |
28 | 28 |
29 ifndef_name = cpp_util.GenerateIfndefName(self._namespace.source_file_dir, | 29 ifndef_name = cpp_util.GenerateIfndefName(self._namespace.source_file_dir, |
30 self._target_namespace) | 30 self._target_namespace) |
31 (c.Append('#ifndef %s' % ifndef_name) | 31 (c.Append('#ifndef %s' % ifndef_name) |
32 .Append('#define %s' % ifndef_name) | 32 .Append('#define %s' % ifndef_name) |
33 .Append() | 33 .Append() |
34 .Append('#include <string>') | 34 .Append('#include <string>') |
35 .Append('#include <vector>') | 35 .Append('#include <vector>') |
36 .Append() | 36 .Append() |
37 .Append('#include "base/basictypes.h"') | 37 .Append('#include "base/basictypes.h"') |
38 .Append('#include "base/json/json_writer.h"') | |
not at google - send to devlin
2012/07/24 23:04:29
this should go in the cc file not the header file.
mitchellwrosen
2012/07/25 17:08:20
Done.
| |
38 .Append('#include "base/logging.h"') | 39 .Append('#include "base/logging.h"') |
39 .Append('#include "base/memory/linked_ptr.h"') | 40 .Append('#include "base/memory/linked_ptr.h"') |
40 .Append('#include "base/memory/scoped_ptr.h"') | 41 .Append('#include "base/memory/scoped_ptr.h"') |
41 .Append('#include "base/values.h"') | 42 .Append('#include "base/values.h"') |
42 .Append('#include "tools/json_schema_compiler/any.h"') | 43 .Append('#include "tools/json_schema_compiler/any.h"') |
43 .Append() | 44 .Append() |
44 ) | 45 ) |
45 | 46 |
46 c.Concat(self._cpp_type_generator.GetRootNamespaceStart()) | 47 c.Concat(self._cpp_type_generator.GetRootNamespaceStart()) |
47 # TODO(calamity): These forward declarations should be #includes to allow | 48 # TODO(calamity): These forward declarations should be #includes to allow |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 param_lists = self._cpp_type_generator.GetAllPossibleParameterLists(params) | 334 param_lists = self._cpp_type_generator.GetAllPossibleParameterLists(params) |
334 for param_list in param_lists: | 335 for param_list in param_lists: |
335 declaration_list = [] | 336 declaration_list = [] |
336 for param in param_list: | 337 for param in param_list: |
337 if param.description: | 338 if param.description: |
338 c.Comment(param.description) | 339 c.Comment(param.description) |
339 declaration_list.append('const %s' % cpp_util.GetParameterDeclaration( | 340 declaration_list.append('const %s' % cpp_util.GetParameterDeclaration( |
340 param, self._cpp_type_generator.GetType(param))) | 341 param, self._cpp_type_generator.GetType(param))) |
341 c.Append('scoped_ptr<base::ListValue> Create(%s);' % | 342 c.Append('scoped_ptr<base::ListValue> Create(%s);' % |
342 ', '.join(declaration_list)) | 343 ', '.join(declaration_list)) |
344 c.Append('scoped_ptr<std::string> ToJson(%s);' % | |
not at google - send to devlin
2012/07/24 23:04:29
ditto, only return std::string, and only generate
mitchellwrosen
2012/07/25 17:08:20
Done.
| |
345 ', '.join(declaration_list)) | |
343 return c | 346 return c |
344 | 347 |
345 def _GenerateFunctionResults(self, callback): | 348 def _GenerateFunctionResults(self, callback): |
346 """Generates namespace for passing a function's result back. | 349 """Generates namespace for passing a function's result back. |
347 """ | 350 """ |
348 c = Code() | 351 c = Code() |
349 (c.Sblock('namespace Results {') | 352 (c.Sblock('namespace Results {') |
350 .Concat(self._GenerateCreateCallbackArguments(callback)) | 353 .Concat(self._GenerateCreateCallbackArguments(callback)) |
351 .Eblock('};') | 354 .Eblock('};') |
352 ) | 355 ) |
353 return c | 356 return c |
OLD | NEW |