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

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

Issue 13843029: WebKit IDL roll. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | « tools/dom/idl/dart/dart.idl ('k') | tools/dom/scripts/idlsync.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 json 10 import json
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 # Given a list of overloaded arguments, render dart arguments. 142 # Given a list of overloaded arguments, render dart arguments.
143 def _BuildArguments(args, interface, constructor=False): 143 def _BuildArguments(args, interface, constructor=False):
144 def IsOptional(argument): 144 def IsOptional(argument):
145 if 'Callback' in argument.ext_attrs: 145 if 'Callback' in argument.ext_attrs:
146 # Optional callbacks arguments are treated as optional arguments. 146 # Optional callbacks arguments are treated as optional arguments.
147 return argument.optional 147 return argument.optional
148 if constructor: 148 if constructor:
149 # FIXME: Optional constructors arguments should not be treated as 149 # FIXME: Optional constructors arguments should not be treated as
150 # optional arguments. 150 # optional arguments.
151 return argument.optional 151 return argument.optional
152 if 'ForceOptional' in argument.ext_attrs:
153 return True
152 return False 154 return False
153 155
154 # Given a list of overloaded arguments, choose a suitable name. 156 # Given a list of overloaded arguments, choose a suitable name.
155 def OverloadedName(args): 157 def OverloadedName(args):
156 return '_OR_'.join(sorted(set(arg.id for arg in args))) 158 return '_OR_'.join(sorted(set(arg.id for arg in args)))
157 159
158 def DartType(idl_type_name): 160 def DartType(idl_type_name):
159 if idl_type_name in _idl_type_registry: 161 if idl_type_name in _idl_type_registry:
160 return _idl_type_registry[idl_type_name].dart_type or idl_type_name 162 return _idl_type_registry[idl_type_name].dart_type or idl_type_name
161 return idl_type_name 163 return idl_type_name
(...skipping 13 matching lines...) Expand all
175 is_optional = is_optional or any(arg is None or IsOptional(arg) for arg in a rg_tuple) 177 is_optional = is_optional or any(arg is None or IsOptional(arg) for arg in a rg_tuple)
176 178
177 filtered = filter(None, arg_tuple) 179 filtered = filter(None, arg_tuple)
178 type_id = OverloadedType(filtered) 180 type_id = OverloadedType(filtered)
179 name = OverloadedName(filtered) 181 name = OverloadedName(filtered)
180 result.append(ParamInfo(name, type_id, is_optional)) 182 result.append(ParamInfo(name, type_id, is_optional))
181 183
182 return result 184 return result
183 185
184 def IsOptional(argument): 186 def IsOptional(argument):
185 return argument.optional and ('Default' not in argument.ext_attrs) 187 return argument.optional and ('Default' not in argument.ext_attrs)\
188 or 'ForceOptional' in argument.ext_attrs
186 189
187 def AnalyzeOperation(interface, operations): 190 def AnalyzeOperation(interface, operations):
188 """Makes operation calling convention decision for a set of overloads. 191 """Makes operation calling convention decision for a set of overloads.
189 192
190 Returns: An OperationInfo object. 193 Returns: An OperationInfo object.
191 """ 194 """
192 195
193 # split operations with optional args into multiple operations 196 # split operations with optional args into multiple operations
194 split_operations = [] 197 split_operations = []
195 for operation in operations: 198 for operation in operations:
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 type_name, type_data, dart_interface_name, self) 1589 type_name, type_data, dart_interface_name, self)
1587 1590
1588 if type_data.clazz == 'BasicTypedList': 1591 if type_data.clazz == 'BasicTypedList':
1589 dart_interface_name = self._renamer.RenameInterface( 1592 dart_interface_name = self._renamer.RenameInterface(
1590 self._database.GetInterface(type_name)) 1593 self._database.GetInterface(type_name))
1591 return BasicTypedListIDLTypeInfo( 1594 return BasicTypedListIDLTypeInfo(
1592 type_name, type_data, dart_interface_name, self) 1595 type_name, type_data, dart_interface_name, self)
1593 1596
1594 class_name = '%sIDLTypeInfo' % type_data.clazz 1597 class_name = '%sIDLTypeInfo' % type_data.clazz
1595 return globals()[class_name](type_name, type_data) 1598 return globals()[class_name](type_name, type_data)
OLDNEW
« no previous file with comments | « tools/dom/idl/dart/dart.idl ('k') | tools/dom/scripts/idlsync.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698