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

Unified Diff: src/api.cc

Issue 2162443002: Add API to create a "remote" instance of a given FunctionTemplate (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 5 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 | « include/v8.h ('k') | src/api-natives.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 93c6e3f1478bc7887bf662f6b399f7fb2b1137e8..89afa3e4afcd731dbba58d0d82019b0f81eab36c 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -5953,6 +5953,32 @@ Local<v8::Function> FunctionTemplate::GetFunction() {
RETURN_TO_LOCAL_UNCHECKED(GetFunction(context), Function);
}
+MaybeLocal<v8::Object> FunctionTemplate::NewRemoteInstance() {
+ auto self = Utils::OpenHandle(this);
+ i::Isolate* isolate = self->GetIsolate();
+ LOG_API(isolate, FunctionTemplate, NewRemoteInstance);
+ i::HandleScope scope(isolate);
+ i::Handle<i::FunctionTemplateInfo> constructor =
+ EnsureConstructor(isolate, *InstanceTemplate());
+ Utils::ApiCheck(constructor->needs_access_check(),
+ "v8::FunctionTemplate::NewRemoteInstance",
+ "InstanceTemplate needs to have access checks enabled.");
+ i::Handle<i::AccessCheckInfo> access_check_info = i::handle(
+ i::AccessCheckInfo::cast(constructor->access_check_info()), isolate);
+ Utils::ApiCheck(access_check_info->named_interceptor() != nullptr,
+ "v8::FunctionTemplate::NewRemoteInstance",
+ "InstanceTemplate needs to have access check handlers.");
+ i::Handle<i::JSObject> object;
+ if (!i::ApiNatives::InstantiateRemoteObject(
+ Utils::OpenHandle(*InstanceTemplate()))
+ .ToHandle(&object)) {
+ if (isolate->has_pending_exception()) {
+ isolate->OptionalRescheduleException(true);
+ }
+ return MaybeLocal<Object>();
+ }
+ return Utils::ToLocal(scope.CloseAndEscape(object));
+}
bool FunctionTemplate::HasInstance(v8::Local<v8::Value> value) {
auto self = Utils::OpenHandle(this);
« no previous file with comments | « include/v8.h ('k') | src/api-natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698