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 22 matching lines...) Expand all Loading... | |
33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler | 33 Design doc: http://www.chromium.org/developers/design-documents/idl-compiler |
34 """ | 34 """ |
35 | 35 |
36 from idl_types import IdlType, IdlUnionType, inherits_interface | 36 from idl_types import IdlType, IdlUnionType, inherits_interface |
37 from v8_globals import includes | 37 from v8_globals import includes |
38 import v8_types | 38 import v8_types |
39 import v8_utilities | 39 import v8_utilities |
40 from v8_utilities import has_extended_attribute_value | 40 from v8_utilities import has_extended_attribute_value |
41 | 41 |
42 | 42 |
43 # Methods with any of these require custom method registration code in the | |
44 # interface's configure*Template() function. | |
45 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES = ( | |
46 'DoNotCheckSecurity', | |
47 'DoNotCheckSignature', | |
48 'NotEnumerable', | |
49 'ReadOnly', | |
50 'Unforgeable', | |
51 ) | |
52 | |
53 | |
43 def argument_needs_try_catch(argument): | 54 def argument_needs_try_catch(argument): |
44 idl_type = argument.idl_type | 55 idl_type = argument.idl_type |
45 base_type = not idl_type.array_or_sequence_type and idl_type.base_type | 56 base_type = not idl_type.array_or_sequence_type and idl_type.base_type |
46 | 57 |
47 return not ( | 58 return not ( |
48 # These cases are handled by separate code paths in the | 59 # These cases are handled by separate code paths in the |
49 # generate_argument() macro in Source/bindings/templates/methods.cpp. | 60 # generate_argument() macro in Source/bindings/templates/methods.cpp. |
50 idl_type.is_callback_interface or | 61 idl_type.is_callback_interface or |
51 base_type == 'SerializedScriptValue' or | 62 base_type == 'SerializedScriptValue' or |
52 (argument.is_variadic and idl_type.is_wrapper_type) or | 63 (argument.is_variadic and idl_type.is_wrapper_type) or |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 | 111 |
101 return { | 112 return { |
102 'activity_logging_world_list': v8_utilities.activity_logging_world_list( method), # [ActivityLogging] | 113 'activity_logging_world_list': v8_utilities.activity_logging_world_list( method), # [ActivityLogging] |
103 'arguments': [generate_argument(interface, method, argument, index) | 114 'arguments': [generate_argument(interface, method, argument, index) |
104 for index, argument in enumerate(arguments)], | 115 for index, argument in enumerate(arguments)], |
105 'arguments_need_try_catch': arguments_need_try_catch, | 116 'arguments_need_try_catch': arguments_need_try_catch, |
106 'conditional_string': v8_utilities.conditional_string(method), | 117 'conditional_string': v8_utilities.conditional_string(method), |
107 'cpp_type': idl_type.cpp_type, | 118 'cpp_type': idl_type.cpp_type, |
108 'cpp_value': this_cpp_value, | 119 'cpp_value': this_cpp_value, |
109 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] | 120 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] |
110 'do_not_check_signature': not(is_static or | |
111 v8_utilities.has_extended_attribute(method, | |
112 ['DoNotCheckSecurity', 'DoNotCheckSignature', 'NotEnumerable', | |
113 'ReadOnly', 'RuntimeEnabled', 'Unforgeable'])), | |
114 'function_template': function_template(), | 121 'function_template': function_template(), |
115 'idl_type': idl_type.base_type, | 122 'idl_type': idl_type.base_type, |
116 'has_event_listener_argument': has_event_listener_argument, | 123 'has_event_listener_argument': has_event_listener_argument, |
117 'has_exception_state': | 124 'has_exception_state': |
118 has_event_listener_argument or | 125 has_event_listener_argument or |
119 is_raises_exception or | 126 is_raises_exception or |
120 is_check_security_for_frame or | 127 is_check_security_for_frame or |
121 any(argument for argument in arguments | 128 any(argument for argument in arguments |
122 if argument.idl_type.name == 'SerializedScriptValue' or | 129 if argument.idl_type.name == 'SerializedScriptValue' or |
123 argument.idl_type.is_integer_type), | 130 argument.idl_type.is_integer_type), |
124 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'), | 131 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'), |
125 'is_call_with_script_arguments': is_call_with_script_arguments, | 132 'is_call_with_script_arguments': is_call_with_script_arguments, |
126 'is_call_with_script_state': is_call_with_script_state, | 133 'is_call_with_script_state': is_call_with_script_state, |
127 'is_check_security_for_frame': is_check_security_for_frame, | 134 'is_check_security_for_frame': is_check_security_for_frame, |
128 'is_check_security_for_node': is_check_security_for_node, | 135 'is_check_security_for_node': is_check_security_for_node, |
129 'is_custom': 'Custom' in extended_attributes, | 136 'is_custom': 'Custom' in extended_attributes, |
130 'is_custom_element_callbacks': is_custom_element_callbacks, | 137 'is_custom_element_callbacks': is_custom_element_callbacks, |
131 'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes, | 138 'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes, |
132 'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attribute s, | 139 'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attribute s, |
133 'is_partial_interface_member': | 140 'is_partial_interface_member': |
134 'PartialInterfaceImplementedAs' in extended_attributes, | 141 'PartialInterfaceImplementedAs' in extended_attributes, |
135 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, | 142 'is_per_world_bindings': 'PerWorldBindings' in extended_attributes, |
136 'is_raises_exception': is_raises_exception, | 143 'is_raises_exception': is_raises_exception, |
137 'is_read_only': 'ReadOnly' in extended_attributes, | 144 'is_read_only': 'ReadOnly' in extended_attributes, |
138 'is_static': is_static, | 145 'is_static': is_static, |
139 'is_variadic': arguments and arguments[-1].is_variadic, | 146 'is_variadic': arguments and arguments[-1].is_variadic, |
140 'measure_as': v8_utilities.measure_as(method), # [MeasureAs] | 147 'measure_as': v8_utilities.measure_as(method), # [MeasureAs] |
141 'name': name, | 148 'name': name, |
149 'needs_custom_registration': is_static or | |
150 v8_utilities.has_extended_attribute(method, CUSTOM_REGISTRATION_EXTE NDED_ATTRIBUTES), | |
Nils Barth (inactive)
2014/06/11 10:10:28
nit: line break
| |
142 'number_of_arguments': len(arguments), | 151 'number_of_arguments': len(arguments), |
143 'number_of_required_arguments': len([ | 152 'number_of_required_arguments': len([ |
144 argument for argument in arguments | 153 argument for argument in arguments |
145 if not (argument.is_optional or argument.is_variadic)]), | 154 if not (argument.is_optional or argument.is_variadic)]), |
146 'number_of_required_or_variadic_arguments': len([ | 155 'number_of_required_or_variadic_arguments': len([ |
147 argument for argument in arguments | 156 argument for argument in arguments |
148 if not argument.is_optional]), | 157 if not argument.is_optional]), |
149 'per_context_enabled_function': v8_utilities.per_context_enabled_functio n_name(method), # [PerContextEnabled] | 158 'per_context_enabled_function': v8_utilities.per_context_enabled_functio n_name(method), # [PerContextEnabled] |
150 'property_attributes': property_attributes(method), | 159 'property_attributes': property_attributes(method), |
151 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m ethod), # [RuntimeEnabled] | 160 'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(m ethod), # [RuntimeEnabled] |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
313 | 322 |
314 | 323 |
315 def union_arguments(idl_type): | 324 def union_arguments(idl_type): |
316 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" | 325 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" |
317 return [arg | 326 return [arg |
318 for i in range(len(idl_type.member_types)) | 327 for i in range(len(idl_type.member_types)) |
319 for arg in ['result%sEnabled' % i, 'result%s' % i]] | 328 for arg in ['result%sEnabled' % i, 'result%s' % i]] |
320 | 329 |
321 IdlType.union_arguments = property(lambda self: None) | 330 IdlType.union_arguments = property(lambda self: None) |
322 IdlUnionType.union_arguments = property(union_arguments) | 331 IdlUnionType.union_arguments = property(union_arguments) |
OLD | NEW |