Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h b/third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h |
| index 3b55b06f35914fa096a57ab701b88beba9dff105..aaaab4939bf85c87b03893c7516b8fa9dd79dfe8 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h |
| +++ b/third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h |
| @@ -31,6 +31,11 @@ |
| #ifndef V8BindingMacros_h |
| #define V8BindingMacros_h |
| +#include "bindings/core/v8/ScriptState.h" |
| +#include "bindings/core/v8/ScriptValue.h" |
| +#include "bindings/core/v8/V8ScriptRunner.h" |
|
haraken
2016/01/19 21:49:48
Hmm, V8BindingMacros.h is intended to be a collect
|
| +#include <v8.h> |
| + |
| namespace blink { |
| // type is an instance of class template V8StringResource<>, |
| @@ -103,6 +108,30 @@ inline v8::Local<T> v8CallOrCrash(v8::MaybeLocal<T> maybeLocal) |
| return maybeLocal.ToLocalChecked(); |
| } |
| +// These are utiltiies for calling functions added to the V8 extras binding object. |
| + |
| +inline v8::MaybeLocal<v8::Value> v8CallExtraHelper(ScriptState* scriptState, const char* name, size_t numArgs, v8::Local<v8::Value>* args) |
| +{ |
| + v8::Isolate* isolate = scriptState->isolate(); |
| + ExecutionContext* ec = scriptState->executionContext(); |
| + v8::Local<v8::Value> undefined = v8::Undefined(isolate); |
| + v8::Local<v8::Value> functionValue = scriptState->getFromExtrasExports(name).v8Value(); |
| + v8::Local<v8::Function> function = functionValue.As<v8::Function>(); |
| + return V8ScriptRunner::callFunction(function, ec, undefined, numArgs, args, isolate); |
| +} |
| + |
| +template <size_t N> |
| +v8::MaybeLocal<v8::Value> v8CallExtra(ScriptState* scriptState, const char* name, v8::Local<v8::Value>(&args)[N]) |
| +{ |
| + return v8CallExtraHelper(scriptState, name, N, args); |
| +} |
| + |
| +template <size_t N> |
| +v8::Local<v8::Value> v8CallExtraOrCrash(ScriptState* scriptState, const char* name, v8::Local<v8::Value>(&args)[N]) |
| +{ |
| + return v8CallOrCrash(v8CallExtraHelper(scriptState, name, N, args)); |
| +} |
| + |
| // The last "else" is to avoid dangling else problem. |
| #define V8_CALL(outVariable, handle, methodCall, failureExpression) \ |
| if (handle.IsEmpty() || !v8Call(handle->methodCall, outVariable)) { \ |