Chromium Code Reviews| 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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 457 return type_check | 457 return type_check |
| 458 return None | 458 return None |
| 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 generated_arguments = [constructor_argument(interface, constructor, argument , index) | |
| 468 for index, argument in enumerate(constructor.argument s)] | |
| 469 | |
| 467 return { | 470 return { |
| 468 'argument_list': constructor_argument_list(interface, constructor), | 471 'argument_list': constructor_argument_list(interface, constructor), |
| 469 'arguments': [constructor_argument(interface, constructor, argument, ind ex) | 472 'arguments': generated_arguments, |
| 470 for index, argument in enumerate(constructor.arguments)], | 473 'arguments_need_try_catch': any( |
| 474 v8_methods.argument_needs_try_catch(argument) for argument in genera ted_arguments), | |
|
Nils Barth (inactive)
2014/05/07 03:02:19
Could you add one more linebreak here?
(So for ...
| |
| 471 'cpp_type': cpp_template_type( | 475 'cpp_type': cpp_template_type( |
| 472 cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)), | 476 cpp_ptr_type('RefPtr', 'RawPtr', gc_type(interface)), |
| 473 cpp_name(interface)), | 477 cpp_name(interface)), |
| 474 'has_exception_state': | 478 'has_exception_state': |
| 475 # [RaisesException=Constructor] | 479 # [RaisesException=Constructor] |
| 476 interface.extended_attributes.get('RaisesException') == 'Constructor ' or | 480 interface.extended_attributes.get('RaisesException') == 'Constructor ' or |
| 477 any(argument for argument in constructor.arguments | 481 any(argument for argument in constructor.arguments |
| 478 if argument.idl_type.name == 'SerializedScriptValue' or | 482 if argument.idl_type.name == 'SerializedScriptValue' or |
| 479 argument.idl_type.is_integer_type), | 483 argument.idl_type.is_integer_type), |
| 480 'is_constructor': True, | 484 'is_constructor': True, |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 497 arguments.extend([argument.name for argument in constructor.arguments]) | 501 arguments.extend([argument.name for argument in constructor.arguments]) |
| 498 | 502 |
| 499 # [RaisesException=Constructor] | 503 # [RaisesException=Constructor] |
| 500 if interface.extended_attributes.get('RaisesException') == 'Constructor': | 504 if interface.extended_attributes.get('RaisesException') == 'Constructor': |
| 501 arguments.append('exceptionState') | 505 arguments.append('exceptionState') |
| 502 | 506 |
| 503 return arguments | 507 return arguments |
| 504 | 508 |
| 505 | 509 |
| 506 def constructor_argument(interface, constructor, argument, index): | 510 def constructor_argument(interface, constructor, argument, index): |
| 511 extended_attributes = argument.extended_attributes | |
| 507 idl_type = argument.idl_type | 512 idl_type = argument.idl_type |
| 513 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type | |
| 514 | |
| 508 return { | 515 return { |
| 516 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es, | |
| 517 used_as_argument=not is_variadic_wrap per_type, | |
| 518 used_in_cpp_sequence=is_variadic_wrap per_type), | |
| 509 'cpp_value': | 519 'cpp_value': |
| 510 v8_methods.cpp_value(interface, constructor, index), | 520 v8_methods.cpp_value(interface, constructor, index), |
| 511 'has_default': 'Default' in argument.extended_attributes, | 521 'has_default': 'Default' in argument.extended_attributes, |
| 512 'has_legacy_overload_string': False, # Required for overload resolution | 522 'has_legacy_overload_string': False, # Required for overload resolution |
| 513 # Dictionary is special-cased, but arrays and sequences shouldn't be | 523 # 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, | 524 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type, |
| 515 'idl_type_object': idl_type, | 525 'idl_type_object': idl_type, |
| 516 'index': index, | 526 'index': index, |
| 517 'is_optional': argument.is_optional, | 527 'is_optional': argument.is_optional, |
| 518 'name': argument.name, | 528 'name': argument.name, |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 747 deleter = next( | 757 deleter = next( |
| 748 method | 758 method |
| 749 for method in interface.operations | 759 for method in interface.operations |
| 750 if ('deleter' in method.specials and | 760 if ('deleter' in method.specials and |
| 751 len(method.arguments) == 1 and | 761 len(method.arguments) == 1 and |
| 752 str(method.arguments[0].idl_type) == 'DOMString')) | 762 str(method.arguments[0].idl_type) == 'DOMString')) |
| 753 except StopIteration: | 763 except StopIteration: |
| 754 return None | 764 return None |
| 755 | 765 |
| 756 return property_deleter(deleter) | 766 return property_deleter(deleter) |
| OLD | NEW |