| 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 os.path | 5 import os.path |
| 6 import re | 6 import re |
| 7 import copy | 7 import copy |
| 8 | 8 |
| 9 class Model(object): | 9 class Model(object): |
| 10 """Model of all namespaces that comprise an API. | 10 """Model of all namespaces that comprise an API. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 self.from_client = True | 83 self.from_client = True |
| 84 self.properties = {} | 84 self.properties = {} |
| 85 self.functions = {} | 85 self.functions = {} |
| 86 self.parent = parent | 86 self.parent = parent |
| 87 for function_json in json.get('functions', []): | 87 for function_json in json.get('functions', []): |
| 88 if not function_json.get('nocompile', False): | 88 if not function_json.get('nocompile', False): |
| 89 self.functions[function_json['name']] = Function(self, function_json) | 89 self.functions[function_json['name']] = Function(self, function_json) |
| 90 props = [] | 90 props = [] |
| 91 for prop_name, prop_json in json.get('properties', {}).items(): | 91 for prop_name, prop_json in json.get('properties', {}).items(): |
| 92 # TODO(calamity): support functions (callbacks) as properties. The model | 92 # TODO(calamity): support functions (callbacks) as properties. The model |
| 93 # doesn't support it yet because to h/cc generators don't -- this is | 93 # doesn't support it yet because the h/cc generators don't -- this is |
| 94 # because we'd need to hook it into a base::Callback or something. | 94 # because we'd need to hook it into a base::Callback or something. |
| 95 # | 95 # |
| 96 # However, pragmatically it's not necessary to support them anyway, since | 96 # However, pragmatically it's not necessary to support them anyway, since |
| 97 # the instances of functions-on-properties in the extension APIs are all | 97 # the instances of functions-on-properties in the extension APIs are all |
| 98 # handled in pure Javascript on the render process (and .: never reach | 98 # handled in pure Javascript on the render process (and .: never reach |
| 99 # C++ let alone the browser). | 99 # C++ let alone the browser). |
| 100 if prop_json.get('type') == 'function': | 100 if prop_json.get('type') == 'function': |
| 101 continue | 101 continue |
| 102 props.append(Property(self, prop_name, prop_json, | 102 props.append(Property(self, prop_name, prop_json, |
| 103 from_json=True, | 103 from_json=True, |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 """Returns the hierarchy of the given model entity.""" | 321 """Returns the hierarchy of the given model entity.""" |
| 322 hierarchy = [] | 322 hierarchy = [] |
| 323 while entity: | 323 while entity: |
| 324 try: | 324 try: |
| 325 hierarchy.append(entity.name) | 325 hierarchy.append(entity.name) |
| 326 except AttributeError: | 326 except AttributeError: |
| 327 hierarchy.append(repr(entity)) | 327 hierarchy.append(repr(entity)) |
| 328 entity = entity.parent | 328 entity = entity.parent |
| 329 hierarchy.reverse() | 329 hierarchy.reverse() |
| 330 return hierarchy | 330 return hierarchy |
| 331 | |
| OLD | NEW |