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 | 6 |
7 from json_parse import OrderedDict | 7 from json_parse import OrderedDict |
8 from memoize import memoize | 8 from memoize import memoize |
9 | 9 |
10 class ParseException(Exception): | 10 class ParseException(Exception): |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 self.unix_name = UnixName(self.name) | 64 self.unix_name = UnixName(self.name) |
65 self.source_file = source_file | 65 self.source_file = source_file |
66 self.source_file_dir, self.source_file_filename = os.path.split(source_file) | 66 self.source_file_dir, self.source_file_filename = os.path.split(source_file) |
67 self.parent = None | 67 self.parent = None |
68 self.platforms = _GetPlatforms(json) | 68 self.platforms = _GetPlatforms(json) |
69 toplevel_origin = Origin(from_client=True, from_json=True) | 69 toplevel_origin = Origin(from_client=True, from_json=True) |
70 self.types = _GetTypes(self, json, self, toplevel_origin) | 70 self.types = _GetTypes(self, json, self, toplevel_origin) |
71 self.functions = _GetFunctions(self, json, self) | 71 self.functions = _GetFunctions(self, json, self) |
72 self.events = _GetEvents(self, json, self) | 72 self.events = _GetEvents(self, json, self) |
73 self.properties = _GetProperties(self, json, self, toplevel_origin) | 73 self.properties = _GetProperties(self, json, self, toplevel_origin) |
74 self.compiler_options = (json.get('compiler_options', {}) | 74 if include_compiler_options: |
75 if include_compiler_options else {}) | 75 self.compiler_options = json.get('compiler_options', {}) |
| 76 else: |
| 77 self.compiler_options = {} |
76 self.documentation_options = json.get('documentation_options', {}) | 78 self.documentation_options = json.get('documentation_options', {}) |
77 | 79 |
78 class Origin(object): | 80 class Origin(object): |
79 """Stores the possible origin of model object as a pair of bools. These are: | 81 """Stores the possible origin of model object as a pair of bools. These are: |
80 | 82 |
81 |from_client| indicating that instances can originate from users of | 83 |from_client| indicating that instances can originate from users of |
82 generated code (for example, function results), or | 84 generated code (for example, function results), or |
83 |from_json| indicating that instances can originate from the JSON (for | 85 |from_json| indicating that instances can originate from the JSON (for |
84 example, function parameters) | 86 example, function parameters) |
85 | 87 |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 # Sanity check: platforms should not be an empty list. | 507 # Sanity check: platforms should not be an empty list. |
506 if not json['platforms']: | 508 if not json['platforms']: |
507 raise ValueError('"platforms" cannot be an empty list') | 509 raise ValueError('"platforms" cannot be an empty list') |
508 platforms = [] | 510 platforms = [] |
509 for platform_name in json['platforms']: | 511 for platform_name in json['platforms']: |
510 for platform_enum in _Enum.GetAll(Platforms): | 512 for platform_enum in _Enum.GetAll(Platforms): |
511 if platform_name == platform_enum.name: | 513 if platform_name == platform_enum.name: |
512 platforms.append(platform_enum) | 514 platforms.append(platform_enum) |
513 break | 515 break |
514 return platforms | 516 return platforms |
OLD | NEW |