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

Unified Diff: Source/bindings/scripts/v8_callback_interface.py

Issue 215993002: Clean up callback interface code and template (Closed) 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/templates/callback_interface.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/v8_callback_interface.py
diff --git a/Source/bindings/scripts/v8_callback_interface.py b/Source/bindings/scripts/v8_callback_interface.py
index 506f8161df213fcdcee83291c04bd66cac5de455..e64975a40480d602f4b7a368d405955dbc7c749e 100644
--- a/Source/bindings/scripts/v8_callback_interface.py
+++ b/Source/bindings/scripts/v8_callback_interface.py
@@ -53,16 +53,6 @@ CALLBACK_INTERFACE_CPP_INCLUDES = frozenset([
])
-def cpp_to_v8_conversion(idl_type, name):
- # FIXME: setting creation_context=v8::Handle<v8::Object>() is wrong,
- # as toV8 then implicitly uses the current context, which causes leaks
- # between isolate worlds if a different context should be used.
- cpp_value_to_v8_value = idl_type.cpp_value_to_v8_value(name,
- isolate='m_isolate', creation_context='v8::Handle<v8::Object>()')
- return 'v8::Handle<v8::Value> {name}Handle = {cpp_to_v8};'.format(
- name=name, cpp_to_v8=cpp_value_to_v8_value)
-
-
def cpp_type(idl_type):
# FIXME: remove this function by making callback types consistent
# (always use usual v8_types.cpp_type)
@@ -83,18 +73,14 @@ IdlType.callback_cpp_type = property(cpp_type)
def generate_callback_interface(callback_interface):
includes.clear()
includes.update(CALLBACK_INTERFACE_CPP_INCLUDES)
- name = callback_interface.name
-
- methods = [generate_method(operation)
- for operation in callback_interface.operations]
- template_contents = {
+ return {
'conditional_string': v8_utilities.conditional_string(callback_interface),
- 'cpp_class': name,
+ 'cpp_class': callback_interface.name,
'v8_class': v8_utilities.v8_class_name(callback_interface),
'header_includes': set(CALLBACK_INTERFACE_H_INCLUDES),
- 'methods': methods,
+ 'methods': [generate_method(operation)
+ for operation in callback_interface.operations],
}
- return template_contents
def add_includes_for_operation(operation):
@@ -128,17 +114,21 @@ def generate_method(operation):
def generate_arguments_contents(arguments, call_with_this_handle):
def generate_argument(argument):
return {
- 'name': argument.name,
- 'cpp_to_v8_conversion': cpp_to_v8_conversion(argument.idl_type, argument.name),
+ 'handle': '%sHandle' % argument.name,
+ # FIXME: setting creation_context=v8::Handle<v8::Object>() is
+ # wrong, as toV8 then implicitly uses the current context, which
+ # causes leaks between isolated worlds if a different context is
+ # used.
+ 'cpp_value_to_v8_value': argument.idl_type.cpp_value_to_v8_value(
+ argument.name, isolate='m_isolate',
+ creation_context='v8::Handle<v8::Object>()'),
}
- argument_declarations = [
- '%s %s' % (argument.idl_type.callback_cpp_type, argument.name)
- for argument in arguments]
- if call_with_this_handle:
- argument_declarations.insert(0, 'ScriptValue thisValue')
+ argument_declarations = ['ScriptValue thisValue'] if call_with_this_handle else []
+ argument_declarations.extend(
+ '%s %s' % (argument.idl_type.callback_cpp_type, argument.name)
+ for argument in arguments)
return {
'argument_declarations': argument_declarations,
'arguments': [generate_argument(argument) for argument in arguments],
- 'handles': ['%sHandle' % argument.name for argument in arguments],
}
« no previous file with comments | « no previous file | Source/bindings/templates/callback_interface.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698