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

Side by Side Diff: third_party/WebKit/Source/bindings/scripts/idl_definitions.py

Issue 1381413003: [bindings] add support for integer-indexed @@iterator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 self.attributes = [] 279 self.attributes = []
280 self.constants = [] 280 self.constants = []
281 self.constructors = [] 281 self.constructors = []
282 self.custom_constructors = [] 282 self.custom_constructors = []
283 self.extended_attributes = {} 283 self.extended_attributes = {}
284 self.operations = [] 284 self.operations = []
285 self.parent = None 285 self.parent = None
286 self.serializer = None 286 self.serializer = None
287 self.stringifier = None 287 self.stringifier = None
288 self.iterable = None 288 self.iterable = None
289 self.has_indexed_elements = False
289 self.maplike = None 290 self.maplike = None
290 self.setlike = None 291 self.setlike = None
291 self.original_interface = None 292 self.original_interface = None
292 self.partial_interfaces = [] 293 self.partial_interfaces = []
293 if not node: # Early exit for IdlException.__init__ 294 if not node: # Early exit for IdlException.__init__
294 return 295 return
295 296
296 self.is_callback = bool(node.GetProperty('CALLBACK')) 297 self.is_callback = bool(node.GetProperty('CALLBACK'))
297 self.is_exception = False 298 self.is_exception = False
298 # FIXME: uppercase 'Partial' => 'PARTIAL' in base IDL parser 299 # FIXME: uppercase 'Partial' => 'PARTIAL' in base IDL parser
299 self.is_partial = bool(node.GetProperty('Partial')) 300 self.is_partial = bool(node.GetProperty('Partial'))
300 self.idl_name = idl_name 301 self.idl_name = idl_name
301 self.name = node.GetName() 302 self.name = node.GetName()
302 self.idl_type = IdlType(self.name) 303 self.idl_type = IdlType(self.name)
303 304
305 has_indexed_property_getter = False
306 has_integer_typed_length = False
307
304 children = node.GetChildren() 308 children = node.GetChildren()
305 for child in children: 309 for child in children:
306 child_class = child.GetClass() 310 child_class = child.GetClass()
307 if child_class == 'Attribute': 311 if child_class == 'Attribute':
308 self.attributes.append(IdlAttribute(idl_name, child)) 312 attr = IdlAttribute(idl_name, child)
313 if attr.idl_type.is_integer_type:
Jens Widell 2015/10/05 05:57:11 Shouldn't we also check that the name is 'length'
caitp (gmail) 2015/10/05 11:30:23 Yes, good catch. Done
314 has_integer_typed_length = True
315 self.attributes.append(attr)
309 elif child_class == 'Const': 316 elif child_class == 'Const':
310 self.constants.append(IdlConstant(idl_name, child)) 317 self.constants.append(IdlConstant(idl_name, child))
311 elif child_class == 'ExtAttributes': 318 elif child_class == 'ExtAttributes':
312 extended_attributes = ext_attributes_node_to_extended_attributes (idl_name, child) 319 extended_attributes = ext_attributes_node_to_extended_attributes (idl_name, child)
313 self.constructors, self.custom_constructors = ( 320 self.constructors, self.custom_constructors = (
314 extended_attributes_to_constructors(idl_name, extended_attri butes)) 321 extended_attributes_to_constructors(idl_name, extended_attri butes))
315 clear_constructor_attributes(extended_attributes) 322 clear_constructor_attributes(extended_attributes)
316 self.extended_attributes = extended_attributes 323 self.extended_attributes = extended_attributes
317 elif child_class == 'Operation': 324 elif child_class == 'Operation':
318 self.operations.append(IdlOperation(idl_name, child)) 325 op = IdlOperation(idl_name, child)
326 if 'getter' in op.specials and len(op.arguments) == 1 and op.arg uments[0].idl_type == 'unsigned long':
Jens Widell 2015/10/05 05:57:11 Checking len(op.arguments) is a bit optional here;
caitp (gmail) 2015/10/05 11:30:23 Done
327 has_indexed_property_getter = True
328 self.operations.append(op)
319 elif child_class == 'Inherit': 329 elif child_class == 'Inherit':
320 self.parent = child.GetName() 330 self.parent = child.GetName()
321 elif child_class == 'Serializer': 331 elif child_class == 'Serializer':
322 self.serializer = IdlSerializer(idl_name, child) 332 self.serializer = IdlSerializer(idl_name, child)
323 self.process_serializer() 333 self.process_serializer()
324 elif child_class == 'Stringifier': 334 elif child_class == 'Stringifier':
325 self.stringifier = IdlStringifier(idl_name, child) 335 self.stringifier = IdlStringifier(idl_name, child)
326 self.process_stringifier() 336 self.process_stringifier()
327 elif child_class == 'Iterable': 337 elif child_class == 'Iterable':
328 self.iterable = IdlIterable(idl_name, child) 338 self.iterable = IdlIterable(idl_name, child)
329 elif child_class == 'Maplike': 339 elif child_class == 'Maplike':
330 self.maplike = IdlMaplike(idl_name, child) 340 self.maplike = IdlMaplike(idl_name, child)
331 elif child_class == 'Setlike': 341 elif child_class == 'Setlike':
332 self.setlike = IdlSetlike(idl_name, child) 342 self.setlike = IdlSetlike(idl_name, child)
333 else: 343 else:
334 raise ValueError('Unrecognized node class: %s' % child_class) 344 raise ValueError('Unrecognized node class: %s' % child_class)
335 345
336 if len(filter(None, [self.iterable, self.maplike, self.setlike])) > 1: 346 if len(filter(None, [self.iterable, self.maplike, self.setlike])) > 1:
337 raise ValueError('Interface can only have one of iterable<>, maplike <> and setlike<>.') 347 raise ValueError('Interface can only have one of iterable<>, maplike <> and setlike<>.')
338 348
349 if has_integer_typed_length and has_indexed_property_getter:
350 self.has_indexed_elements = True
351
339 def accept(self, visitor): 352 def accept(self, visitor):
340 visitor.visit_interface(self) 353 visitor.visit_interface(self)
341 for attribute in self.attributes: 354 for attribute in self.attributes:
342 attribute.accept(visitor) 355 attribute.accept(visitor)
343 for constant in self.constants: 356 for constant in self.constants:
344 constant.accept(visitor) 357 constant.accept(visitor)
345 for constructor in self.constructors: 358 for constructor in self.constructors:
346 constructor.accept(visitor) 359 constructor.accept(visitor)
347 for custom_constructor in self.custom_constructors: 360 for custom_constructor in self.custom_constructors:
348 custom_constructor.accept(visitor) 361 custom_constructor.accept(visitor)
(...skipping 739 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 self.visit_typed_object(argument) 1101 self.visit_typed_object(argument)
1089 1102
1090 def visit_iterable(self, iterable): 1103 def visit_iterable(self, iterable):
1091 self.visit_typed_object(iterable) 1104 self.visit_typed_object(iterable)
1092 1105
1093 def visit_maplike(self, maplike): 1106 def visit_maplike(self, maplike):
1094 self.visit_typed_object(maplike) 1107 self.visit_typed_object(maplike)
1095 1108
1096 def visit_setlike(self, setlike): 1109 def visit_setlike(self, setlike):
1097 self.visit_typed_object(setlike) 1110 self.visit_typed_object(setlike)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698