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

Side by Side Diff: Source/bindings/scripts/v8_methods.py

Issue 328663003: IDL: restructure logic handling registration of methods (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased Created 6 years, 6 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
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/templates/interface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 22 matching lines...) Expand all
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 = frozenset([
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 for argument in arguments) 110 for argument in arguments)
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,
120 'custom_registration_extended_attributes':
121 CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES.intersection(
122 extended_attributes.iterkeys()),
109 'deprecate_as': v8_utilities.deprecate_as(method), # [DeprecateAs] 123 '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(), 124 'function_template': function_template(),
115 'idl_type': idl_type.base_type, 125 'has_custom_registration': is_static or
126 v8_utilities.has_extended_attribute(
127 method, CUSTOM_REGISTRATION_EXTENDED_ATTRIBUTES),
116 'has_event_listener_argument': has_event_listener_argument, 128 'has_event_listener_argument': has_event_listener_argument,
117 'has_exception_state': 129 'has_exception_state':
118 has_event_listener_argument or 130 has_event_listener_argument or
119 is_raises_exception or 131 is_raises_exception or
120 is_check_security_for_frame or 132 is_check_security_for_frame or
121 any(argument for argument in arguments 133 any(argument for argument in arguments
122 if argument.idl_type.name in ('ByteString', 'SerializedScriptVal ue') or 134 if argument.idl_type.name in ('ByteString', 'SerializedScriptVal ue') or
123 argument.idl_type.is_integer_type), 135 argument.idl_type.is_integer_type),
136 'idl_type': idl_type.base_type,
124 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'), 137 'is_call_with_execution_context': has_extended_attribute_value(method, ' CallWith', 'ExecutionContext'),
125 'is_call_with_script_arguments': is_call_with_script_arguments, 138 'is_call_with_script_arguments': is_call_with_script_arguments,
126 'is_call_with_script_state': is_call_with_script_state, 139 'is_call_with_script_state': is_call_with_script_state,
127 'is_check_security_for_frame': is_check_security_for_frame, 140 'is_check_security_for_frame': is_check_security_for_frame,
128 'is_check_security_for_node': is_check_security_for_node, 141 'is_check_security_for_node': is_check_security_for_node,
129 'is_custom': 'Custom' in extended_attributes, 142 'is_custom': 'Custom' in extended_attributes,
130 'is_custom_element_callbacks': is_custom_element_callbacks, 143 'is_custom_element_callbacks': is_custom_element_callbacks,
131 'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes, 144 'is_do_not_check_security': 'DoNotCheckSecurity' in extended_attributes,
132 'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attribute s, 145 'is_do_not_check_signature': 'DoNotCheckSignature' in extended_attribute s,
133 'is_partial_interface_member': 146 'is_partial_interface_member':
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 326
314 327
315 def union_arguments(idl_type): 328 def union_arguments(idl_type):
316 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" 329 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value"""
317 return [arg 330 return [arg
318 for i in range(len(idl_type.member_types)) 331 for i in range(len(idl_type.member_types))
319 for arg in ['result%sEnabled' % i, 'result%s' % i]] 332 for arg in ['result%sEnabled' % i, 'result%s' % i]]
320 333
321 IdlType.union_arguments = property(lambda self: None) 334 IdlType.union_arguments = property(lambda self: None)
322 IdlUnionType.union_arguments = property(union_arguments) 335 IdlUnionType.union_arguments = property(union_arguments)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/templates/interface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698