Index: Source/bindings/templates/callback_interface.cpp.tmpl |
diff --git a/Source/bindings/templates/callback_interface.cpp b/Source/bindings/templates/callback_interface.cpp.tmpl |
similarity index 81% |
rename from Source/bindings/templates/callback_interface.cpp |
rename to Source/bindings/templates/callback_interface.cpp.tmpl |
index 21a8969f9e0cbb249e993aca5cac66928f84a3ea..122e2823c5f0c47e2616c67feb5aff07a1a30403 100644 |
--- a/Source/bindings/templates/callback_interface.cpp |
+++ b/Source/bindings/templates/callback_interface.cpp.tmpl |
@@ -54,7 +54,8 @@ namespace WebCore { |
{% for method in methods %} |
{% if not method.custom %} |
-{{method.return_cpp_type}} {{v8_class_name}}::{{method.name}}({{method.argument_declaration}}) |
+{% set this_value_param = 'ScriptValue thisValue, ' if method.call_with_this_handle else '' %} |
+{{method.return_cpp_type}} {{v8_class_name}}::{{method.name}}({{this_value_param}}{{method.argument_declaration}}) |
haraken
2013/08/06 05:02:03
How about putting 'ScriptValue thisValue, ' into m
alancutter (OOO until 2018)
2013/08/07 00:40:24
Done.
|
{ |
if (!canInvokeCallback()) |
return true; |
@@ -68,6 +69,15 @@ namespace WebCore { |
v8::Context::Scope scope(v8Context); |
+{% if method.call_with_this_handle %} |
+ v8::Handle<v8::Value> thisHandle = thisValue.v8Value(); |
+ if (thisHandle.IsEmpty()) { |
+ if (!isScriptControllerTerminating()) |
+ CRASH(); |
+ return true; |
+ } |
+ ASSERT(thisHandle->IsObject()); |
+{% endif %} |
{% for argument in method.arguments %} |
{{argument.cpp_to_js_conversion | indent(4)}} |
if ({{argument.name}}Handle.IsEmpty()) { |
@@ -83,7 +93,8 @@ namespace WebCore { |
{% endif %} |
bool callbackReturnValue = false; |
- return !invokeCallback(m_callback.newLocal(isolate), {{method.arguments | length}}, argv, callbackReturnValue, scriptExecutionContext()); |
+{% set this_handle_param = 'v8::Handle<v8::Object>::Cast(thisHandle), ' if method.call_with_this_handle else '' %} |
+ return !invokeCallback(m_callback.newLocal(isolate), {{this_handle_param}}{{method.arguments | length}}, argv, callbackReturnValue, scriptExecutionContext()); |
haraken
2013/08/06 05:02:03
Ditto. You might want to put 'v8::Handle<v8::Objec
alancutter (OOO until 2018)
2013/08/07 00:40:24
This will change the value of {{method.arguments |
|
} |
{% endif %} |