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

Side by Side Diff: lib/dom/scripts/generator.py

Issue 10789010: Do not treat callbacks with no handlers as interfaces. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « lib/dom/scripts/dartgenerator.py ('k') | lib/dom/scripts/systemfrog.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 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
3 # for details. All rights reserved. Use of this source code is governed by a 3 # for details. All rights reserved. Use of this source code is governed by a
4 # BSD-style license that can be found in the LICENSE file. 4 # BSD-style license that can be found in the LICENSE file.
5 5
6 """This module provides shared functionality for systems to generate 6 """This module provides shared functionality for systems to generate
7 Dart APIs from the IDL database.""" 7 Dart APIs from the IDL database."""
8 8
9 import copy 9 import copy
10 import re 10 import re
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 info.overloads = None 299 info.overloads = None
300 info.idl_args = idl_args 300 info.idl_args = idl_args
301 info.declared_name = name 301 info.declared_name = name
302 info.name = name 302 info.name = name
303 info.constructor_name = None 303 info.constructor_name = None
304 info.js_name = name 304 info.js_name = name
305 info.type_name = interface.id 305 info.type_name = interface.id
306 info.param_infos = args 306 info.param_infos = args
307 return info 307 return info
308 308
309
310 def RecognizeCallback(interface):
311 """Returns the info for the callback method if the interface smells like a
312 callback.
313 """
314 if 'Callback' not in interface.ext_attrs: return None
315 handlers = [op for op in interface.operations if op.id == 'handleEvent']
316 if not handlers: return None
317 if not (handlers == interface.operations): return None
318 return AnalyzeOperation(interface, handlers)
319
320 def IsDartListType(type): 309 def IsDartListType(type):
321 return type == 'List' or type.startswith('sequence<') 310 return type == 'List' or type.startswith('sequence<')
322 311
323 def IsDartCollectionType(type): 312 def IsDartCollectionType(type):
324 return IsDartListType(type) 313 return IsDartListType(type)
325 314
326 def FindMatchingAttribute(interface, attr1): 315 def FindMatchingAttribute(interface, attr1):
327 matches = [attr2 for attr2 in interface.attributes 316 matches = [attr2 for attr2 in interface.attributes
328 if attr1.id == attr2.id] 317 if attr1.id == attr2.id]
329 if matches: 318 if matches:
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 match = re.match(r'(?:sequence<(\w+)>|(\w+)\[\])$', type_name) 824 match = re.match(r'(?:sequence<(\w+)>|(\w+)\[\])$', type_name)
836 if match: 825 if match:
837 if type_name == 'DOMString[]': 826 if type_name == 'DOMString[]':
838 return DOMStringArrayTypeInfo(self.TypeInfo('DOMString')) 827 return DOMStringArrayTypeInfo(self.TypeInfo('DOMString'))
839 return SequenceIDLTypeInfo(type_name, self.TypeInfo(match.group(1) or matc h.group(2))) 828 return SequenceIDLTypeInfo(type_name, self.TypeInfo(match.group(1) or matc h.group(2)))
840 if not type_name in _idl_type_registry: 829 if not type_name in _idl_type_registry:
841 return InterfaceIDLTypeInfo(type_name, TypeData('Interface')) 830 return InterfaceIDLTypeInfo(type_name, TypeData('Interface'))
842 type_data = _idl_type_registry.get(type_name) 831 type_data = _idl_type_registry.get(type_name)
843 class_name = '%sIDLTypeInfo' % type_data.clazz 832 class_name = '%sIDLTypeInfo' % type_data.clazz
844 return globals()[class_name](type_name, type_data) 833 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « lib/dom/scripts/dartgenerator.py ('k') | lib/dom/scripts/systemfrog.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698