Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: tools/json_schema_compiler/model.py

Issue 2650733002: Revert of Update json_schema_compiler to handle the Automation extension API (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/json_schema_compiler/js_util.py ('k') | ui/accessibility/PRESUBMIT.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 parent, 176 parent,
177 name, 177 name,
178 json, 178 json,
179 namespace, 179 namespace,
180 origin): 180 origin):
181 self.name = name 181 self.name = name
182 self.namespace = namespace 182 self.namespace = namespace
183 self.simple_name = _StripNamespace(self.name, namespace) 183 self.simple_name = _StripNamespace(self.name, namespace)
184 self.unix_name = UnixName(self.name) 184 self.unix_name = UnixName(self.name)
185 self.description = json.get('description', None) 185 self.description = json.get('description', None)
186 self.jsexterns = json.get('jsexterns', None)
187 self.origin = origin 186 self.origin = origin
188 self.parent = parent 187 self.parent = parent
189 self.instance_of = json.get('isInstanceOf', None) 188 self.instance_of = json.get('isInstanceOf', None)
190 189
191 # TODO(kalman): Only objects need functions/events/properties, but callers 190 # TODO(kalman): Only objects need functions/events/properties, but callers
192 # assume that all types have them. Fix this. 191 # assume that all types have them. Fix this.
193 self.functions = _GetFunctions(self, json, namespace) 192 self.functions = _GetFunctions(self, json, namespace)
194 self.events = _GetEvents(self, json, namespace) 193 self.events = _GetEvents(self, json, namespace)
195 self.properties = _GetProperties(self, json, namespace, origin) 194 self.properties = _GetProperties(self, json, namespace, origin)
196 195
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 self.supports_listeners = options.get('supportsListeners', True) 310 self.supports_listeners = options.get('supportsListeners', True)
312 self.supports_rules = options.get('supportsRules', False) 311 self.supports_rules = options.get('supportsRules', False)
313 self.supports_dom = options.get('supportsDom', False) 312 self.supports_dom = options.get('supportsDom', False)
314 313
315 def GeneratePropertyFromParam(p): 314 def GeneratePropertyFromParam(p):
316 return Property(self, p['name'], p, namespace, origin) 315 return Property(self, p['name'], p, namespace, origin)
317 316
318 self.filters = [GeneratePropertyFromParam(filter_instance) 317 self.filters = [GeneratePropertyFromParam(filter_instance)
319 for filter_instance in json.get('filters', [])] 318 for filter_instance in json.get('filters', [])]
320 callback_param = None 319 callback_param = None
321 params = json.get('parameters', []) 320 for param in json.get('parameters', []):
322 for i, param in enumerate(params): 321 if param.get('type') == 'function':
323 if param.get('type') == 'function' and i == len(params) - 1:
324 if callback_param: 322 if callback_param:
325 # No ParseException because the webstore has this. 323 # No ParseException because the webstore has this.
326 # Instead, pretend all intermediate callbacks are properties. 324 # Instead, pretend all intermediate callbacks are properties.
327 self.params.append(GeneratePropertyFromParam(callback_param)) 325 self.params.append(GeneratePropertyFromParam(callback_param))
328 callback_param = param 326 callback_param = param
329 else: 327 else:
330 self.params.append(GeneratePropertyFromParam(param)) 328 self.params.append(GeneratePropertyFromParam(param))
331 329
332 if callback_param: 330 if callback_param:
333 self.callback = Function(self, 331 self.callback = Function(self,
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 # Sanity check: platforms should not be an empty list. 608 # Sanity check: platforms should not be an empty list.
611 if not json['platforms']: 609 if not json['platforms']:
612 raise ValueError('"platforms" cannot be an empty list') 610 raise ValueError('"platforms" cannot be an empty list')
613 platforms = [] 611 platforms = []
614 for platform_name in json['platforms']: 612 for platform_name in json['platforms']:
615 for platform_enum in _Enum.GetAll(Platforms): 613 for platform_enum in _Enum.GetAll(Platforms):
616 if platform_name == platform_enum.name: 614 if platform_name == platform_enum.name:
617 platforms.append(platform_enum) 615 platforms.append(platform_enum)
618 break 616 break
619 return platforms 617 return platforms
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/js_util.py ('k') | ui/accessibility/PRESUBMIT.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698