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 class ParseException(Exception): | 9 class ParseException(Exception): |
10 """Thrown when data in the model is invalid. | 10 """Thrown when data in the model is invalid. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 | 104 |
105 class Callback(object): | 105 class Callback(object): |
106 """A callback parameter to a Function. | 106 """A callback parameter to a Function. |
107 | 107 |
108 Properties: | 108 Properties: |
109 - |params| the parameters to this callback. | 109 - |params| the parameters to this callback. |
110 """ | 110 """ |
111 def __init__(self, parent, json): | 111 def __init__(self, parent, json): |
112 params = json['parameters'] | 112 params = json['parameters'] |
113 self.parent = parent | 113 self.parent = parent |
114 self.optional = False | 114 self.description = json.get('description') |
115 if 'optional' in json: | 115 self.optional = json.get('optional', False) |
116 self.optional = json['optional'] == True | |
117 self.params = [] | 116 self.params = [] |
118 if len(params) == 0: | 117 if len(params) == 0: |
119 return | 118 return |
120 elif len(params) == 1: | 119 elif len(params) == 1: |
121 param = params[0] | 120 param = params[0] |
122 self.params.append(Property(self, param['name'], param, | 121 self.params.append(Property(self, param['name'], param, |
123 from_client=True)) | 122 from_client=True)) |
124 else: | 123 else: |
125 raise ParseException( | 124 raise ParseException( |
126 self, | 125 self, |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 - |from_json| indicates that instances of the Type can originate from the | 176 - |from_json| indicates that instances of the Type can originate from the |
178 JSON (as described by the schema), such as top-level types and function | 177 JSON (as described by the schema), such as top-level types and function |
179 parameters | 178 parameters |
180 - |from_client| indicates that instances of the Type can originate from the | 179 - |from_client| indicates that instances of the Type can originate from the |
181 users of generated code, such as top-level types and function results | 180 users of generated code, such as top-level types and function results |
182 """ | 181 """ |
183 self.name = name | 182 self.name = name |
184 self._unix_name = UnixName(self.name) | 183 self._unix_name = UnixName(self.name) |
185 self._unix_name_used = False | 184 self._unix_name_used = False |
186 self.optional = json.get('optional', False) | 185 self.optional = json.get('optional', False) |
186 self.value = json.get('value') | |
not at google - send to devlin
2012/07/09 11:01:20
We're already doing this below :)
cduvall
2012/07/09 17:50:40
Done.
| |
187 self.functions = [] | |
187 self.has_value = False | 188 self.has_value = False |
188 self.description = json.get('description') | 189 self.description = json.get('description') |
189 self.parent = parent | 190 self.parent = parent |
190 _AddProperties(self, json) | 191 _AddProperties(self, json) |
191 if is_additional_properties: | 192 if is_additional_properties: |
192 self.type_ = PropertyType.ADDITIONAL_PROPERTIES | 193 self.type_ = PropertyType.ADDITIONAL_PROPERTIES |
193 elif '$ref' in json: | 194 elif '$ref' in json: |
194 self.ref_type = json['$ref'] | 195 self.ref_type = json['$ref'] |
195 self.type_ = PropertyType.REF | 196 self.type_ = PropertyType.REF |
196 elif 'enum' in json: | 197 elif 'enum' in json: |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
364 # handled in pure Javascript on the render process (and .: never reach | 365 # handled in pure Javascript on the render process (and .: never reach |
365 # C++ let alone the browser). | 366 # C++ let alone the browser). |
366 if property_json.get('type') == 'function': | 367 if property_json.get('type') == 'function': |
367 continue | 368 continue |
368 model.properties[name] = Property( | 369 model.properties[name] = Property( |
369 model, | 370 model, |
370 name, | 371 name, |
371 property_json, | 372 property_json, |
372 from_json=from_json, | 373 from_json=from_json, |
373 from_client=from_client) | 374 from_client=from_client) |
OLD | NEW |