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

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: Add FIXMEs 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
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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 # FIXME: check if compilers are smart enough to inline this, and if so, 117 # FIXME: check if compilers are smart enough to inline this, and if so,
118 # always use a local variable (for readability and CG simplicity). 118 # always use a local variable (for readability and CG simplicity).
119 if (attribute.is_nullable or 119 if (attribute.is_nullable or
120 idl_type == 'EventHandler' or 120 idl_type == 'EventHandler' or
121 'CachedAttribute' in extended_attributes or 121 'CachedAttribute' in extended_attributes or
122 contents['is_getter_raises_exception']): 122 contents['is_getter_raises_exception']):
123 contents['cpp_value_original'] = cpp_value 123 contents['cpp_value_original'] = cpp_value
124 cpp_value = 'jsValue' 124 cpp_value = 'jsValue'
125 contents['cpp_value'] = cpp_value 125 contents['cpp_value'] = cpp_value
126 126
127 # FIXME: always have includes_for_type
127 if contents['is_keep_alive_for_gc']: 128 if contents['is_keep_alive_for_gc']:
128 v8_set_return_value_statement = 'v8SetReturnValue(info, wrapper)' 129 v8_set_return_value_statement = 'v8SetReturnValue(info, wrapper)'
129 includes.update(v8_types.includes_for_type(idl_type)) 130 includes.update(v8_types.includes_for_type(idl_type))
130 includes.add('bindings/v8/V8HiddenPropertyName.h') 131 includes.add('bindings/v8/V8HiddenPropertyName.h')
131 else: 132 else:
132 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') 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')
133 contents['v8_set_return_value'] = v8_set_return_value_statement 134 contents['v8_set_return_value'] = v8_set_return_value_statement
134 135
135 if (idl_type == 'EventHandler' and 136 if idl_type == 'EventHandler':
136 interface.name in ['Window', 'WorkerGlobalScope'] and 137 includes.update(v8_types.includes_for_type('EventHandler'))
137 attribute.name == 'onerror'): 138 if (interface.name in ['Window', 'WorkerGlobalScope'] and
138 includes.add('bindings/v8/V8ErrorHandler.h') 139 attribute.name == 'onerror'):
140 includes.add('bindings/v8/V8ErrorHandler.h')
139 141
140 # [CheckSecurityForNode] 142 # [CheckSecurityForNode]
141 is_check_security_for_node = 'CheckSecurityForNode' in extended_attributes 143 is_check_security_for_node = 'CheckSecurityForNode' in extended_attributes
142 if is_check_security_for_node: 144 if is_check_security_for_node:
143 includes.add('bindings/v8/BindingSecurity.h') 145 includes.add('bindings/v8/BindingSecurity.h')
144 v8_utilities.generate_measure_as(attribute, contents, includes) # [MeasureA s] 146 v8_utilities.generate_measure_as(attribute, contents, includes) # [MeasureA s]
145 147
146 # [DeprecateAs] 148 # [DeprecateAs]
147 v8_utilities.generate_deprecate_as(attribute, contents, includes) 149 v8_utilities.generate_deprecate_as(attribute, contents, includes)
148 if is_check_security_for_node or contents['is_getter_raises_exception']: 150 if is_check_security_for_node or contents['is_getter_raises_exception']:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 '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()'), 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()'),
213 'cpp_setter': setter_expression(interface, attribute, contents), 215 'cpp_setter': setter_expression(interface, attribute, contents, includes ),
214 'enum_validation_expression': enum_validation_expression(idl_type), 216 'enum_validation_expression': enum_validation_expression(idl_type),
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') | Source/bindings/tests/results/V8TestObjectPython.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698