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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 # exceptions), we need to use a local variable. | 165 # exceptions), we need to use a local variable. |
166 # FIXME: check if compilers are smart enough to inline this, and if so, | 166 # FIXME: check if compilers are smart enough to inline this, and if so, |
167 # always use a local variable (for readability and CG simplicity). | 167 # always use a local variable (for readability and CG simplicity). |
168 release = False | 168 release = False |
169 if (idl_type.is_nullable or | 169 if (idl_type.is_nullable or |
170 base_idl_type == 'EventHandler' or | 170 base_idl_type == 'EventHandler' or |
171 'CachedAttribute' in extended_attributes or | 171 'CachedAttribute' in extended_attributes or |
172 'ReflectOnly' in extended_attributes or | 172 'ReflectOnly' in extended_attributes or |
173 contents['is_getter_raises_exception']): | 173 contents['is_getter_raises_exception']): |
174 contents['cpp_value_original'] = cpp_value | 174 contents['cpp_value_original'] = cpp_value |
175 cpp_value = 'jsValue' | 175 cpp_value = 'v8Value' |
176 # EventHandler has special handling | 176 # EventHandler has special handling |
177 if base_idl_type != 'EventHandler' and idl_type.is_interface_type: | 177 if base_idl_type != 'EventHandler' and idl_type.is_interface_type: |
178 release = True | 178 release = True |
179 | 179 |
180 def v8_set_return_value_statement(for_main_world=False): | 180 def v8_set_return_value_statement(for_main_world=False): |
181 if contents['is_keep_alive_for_gc']: | 181 if contents['is_keep_alive_for_gc']: |
182 return 'v8SetReturnValue(info, wrapper)' | 182 return 'v8SetReturnValue(info, wrapper)' |
183 return idl_type.v8_set_return_value(cpp_value, extended_attributes=exten
ded_attributes, script_wrappable='impl', release=release, for_main_world=for_mai
n_world) | 183 return idl_type.v8_set_return_value(cpp_value, extended_attributes=exten
ded_attributes, script_wrappable='impl', release=release, for_main_world=for_mai
n_world) |
184 | 184 |
185 contents.update({ | 185 contents.update({ |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 (target_attribute_name, target_interface_name)) | 273 (target_attribute_name, target_interface_name)) |
274 | 274 |
275 extended_attributes = attribute.extended_attributes | 275 extended_attributes = attribute.extended_attributes |
276 | 276 |
277 if 'PutForwards' in extended_attributes: | 277 if 'PutForwards' in extended_attributes: |
278 # Use target attribute in place of original attribute | 278 # Use target attribute in place of original attribute |
279 attribute = target_attribute() | 279 attribute = target_attribute() |
280 | 280 |
281 contents.update({ | 281 contents.update({ |
282 'cpp_setter': setter_expression(interface, attribute, contents), | 282 'cpp_setter': setter_expression(interface, attribute, contents), |
283 'v8_value_to_local_cpp_value': attribute.idl_type.v8_value_to_local_cpp_
value(extended_attributes, 'jsValue', 'cppValue'), | 283 'v8_value_to_local_cpp_value': attribute.idl_type.v8_value_to_local_cpp_
value(extended_attributes, 'v8Value', 'cppValue'), |
284 }) | 284 }) |
285 | 285 |
286 | 286 |
287 def setter_expression(interface, attribute, contents): | 287 def setter_expression(interface, attribute, contents): |
288 extended_attributes = attribute.extended_attributes | 288 extended_attributes = attribute.extended_attributes |
289 arguments = v8_utilities.call_with_arguments(attribute, extended_attributes.
get('SetterCallWith')) | 289 arguments = v8_utilities.call_with_arguments(attribute, extended_attributes.
get('SetterCallWith')) |
290 | 290 |
291 this_setter_base_name = setter_base_name(interface, attribute, arguments) | 291 this_setter_base_name = setter_base_name(interface, attribute, arguments) |
292 setter_name = scoped_name(interface, attribute, this_setter_base_name) | 292 setter_name = scoped_name(interface, attribute, this_setter_base_name) |
293 | 293 |
294 if ('ImplementedBy' in extended_attributes and | 294 if ('ImplementedBy' in extended_attributes and |
295 not attribute.is_static): | 295 not attribute.is_static): |
296 arguments.append('*impl') | 296 arguments.append('*impl') |
297 idl_type = attribute.idl_type | 297 idl_type = attribute.idl_type |
298 if idl_type.base_type == 'EventHandler': | 298 if idl_type.base_type == 'EventHandler': |
299 getter_name = scoped_name(interface, attribute, cpp_name(attribute)) | 299 getter_name = scoped_name(interface, attribute, cpp_name(attribute)) |
300 contents['event_handler_getter_expression'] = '%s(%s)' % ( | 300 contents['event_handler_getter_expression'] = '%s(%s)' % ( |
301 getter_name, ', '.join(arguments)) | 301 getter_name, ', '.join(arguments)) |
302 if (interface.name in ['Window', 'WorkerGlobalScope'] and | 302 if (interface.name in ['Window', 'WorkerGlobalScope'] and |
303 attribute.name == 'onerror'): | 303 attribute.name == 'onerror'): |
304 includes.add('bindings/v8/V8ErrorHandler.h') | 304 includes.add('bindings/v8/V8ErrorHandler.h') |
305 arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHa
ndler>(jsValue, true, info.GetIsolate())') | 305 arguments.append('V8EventListenerList::findOrCreateWrapper<V8ErrorHa
ndler>(v8Value, true, info.GetIsolate())') |
306 else: | 306 else: |
307 arguments.append('V8EventListenerList::getEventListener(jsValue, tru
e, ListenerFindOrCreate)') | 307 arguments.append('V8EventListenerList::getEventListener(v8Value, tru
e, ListenerFindOrCreate)') |
308 elif idl_type.is_interface_type and not idl_type.array_type: | 308 elif idl_type.is_interface_type and not idl_type.array_type: |
309 # FIXME: should be able to eliminate WTF::getPtr in most or all cases | 309 # FIXME: should be able to eliminate WTF::getPtr in most or all cases |
310 arguments.append('WTF::getPtr(cppValue)') | 310 arguments.append('WTF::getPtr(cppValue)') |
311 else: | 311 else: |
312 arguments.append('cppValue') | 312 arguments.append('cppValue') |
313 if contents['is_setter_raises_exception']: | 313 if contents['is_setter_raises_exception']: |
314 arguments.append('exceptionState') | 314 arguments.append('exceptionState') |
315 | 315 |
316 return '%s(%s)' % (setter_name, ', '.join(arguments)) | 316 return '%s(%s)' % (setter_name, ', '.join(arguments)) |
317 | 317 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 lambda self: strip_suffix(self.base_type, 'Constructor')) | 398 lambda self: strip_suffix(self.base_type, 'Constructor')) |
399 | 399 |
400 | 400 |
401 def is_constructor_attribute(attribute): | 401 def is_constructor_attribute(attribute): |
402 # FIXME: replace this with [ConstructorAttribute] extended attribute | 402 # FIXME: replace this with [ConstructorAttribute] extended attribute |
403 return attribute.idl_type.base_type.endswith('Constructor') | 403 return attribute.idl_type.base_type.endswith('Constructor') |
404 | 404 |
405 | 405 |
406 def generate_constructor_getter(interface, attribute, contents): | 406 def generate_constructor_getter(interface, attribute, contents): |
407 contents['needs_constructor_getter_callback'] = contents['measure_as'] or co
ntents['deprecate_as'] | 407 contents['needs_constructor_getter_callback'] = contents['measure_as'] or co
ntents['deprecate_as'] |
OLD | NEW |