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

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

Issue 204213002: Replace custom EventTarget toNative call with [ToNativeArg] extended attribute Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 'octet': 'toUInt8({arguments})', 329 'octet': 'toUInt8({arguments})',
330 'short': 'toInt16({arguments})', 330 'short': 'toInt16({arguments})',
331 'unsigned short': 'toUInt16({arguments})', 331 'unsigned short': 'toUInt16({arguments})',
332 'long': 'toInt32({arguments})', 332 'long': 'toInt32({arguments})',
333 'unsigned long': 'toUInt32({arguments})', 333 'unsigned long': 'toUInt32({arguments})',
334 'long long': 'toInt64({arguments})', 334 'long long': 'toInt64({arguments})',
335 'unsigned long long': 'toUInt64({arguments})', 335 'unsigned long long': 'toUInt64({arguments})',
336 # Interface types 336 # Interface types
337 'CompareHow': 'static_cast<Range::CompareHow>({v8_value}->Int32Value())', 337 'CompareHow': 'static_cast<Range::CompareHow>({v8_value}->Int32Value())',
338 'Dictionary': 'Dictionary({v8_value}, info.GetIsolate())', 338 'Dictionary': 'Dictionary({v8_value}, info.GetIsolate())',
339 # FIXME: EventListener is special-cased in templates instead, because 339 'EventListener': 'V8EventListenerList::getEventListener({v8_value}, false, { arguments})',
340 # removeEventListener uses ListenerFindOnly (only use) instead of
341 # ListenerFindOrCreate.
342 # 'EventListener': 'V8EventListenerList::getEventListener({v8_value}, false, ListenerFindOrCreate/ListenerFindOnly)'
343 'EventTarget': 'V8DOMWrapper::isDOMWrapper({v8_value}) ? toWrapperTypeInfo(v 8::Handle<v8::Object>::Cast({v8_value}))->toEventTarget(v8::Handle<v8::Object>:: Cast({v8_value})) : 0', 340 'EventTarget': 'V8DOMWrapper::isDOMWrapper({v8_value}) ? toWrapperTypeInfo(v 8::Handle<v8::Object>::Cast({v8_value}))->toEventTarget(v8::Handle<v8::Object>:: Cast({v8_value})) : 0',
344 'MediaQueryListListener': 'MediaQueryListListener::create(ScriptValue({v8_va lue}, info.GetIsolate()))', 341 'MediaQueryListListener': 'MediaQueryListListener::create(ScriptValue({v8_va lue}, info.GetIsolate()))',
345 'NodeFilter': 'toNodeFilter({v8_value}, info.GetIsolate())', 342 'NodeFilter': 'toNodeFilter({v8_value}, info.GetIsolate())',
346 'Promise': 'ScriptPromise({v8_value}, info.GetIsolate())', 343 'Promise': 'ScriptPromise({v8_value}, info.GetIsolate())',
347 'SerializedScriptValue': 'SerializedScriptValue::create({v8_value}, info.Get Isolate())', 344 'SerializedScriptValue': 'SerializedScriptValue::create({v8_value}, info.Get Isolate())',
348 'ScriptValue': 'ScriptValue({v8_value}, info.GetIsolate())', 345 'ScriptValue': 'ScriptValue({v8_value}, info.GetIsolate())',
349 'Window': 'toDOMWindow({v8_value}, info.GetIsolate())', 346 'Window': 'toDOMWindow({v8_value}, info.GetIsolate())',
350 'XPathNSResolver': 'toXPathNSResolver({v8_value}, info.GetIsolate())', 347 'XPathNSResolver': 'toXPathNSResolver({v8_value}, info.GetIsolate())',
351 } 348 }
352 349
353 350
354 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index): 351 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index):
355 # Composite types 352 # Composite types
356 array_or_sequence_type = idl_type.array_or_sequence_type 353 array_or_sequence_type = idl_type.array_or_sequence_type
357 if array_or_sequence_type: 354 if array_or_sequence_type:
358 return v8_value_to_cpp_value_array_or_sequence(array_or_sequence_type, v 8_value, index) 355 return v8_value_to_cpp_value_array_or_sequence(array_or_sequence_type, v 8_value, index)
359 356
360 # Simple types 357 # Simple types
361 idl_type = idl_type.preprocessed_type 358 idl_type = idl_type.preprocessed_type
362 add_includes_for_type(idl_type) 359 add_includes_for_type(idl_type)
363 base_idl_type = idl_type.base_type 360 base_idl_type = idl_type.base_type
364 361
365 if 'EnforceRange' in extended_attributes: 362 if 'ToNativeArg' in extended_attributes:
363 arguments = extended_attributes['ToNativeArg']
364 elif 'EnforceRange' in extended_attributes:
366 arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState']) 365 arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState'])
367 elif idl_type.is_integer_type: # NormalConversion 366 elif idl_type.is_integer_type: # NormalConversion
368 arguments = ', '.join([v8_value, 'exceptionState']) 367 arguments = ', '.join([v8_value, 'exceptionState'])
369 else: 368 else:
370 arguments = v8_value 369 arguments = v8_value
371 370
372 if base_idl_type in V8_VALUE_TO_CPP_VALUE: 371 if base_idl_type in V8_VALUE_TO_CPP_VALUE:
373 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type] 372 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type]
374 elif idl_type.is_typed_array_type: 373 elif idl_type.is_typed_array_type:
375 cpp_expression_format = ( 374 cpp_expression_format = (
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea tion_context='', extended_attributes=None): 605 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea tion_context='', extended_attributes=None):
607 """Returns an expression that converts a C++ value to a V8 value.""" 606 """Returns an expression that converts a C++ value to a V8 value."""
608 # the isolate parameter is needed for callback interfaces 607 # the isolate parameter is needed for callback interfaces
609 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext ended_attributes) 608 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext ended_attributes)
610 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes) 609 this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes)
611 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] 610 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type]
612 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat ion_context=creation_context) 611 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat ion_context=creation_context)
613 return statement 612 return statement
614 613
615 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value 614 IdlType.cpp_value_to_v8_value = cpp_value_to_v8_value
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698