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

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

Issue 271543006: Fix DataTransfer object for Drag and Drop in Chrome 35. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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 | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | no next file » | 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 json 10 import json
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 'ChannelMergerNode': 'ChannelMergerNode,AudioChannelMerger', 112 'ChannelMergerNode': 'ChannelMergerNode,AudioChannelMerger',
113 'ChannelSplitterNode': 'ChannelSplitterNode,AudioChannelSplitter', 113 'ChannelSplitterNode': 'ChannelSplitterNode,AudioChannelSplitter',
114 114
115 'ClientRect': 'ClientRect,DOMRect', 115 'ClientRect': 'ClientRect,DOMRect',
116 116
117 'CSSStyleDeclaration': 117 'CSSStyleDeclaration':
118 # IE Firefox 118 # IE Firefox
119 'CSSStyleDeclaration,MSStyleCSSProperties,CSS2Properties', 119 'CSSStyleDeclaration,MSStyleCSSProperties,CSS2Properties',
120 120
121 'Clipboard': 'Clipboard,DataTransfer',
122
121 'ApplicationCache': 123 'ApplicationCache':
122 'ApplicationCache,DOMApplicationCache,OfflineResourceList', 124 'ApplicationCache,DOMApplicationCache,OfflineResourceList',
123 125
124 'HTMLTableCellElement': 126 'HTMLTableCellElement':
125 'HTMLTableCellElement,HTMLTableDataCellElement,HTMLTableHeaderCellElemen t', 127 'HTMLTableCellElement,HTMLTableDataCellElement,HTMLTableHeaderCellElemen t',
126 128
127 'GainNode': 'GainNode,AudioGainNode', 129 'GainNode': 'GainNode,AudioGainNode',
128 130
129 'IDBOpenDBRequest': 131 'IDBOpenDBRequest':
130 'IDBOpenDBRequest,IDBVersionChangeRequest', 132 'IDBOpenDBRequest,IDBVersionChangeRequest',
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 self.factory_parameters = None 417 self.factory_parameters = None
416 418
417 def ParametersAsDecVarLists(self, rename_type, force_optional=False): 419 def ParametersAsDecVarLists(self, rename_type, force_optional=False):
418 """ Returns a tuple (required, optional, named), where: 420 """ Returns a tuple (required, optional, named), where:
419 required is a list of parameter declarations corresponding to the 421 required is a list of parameter declarations corresponding to the
420 required parameters 422 required parameters
421 optional is a list of parameter declarations corresponding to the 423 optional is a list of parameter declarations corresponding to the
422 optional parameters 424 optional parameters
423 named is a boolean which is true if the optional parameters should 425 named is a boolean which is true if the optional parameters should
424 be named 426 be named
425 A parameter declaration is a tuple (dec, var) where var is the 427 A parameter declaration is a tuple (dec, var) where var is the
426 variable name, and dec is a string suitable for declaring the 428 variable name, and dec is a string suitable for declaring the
427 variable in a parameter list. That is, dec + var is a valid 429 variable in a parameter list. That is, dec + var is a valid
428 parameter declaration. 430 parameter declaration.
429 """ 431 """
430 def FormatParam(param): 432 def FormatParam(param):
431 dart_type = rename_type(param.type_id) if param.type_id else 'dynamic' 433 dart_type = rename_type(param.type_id) if param.type_id else 'dynamic'
432 return (TypeOrNothing(dart_type, param.type_id), param.name) 434 return (TypeOrNothing(dart_type, param.type_id), param.name)
433 required = [] 435 required = []
434 optional = [] 436 optional = []
435 for param_info in self.param_infos: 437 for param_info in self.param_infos:
436 if param_info.is_optional: 438 if param_info.is_optional:
437 optional.append(FormatParam(param_info)) 439 optional.append(FormatParam(param_info))
438 else: 440 else:
439 if optional: 441 if optional:
440 raise Exception('Optional parameters cannot precede required ones: ' 442 raise Exception('Optional parameters cannot precede required ones: '
441 + str(params)) 443 + str(params))
442 required.append(FormatParam(param_info)) 444 required.append(FormatParam(param_info))
443 needs_named = optional and self.requires_named_arguments and not force_optio nal 445 needs_named = optional and self.requires_named_arguments and not force_optio nal
444 return (required, optional, needs_named) 446 return (required, optional, needs_named)
445 447
446 def ParametersAsDecStringList(self, rename_type, force_optional=False): 448 def ParametersAsDecStringList(self, rename_type, force_optional=False):
447 """Returns a list of strings where each string corresponds to a parameter 449 """Returns a list of strings where each string corresponds to a parameter
448 declaration. All of the optional/named parameters if any will appear as 450 declaration. All of the optional/named parameters if any will appear as
449 a single entry at the end of the list. 451 a single entry at the end of the list.
450 """ 452 """
451 (required, optional, needs_named) = \ 453 (required, optional, needs_named) = \
452 self.ParametersAsDecVarLists(rename_type, force_optional) 454 self.ParametersAsDecVarLists(rename_type, force_optional)
453 def FormatParam(dec): 455 def FormatParam(dec):
454 return dec[0] + dec[1] 456 return dec[0] + dec[1]
455 argtexts = map(FormatParam, required) 457 argtexts = map(FormatParam, required)
456 if optional: 458 if optional:
457 left_bracket, right_bracket = '{}' if needs_named else '[]' 459 left_bracket, right_bracket = '{}' if needs_named else '[]'
458 argtexts.append( 460 argtexts.append(
459 left_bracket + 461 left_bracket +
460 ', '.join(map(FormatParam, optional)) + 462 ', '.join(map(FormatParam, optional)) +
461 right_bracket) 463 right_bracket)
462 return argtexts 464 return argtexts
463 465
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1311 if type_data.clazz == 'BasicTypedList': 1313 if type_data.clazz == 'BasicTypedList':
1312 if type_name == 'ArrayBuffer': 1314 if type_name == 'ArrayBuffer':
1313 dart_interface_name = 'ByteBuffer' 1315 dart_interface_name = 'ByteBuffer'
1314 else: 1316 else:
1315 dart_interface_name = self._renamer.RenameInterfaceId(type_name) 1317 dart_interface_name = self._renamer.RenameInterfaceId(type_name)
1316 return BasicTypedListIDLTypeInfo( 1318 return BasicTypedListIDLTypeInfo(
1317 type_name, type_data, dart_interface_name, self) 1319 type_name, type_data, dart_interface_name, self)
1318 1320
1319 class_name = '%sIDLTypeInfo' % type_data.clazz 1321 class_name = '%sIDLTypeInfo' % type_data.clazz
1320 return globals()[class_name](type_name, type_data) 1322 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « sdk/lib/html/dart2js/html_dart2js.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698