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 import code | 5 import code |
6 import cpp_util | 6 import cpp_util |
7 from model import Platforms | 7 from model import Platforms |
8 from schema_util import CapitalizeFirstLetter | 8 from schema_util import CapitalizeFirstLetter |
9 from schema_util import JsFunctionNameToClassName | 9 from schema_util import JsFunctionNameToClassName |
10 | 10 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 class _APIHGenerator(object): | 156 class _APIHGenerator(object): |
157 """Generates the header for API registration / declaration""" | 157 """Generates the header for API registration / declaration""" |
158 def __init__(self, cpp_bundle): | 158 def __init__(self, cpp_bundle): |
159 self._bundle = cpp_bundle | 159 self._bundle = cpp_bundle |
160 | 160 |
161 def Generate(self, _): # namespace not relevant, this is a bundle | 161 def Generate(self, _): # namespace not relevant, this is a bundle |
162 c = code.Code() | 162 c = code.Code() |
163 | 163 |
164 c.Append('#include <string>') | 164 c.Append('#include <string>') |
165 c.Append() | 165 c.Append() |
166 c.Append('#include "base/basictypes.h"') | |
167 c.Append() | |
168 c.Append("class ExtensionFunctionRegistry;") | 166 c.Append("class ExtensionFunctionRegistry;") |
169 c.Append() | 167 c.Append() |
170 c.Concat(cpp_util.OpenNamespace(self._bundle._cpp_namespace)) | 168 c.Concat(cpp_util.OpenNamespace(self._bundle._cpp_namespace)) |
171 c.Append() | 169 c.Append() |
172 c.Append('class %s {' % | 170 c.Append('class %s {' % |
173 self._bundle._GenerateBundleClass('GeneratedFunctionRegistry')) | 171 self._bundle._GenerateBundleClass('GeneratedFunctionRegistry')) |
174 c.Sblock(' public:') | 172 c.Sblock(' public:') |
175 c.Append('static void RegisterAll(' | 173 c.Append('static void RegisterAll(' |
176 'ExtensionFunctionRegistry* registry);') | 174 'ExtensionFunctionRegistry* registry);') |
177 c.Eblock('};') | 175 c.Eblock('};') |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 c.Append() | 322 c.Append() |
325 c.Append('// static') | 323 c.Append('// static') |
326 c.Sblock('bool %s::IsGenerated(std::string name) {' % | 324 c.Sblock('bool %s::IsGenerated(std::string name) {' % |
327 self._bundle._GenerateBundleClass('GeneratedSchemas')) | 325 self._bundle._GenerateBundleClass('GeneratedSchemas')) |
328 c.Append('return g_lazy_instance.Get().schemas.count(name) > 0;') | 326 c.Append('return g_lazy_instance.Get().schemas.count(name) > 0;') |
329 c.Eblock('}') | 327 c.Eblock('}') |
330 c.Append() | 328 c.Append() |
331 c.Concat(cpp_util.CloseNamespace(self._bundle._cpp_namespace)) | 329 c.Concat(cpp_util.CloseNamespace(self._bundle._cpp_namespace)) |
332 c.Append() | 330 c.Append() |
333 return c | 331 return c |
OLD | NEW |