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

Side by Side Diff: Source/bindings/scripts/unstable/v8_attributes.py

Issue 30493002: IDL compiler: EventHandler for setters (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 7 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/scripts/unstable/v8_types.py » ('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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 # FIXME: check if compilers are smart enough to inline this, and if so, 118 # FIXME: check if compilers are smart enough to inline this, and if so,
119 # always use a local variable (for readability and CG simplicity). 119 # always use a local variable (for readability and CG simplicity).
120 if (attribute.is_nullable or 120 if (attribute.is_nullable or
121 idl_type == 'EventHandler' or 121 idl_type == 'EventHandler' or
122 'CachedAttribute' in extended_attributes or 122 'CachedAttribute' in extended_attributes or
123 contents['is_getter_raises_exception']): 123 contents['is_getter_raises_exception']):
124 contents['cpp_value_original'] = cpp_value 124 contents['cpp_value_original'] = cpp_value
125 cpp_value = 'jsValue' 125 cpp_value = 'jsValue'
126 contents['cpp_value'] = cpp_value 126 contents['cpp_value'] = cpp_value
127 127
128 # FIXME: always have includes_for_type
128 if contents['is_keep_alive_for_gc']: 129 if contents['is_keep_alive_for_gc']:
129 v8_set_return_value_statement = 'v8SetReturnValue(info, wrapper)' 130 v8_set_return_value_statement = 'v8SetReturnValue(info, wrapper)'
130 includes.update(v8_types.includes_for_type(idl_type)) 131 includes.update(v8_types.includes_for_type(idl_type))
131 includes.add('bindings/v8/V8HiddenPropertyName.h') 132 includes.add('bindings/v8/V8HiddenPropertyName.h')
132 else: 133 else:
133 v8_set_return_value_statement = v8_types.v8_set_return_value(idl_type, c pp_value, includes, callback_info='info', isolate='info.GetIsolate()', extended_ attributes=extended_attributes, script_wrappable='imp') 134 v8_set_return_value_statement = v8_types.v8_set_return_value(idl_type, c pp_value, includes, callback_info='info', isolate='info.GetIsolate()', extended_ attributes=extended_attributes, script_wrappable='imp')
134 contents['v8_set_return_value'] = v8_set_return_value_statement 135 contents['v8_set_return_value'] = v8_set_return_value_statement
135 136
136 if (idl_type == 'EventHandler' and 137 if idl_type == 'EventHandler':
137 interface.name in ['Window', 'WorkerGlobalScope'] and 138 includes.update(v8_types.includes_for_type('EventHandler'))
138 attribute.name == 'onerror'): 139 if (interface.name in ['Window', 'WorkerGlobalScope'] and
139 includes.add('bindings/v8/V8ErrorHandler.h') 140 attribute.name == 'onerror'):
141 includes.add('bindings/v8/V8ErrorHandler.h')
140 142
141 # [CheckSecurityForNode] 143 # [CheckSecurityForNode]
142 is_check_security_for_node = 'CheckSecurityForNode' in extended_attributes 144 is_check_security_for_node = 'CheckSecurityForNode' in extended_attributes
143 if is_check_security_for_node: 145 if is_check_security_for_node:
144 includes.add('bindings/v8/BindingSecurity.h') 146 includes.add('bindings/v8/BindingSecurity.h')
145 v8_utilities.generate_measure_as(attribute, contents, includes) # [MeasureA s] 147 v8_utilities.generate_measure_as(attribute, contents, includes) # [MeasureA s]
146 148
147 # [DeprecateAs] 149 # [DeprecateAs]
148 v8_utilities.generate_deprecate_as(attribute, contents, includes) 150 v8_utilities.generate_deprecate_as(attribute, contents, includes)
149 if is_check_security_for_node or contents['is_getter_raises_exception']: 151 if is_check_security_for_node or contents['is_getter_raises_exception']:
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 return 'fastGetAttribute' 204 return 'fastGetAttribute'
203 205
204 206
205 def generate_setter(interface, attribute, contents, includes): 207 def generate_setter(interface, attribute, contents, includes):
206 idl_type = attribute.data_type 208 idl_type = attribute.data_type
207 if v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type ): 209 if v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type ):
208 cpp_value = 'WTF::getPtr(cppValue)' 210 cpp_value = 'WTF::getPtr(cppValue)'
209 else: 211 else:
210 cpp_value = 'cppValue' 212 cpp_value = 'cppValue'
211 contents.update({ 213 contents.update({
212 'cpp_setter': setter_expression(interface, attribute, contents), 214 'cpp_setter': setter_expression(interface, attribute, contents, includes ),
213 'enum_validation_expression': enum_validation_expression(idl_type), 215 'enum_validation_expression': enum_validation_expression(idl_type),
214 'v8_value_to_local_cpp_value': v8_types.v8_value_to_local_cpp_value(idl_ type, attribute.extended_attributes, 'jsValue', 'cppValue', includes, 'info.GetI solate()'), 216 'v8_value_to_local_cpp_value': v8_types.v8_value_to_local_cpp_value(idl_ type, attribute.extended_attributes, 'jsValue', 'cppValue', includes, 'info.GetI solate()'),
215 }) 217 })
216 218
217 219
218 def setter_expression(interface, attribute, contents): 220 def setter_expression(interface, attribute, contents, includes):
219 arguments = v8_utilities.call_with_arguments(attribute, contents) 221 arguments = v8_utilities.call_with_arguments(attribute, contents)
220 idl_type = attribute.data_type 222 idl_type = attribute.data_type
221 # FIXME: should be able to eliminate WTF::getPtr in most or all cases 223 if idl_type == 'EventHandler':
222 cpp_value = 'WTF::getPtr(cppValue)' if v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_type) else 'cppValue' 224 # FIXME: move V8EventListenerList.h to INCLUDES_FOR_TYPE
223 arguments.append(cpp_value) 225 includes.add('bindings/v8/V8EventListenerList.h')
226 # FIXME: pass the isolate instead of the isolated world
227 isolated_world = 'isolatedWorldForIsolate(info.GetIsolate())'
228 arguments.extend(['V8EventListenerList::getEventListener(jsValue, true, ListenerFindOrCreate)', isolated_world])
229 contents['event_handler_getter_expression'] = 'imp->%s(%s)' % (cpp_name( attribute), isolated_world)
230 elif v8_types.is_interface_type(idl_type) and not v8_types.array_type(idl_ty pe):
231 # FIXME: should be able to eliminate WTF::getPtr in most or all cases
232 arguments.append('WTF::getPtr(cppValue)')
233 else:
234 arguments.append('cppValue')
235
224 setter_name = scoped_name(interface, attribute, 'set%s' % capitalize(cpp_nam e(attribute))) 236 setter_name = scoped_name(interface, attribute, 'set%s' % capitalize(cpp_nam e(attribute)))
225 return '%s(%s)' % (setter_name, ', '.join(arguments)) 237 return '%s(%s)' % (setter_name, ', '.join(arguments))
226 238
227 239
228 def enum_validation_expression(idl_type): 240 def enum_validation_expression(idl_type):
229 if not v8_types.is_enum_type(idl_type): 241 if not v8_types.is_enum_type(idl_type):
230 return None 242 return None
231 return ' || '.join(['string == "%s"' % enum_value 243 return ' || '.join(['string == "%s"' % enum_value
232 for enum_value in v8_types.enum_values(idl_type)]) 244 for enum_value in v8_types.enum_values(idl_type)])
233 245
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 if 'PerWorldBindings' not in attribute.extended_attributes: 314 if 'PerWorldBindings' not in attribute.extended_attributes:
303 return '0' 315 return '0'
304 return '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name) 316 return '%sV8Internal::%sAttributeGetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name)
305 317
306 318
307 def setter_callback_name_for_main_world(interface, attribute): 319 def setter_callback_name_for_main_world(interface, attribute):
308 if ('PerWorldBindings' not in attribute.extended_attributes or 320 if ('PerWorldBindings' not in attribute.extended_attributes or
309 attribute.is_read_only): 321 attribute.is_read_only):
310 return '0' 322 return '0'
311 return '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name) 323 return '%sV8Internal::%sAttributeSetterCallbackForMainWorld' % (cpp_name(int erface), attribute.name)
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/unstable/v8_types.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698