| 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 14 matching lines...) Expand all Loading... |
| 25 for value in node: | 25 for value in node: |
| 26 _RemoveKey(value, key, type_restriction) | 26 _RemoveKey(value, key, type_restriction) |
| 27 | 27 |
| 28 def _RemoveUnneededFields(schema): | 28 def _RemoveUnneededFields(schema): |
| 29 """Returns a copy of |schema| with fields that aren't necessary at runtime | 29 """Returns a copy of |schema| with fields that aren't necessary at runtime |
| 30 removed. | 30 removed. |
| 31 """ | 31 """ |
| 32 # Return a copy so that we don't pollute the global api object, which may be | 32 # Return a copy so that we don't pollute the global api object, which may be |
| 33 # used elsewhere. | 33 # used elsewhere. |
| 34 ret = copy.deepcopy(schema) | 34 ret = copy.deepcopy(schema) |
| 35 _RemoveKey(ret, "description", basestring) | 35 _RemoveKey(ret, 'description', basestring) |
| 36 _RemoveKey(ret, "compiler_options", dict) | 36 _RemoveKey(ret, 'compiler_options', dict) |
| 37 _RemoveKey(ret, "nodoc", bool) | 37 _RemoveKey(ret, 'nodoc', bool) |
| 38 _RemoveKey(ret, "noinline_doc", bool) | 38 _RemoveKey(ret, 'nocompile', bool) |
| 39 _RemoveKey(ret, 'noinline_doc', bool) |
| 40 _RemoveKey(ret, 'jsexterns', object) |
| 39 return ret | 41 return ret |
| 40 | 42 |
| 41 def _PrefixSchemaWithNamespace(schema): | 43 def _PrefixSchemaWithNamespace(schema): |
| 42 """Modifies |schema| in place to prefix all types and references with a | 44 """Modifies |schema| in place to prefix all types and references with a |
| 43 namespace, if they aren't already qualified. That is, in the tabs API, this | 45 namespace, if they aren't already qualified. That is, in the tabs API, this |
| 44 will turn type Tab into tabs.Tab, but will leave the fully-qualified | 46 will turn type Tab into tabs.Tab, but will leave the fully-qualified |
| 45 windows.Window as-is. | 47 windows.Window as-is. |
| 46 """ | 48 """ |
| 47 assert isinstance(schema, dict), "Schema is unexpected type" | 49 assert isinstance(schema, dict), "Schema is unexpected type" |
| 48 namespace = schema['namespace'] | 50 namespace = schema['namespace'] |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 c.Append() | 377 c.Append() |
| 376 c.Append('// static') | 378 c.Append('// static') |
| 377 c.Sblock('bool %s::IsGenerated(std::string name) {' % | 379 c.Sblock('bool %s::IsGenerated(std::string name) {' % |
| 378 self._bundle._GenerateBundleClass('GeneratedSchemas')) | 380 self._bundle._GenerateBundleClass('GeneratedSchemas')) |
| 379 c.Append('return g_lazy_instance.Get().schemas.count(name) > 0;') | 381 c.Append('return g_lazy_instance.Get().schemas.count(name) > 0;') |
| 380 c.Eblock('}') | 382 c.Eblock('}') |
| 381 c.Append() | 383 c.Append() |
| 382 c.Concat(cpp_util.CloseNamespace(self._bundle._cpp_namespace)) | 384 c.Concat(cpp_util.CloseNamespace(self._bundle._cpp_namespace)) |
| 383 c.Append() | 385 c.Append() |
| 384 return c | 386 return c |
| OLD | NEW |