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

Unified Diff: third_party/WebKit/Source/bindings/scripts/v8_types.py

Issue 2312093003: Generated bindings for IDL callback functions (Closed)
Patch Set: Addressed comments Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/scripts/v8_types.py
diff --git a/third_party/WebKit/Source/bindings/scripts/v8_types.py b/third_party/WebKit/Source/bindings/scripts/v8_types.py
index 08ffb704751d77a0b2702dd343083d8b4fbbabcc..22d41a931a795e10cdc1289373b0b165ae4344f0 100644
--- a/third_party/WebKit/Source/bindings/scripts/v8_types.py
+++ b/third_party/WebKit/Source/bindings/scripts/v8_types.py
@@ -212,7 +212,10 @@ def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_rvalue_
idl_type_name = "Or".join(member_cpp_name(member)
for member in idl_type.member_types)
return 'const %s&' % idl_type_name if used_as_rvalue_type else idl_type_name
-
+ if idl_type.is_experimental_callback_function:
+ return 'V8' + base_idl_type + '*'
+ if base_idl_type == 'void':
+ return base_idl_type
# Default, assume native type is a pointer with same type name as idl type
return base_idl_type + '*'
@@ -381,6 +384,9 @@ def includes_for_type(idl_type, extended_attributes=None):
if base_idl_type.endswith('Constructor'):
# FIXME: replace with a [ConstructorAttribute] extended attribute
base_idl_type = idl_type.constructor_type_name
+ if idl_type.is_experimental_callback_function:
+ component = IdlType.experimental_callback_functions[base_idl_type]['component_dir']
+ return set(['bindings/%s/v8/V8%s.h' % (component, base_idl_type)])
if base_idl_type not in component_dir:
return set()
return set(['bindings/%s/v8/V8%s.h' % (component_dir[base_idl_type],
@@ -573,6 +579,9 @@ def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, variable_name
cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {variable_name}, %s, exceptionState)' % nullable
elif idl_type.use_output_parameter_for_result:
cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {variable_name}, exceptionState)'
+ elif idl_type.is_experimental_callback_function:
+ cpp_expression_format = (
+ 'V8{idl_type}::create({isolate}, v8::Local<v8::Function>::Cast({v8_value}))')
else:
cpp_expression_format = (
'V8{idl_type}::toImplWithTypeCheck({isolate}, {v8_value})')
@@ -641,7 +650,7 @@ def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl
check_expression = '!%s.prepare(exceptionState)' % variable_name
else:
check_expression = '!%s.prepare()' % variable_name
- elif not idl_type.v8_conversion_is_trivial:
+ elif not idl_type.v8_conversion_is_trivial and not idl_type.is_callback_function:
return {
'error_message': 'no V8 -> C++ conversion for IDL type: %s' % idl_type.name
}
@@ -688,6 +697,8 @@ def preprocess_idl_type(idl_type):
if idl_type.is_enum:
# Enumerations are internally DOMStrings
return IdlType('DOMString')
+ if idl_type.is_experimental_callback_function:
+ return idl_type
if idl_type.base_type in ['any', 'object'] or idl_type.is_callback_function:
return IdlType('ScriptValue')
return idl_type

Powered by Google App Engine
This is Rietveld 408576698