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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h

Issue 1594653003: Move utilities for V8 extras functions into V8Binding.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1b5bfba84b631827d893e7eb8957264f4eae9c43 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h
+++ b/third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h
@@ -31,6 +31,10 @@
#ifndef V8BindingMacros_h
#define V8BindingMacros_h
+#include "bindings/core/v8/ScriptState.h"
+#include "bindings/core/v8/ScriptValue.h"
yhirano 2016/01/17 23:59:55 Not used?
domenic 2016/01/19 21:41:00 It turns out getExtrasExports returns a ScriptValu
+#include <v8.h>
+
namespace blink {
// type is an instance of class template V8StringResource<>,
@@ -103,6 +107,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();
+ v8::Local<v8::Context> context = scriptState->context();
+ 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 function->Call(context, undefined, numArgs, args);
haraken 2016/01/16 03:54:31 We want to unify all Function::Calls into V8Script
domenic 2016/01/19 21:41:00 Done; PTAL.
+}
+
+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)) { \
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperations.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698