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 448 matching lines...) Loading... |
459 | 459 |
460 | 460 |
461 ################################################################################ | 461 ################################################################################ |
462 # Constructors | 462 # Constructors |
463 ################################################################################ | 463 ################################################################################ |
464 | 464 |
465 # [Constructor] | 465 # [Constructor] |
466 def generate_constructor(interface, constructor): | 466 def generate_constructor(interface, constructor): |
467 return { | 467 return { |
468 'argument_list': constructor_argument_list(interface, constructor), | 468 'argument_list': constructor_argument_list(interface, constructor), |
469 'arguments': [constructor_argument(interface, constructor, argument, ind
ex) | 469 'arguments': [v8_methods.generate_argument(interface, constructor, argum
ent, index) |
470 for index, argument in enumerate(constructor.arguments)], | 470 for index, argument in enumerate(constructor.arguments)], |
471 'cpp_type': cpp_template_type( | 471 'cpp_type': cpp_template_type( |
472 cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)), | 472 cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)), |
473 cpp_name(interface)), | 473 cpp_name(interface)), |
474 'has_exception_state': | 474 'has_exception_state': |
475 # [RaisesException=Constructor] | 475 # [RaisesException=Constructor] |
476 interface.extended_attributes.get('RaisesException') == 'Constructor
' or | 476 interface.extended_attributes.get('RaisesException') == 'Constructor
' or |
477 any(argument for argument in constructor.arguments | 477 any(argument for argument in constructor.arguments |
478 if argument.idl_type.name == 'SerializedScriptValue' or | 478 if argument.idl_type.name == 'SerializedScriptValue' or |
479 argument.idl_type.is_integer_type), | 479 argument.idl_type.is_integer_type), |
(...skipping 16 matching lines...) Loading... |
496 | 496 |
497 arguments.extend([argument.name for argument in constructor.arguments]) | 497 arguments.extend([argument.name for argument in constructor.arguments]) |
498 | 498 |
499 # [RaisesException=Constructor] | 499 # [RaisesException=Constructor] |
500 if interface.extended_attributes.get('RaisesException') == 'Constructor': | 500 if interface.extended_attributes.get('RaisesException') == 'Constructor': |
501 arguments.append('exceptionState') | 501 arguments.append('exceptionState') |
502 | 502 |
503 return arguments | 503 return arguments |
504 | 504 |
505 | 505 |
506 def constructor_argument(interface, constructor, argument, index): | |
507 idl_type = argument.idl_type | |
508 return { | |
509 'cpp_value': | |
510 v8_methods.cpp_value(interface, constructor, index), | |
511 'has_default': 'Default' in argument.extended_attributes, | |
512 'has_legacy_overload_string': False, # Required for overload resolution | |
513 # Dictionary is special-cased, but arrays and sequences shouldn't be | |
514 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type, | |
515 'idl_type_object': idl_type, | |
516 'index': index, | |
517 'is_optional': argument.is_optional, | |
518 'name': argument.name, | |
519 'v8_value_to_local_cpp_value': | |
520 v8_methods.v8_value_to_local_cpp_value(argument, index), | |
521 } | |
522 | |
523 | |
524 def generate_constructor_overloads(constructors): | 506 def generate_constructor_overloads(constructors): |
525 if len(constructors) <= 1: | 507 if len(constructors) <= 1: |
526 return | 508 return |
527 for overload_index, constructor in enumerate(constructors): | 509 for overload_index, constructor in enumerate(constructors): |
528 constructor.update({ | 510 constructor.update({ |
529 'overload_index': overload_index + 1, | 511 'overload_index': overload_index + 1, |
530 'overload_resolution_expression': | 512 'overload_resolution_expression': |
531 overload_resolution_expression(constructor), | 513 overload_resolution_expression(constructor), |
532 }) | 514 }) |
533 | 515 |
(...skipping 213 matching lines...) Loading... |
747 deleter = next( | 729 deleter = next( |
748 method | 730 method |
749 for method in interface.operations | 731 for method in interface.operations |
750 if ('deleter' in method.specials and | 732 if ('deleter' in method.specials and |
751 len(method.arguments) == 1 and | 733 len(method.arguments) == 1 and |
752 str(method.arguments[0].idl_type) == 'DOMString')) | 734 str(method.arguments[0].idl_type) == 'DOMString')) |
753 except StopIteration: | 735 except StopIteration: |
754 return None | 736 return None |
755 | 737 |
756 return property_deleter(deleter) | 738 return property_deleter(deleter) |
OLD | NEW |