| OLD | NEW |
| 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 Loading... |
| 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 and attr.name == 'length': |
| 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 str(op.arguments[0].idl_type) ==
'unsigned long': |
| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 408 |
| 396 children = node.GetChildren() | 409 children = node.GetChildren() |
| 397 for child in children: | 410 for child in children: |
| 398 child_class = child.GetClass() | 411 child_class = child.GetClass() |
| 399 if child_class == 'Attribute': | 412 if child_class == 'Attribute': |
| 400 attribute = IdlAttribute(idl_name, child) | 413 attribute = IdlAttribute(idl_name, child) |
| 401 self.attributes.append(attribute) | 414 self.attributes.append(attribute) |
| 402 elif child_class == 'Const': | 415 elif child_class == 'Const': |
| 403 self.constants.append(IdlConstant(idl_name, child)) | 416 self.constants.append(IdlConstant(idl_name, child)) |
| 404 elif child_class == 'ExtAttributes': | 417 elif child_class == 'ExtAttributes': |
| 405 self.extended_attributes = ext_attributes_node_to_extended_attri
butes(idl_name, child) | 418 extended_attributes = ext_attributes_node_to_extended_attributes
(idl_name, child) |
| 419 self.constructors, self.custom_constructors = ( |
| 420 extended_attributes_to_constructors(idl_name, extended_attri
butes)) |
| 421 clear_constructor_attributes(extended_attributes) |
| 422 self.extended_attributes = extended_attributes |
| 406 elif child_class == 'ExceptionOperation': | 423 elif child_class == 'ExceptionOperation': |
| 407 self.operations.append(IdlOperation.from_exception_operation_nod
e(idl_name, child)) | 424 self.operations.append(IdlOperation.from_exception_operation_nod
e(idl_name, child)) |
| 408 else: | 425 else: |
| 409 raise ValueError('Unrecognized node class: %s' % child_class) | 426 raise ValueError('Unrecognized node class: %s' % child_class) |
| 410 | 427 |
| 411 | 428 |
| 412 ################################################################################ | 429 ################################################################################ |
| 413 # Attributes | 430 # Attributes |
| 414 ################################################################################ | 431 ################################################################################ |
| 415 | 432 |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 self.visit_typed_object(argument) | 1101 self.visit_typed_object(argument) |
| 1085 | 1102 |
| 1086 def visit_iterable(self, iterable): | 1103 def visit_iterable(self, iterable): |
| 1087 self.visit_typed_object(iterable) | 1104 self.visit_typed_object(iterable) |
| 1088 | 1105 |
| 1089 def visit_maplike(self, maplike): | 1106 def visit_maplike(self, maplike): |
| 1090 self.visit_typed_object(maplike) | 1107 self.visit_typed_object(maplike) |
| 1091 | 1108 |
| 1092 def visit_setlike(self, setlike): | 1109 def visit_setlike(self, setlike): |
| 1093 self.visit_typed_object(setlike) | 1110 self.visit_typed_object(setlike) |
| OLD | NEW |