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 copy | 5 import copy |
6 import os.path | 6 import os.path |
7 import re | 7 import re |
8 | 8 |
9 from json_parse import OrderedDict | 9 from json_parse import OrderedDict |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... | |
33 source_file, | 33 source_file, |
34 include_compiler_options=include_compiler_options) | 34 include_compiler_options=include_compiler_options) |
35 self.namespaces[namespace.name] = namespace | 35 self.namespaces[namespace.name] = namespace |
36 return namespace | 36 return namespace |
37 | 37 |
38 class Namespace(object): | 38 class Namespace(object): |
39 """An API namespace. | 39 """An API namespace. |
40 | 40 |
41 Properties: | 41 Properties: |
42 - |name| the name of the namespace | 42 - |name| the name of the namespace |
43 - |description| the description of the namespace | |
44 - |availability| describes when the namespace first became available | |
43 - |unix_name| the unix_name of the namespace | 45 - |unix_name| the unix_name of the namespace |
44 - |source_file| the file that contained the namespace definition | 46 - |source_file| the file that contained the namespace definition |
45 - |source_file_dir| the directory component of |source_file| | 47 - |source_file_dir| the directory component of |source_file| |
46 - |source_file_filename| the filename component of |source_file| | 48 - |source_file_filename| the filename component of |source_file| |
47 - |platforms| if not None, the list of platforms that the namespace is | 49 - |platforms| if not None, the list of platforms that the namespace is |
48 available to | 50 available to |
49 - |types| a map of type names to their model.Type | 51 - |types| a map of type names to their model.Type |
50 - |functions| a map of function names to their model.Function | 52 - |functions| a map of function names to their model.Function |
51 - |events| a map of event names to their model.Function | 53 - |events| a map of event names to their model.Function |
52 - |properties| a map of property names to their model.Property | 54 - |properties| a map of property names to their model.Property |
53 - |compiler_options| the compiler_options dict, only present if | 55 - |compiler_options| the compiler_options dict, only present if |
54 |include_compiler_options| is True | 56 |include_compiler_options| is True |
55 """ | 57 """ |
56 def __init__(self, json, source_file, include_compiler_options=False): | 58 def __init__(self, json, source_file, include_compiler_options=False): |
57 self.name = json['namespace'] | 59 self.name = json['namespace'] |
60 self.description = json.get('description', None) | |
61 self.availability = json.get('availability', None) | |
not at google - send to devlin
2013/04/04 05:19:23
see comment in idl_schema about this.
| |
58 self.unix_name = UnixName(self.name) | 62 self.unix_name = UnixName(self.name) |
59 self.source_file = source_file | 63 self.source_file = source_file |
60 self.source_file_dir, self.source_file_filename = os.path.split(source_file) | 64 self.source_file_dir, self.source_file_filename = os.path.split(source_file) |
61 self.parent = None | 65 self.parent = None |
62 self.platforms = _GetPlatforms(json) | 66 self.platforms = _GetPlatforms(json) |
63 toplevel_origin = Origin(from_client=True, from_json=True) | 67 toplevel_origin = Origin(from_client=True, from_json=True) |
64 self.types = _GetTypes(self, json, self, toplevel_origin) | 68 self.types = _GetTypes(self, json, self, toplevel_origin) |
65 self.functions = _GetFunctions(self, json, self) | 69 self.functions = _GetFunctions(self, json, self) |
66 self.events = _GetEvents(self, json, self) | 70 self.events = _GetEvents(self, json, self) |
67 self.properties = _GetProperties(self, json, self, toplevel_origin) | 71 self.properties = _GetProperties(self, json, self, toplevel_origin) |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
458 def _GetPlatforms(json): | 462 def _GetPlatforms(json): |
459 if 'platforms' not in json: | 463 if 'platforms' not in json: |
460 return None | 464 return None |
461 platforms = [] | 465 platforms = [] |
462 for platform_name in json['platforms']: | 466 for platform_name in json['platforms']: |
463 for platform_enum in _Enum.GetAll(Platforms): | 467 for platform_enum in _Enum.GetAll(Platforms): |
464 if platform_name == platform_enum.name: | 468 if platform_name == platform_enum.name: |
465 platforms.append(platform_enum) | 469 platforms.append(platform_enum) |
466 break | 470 break |
467 return platforms | 471 return platforms |
OLD | NEW |