mirror of
https://github.com/nodejs/node.git
synced 2026-12-06 07:58:50 -05:00
vm: implement isContext() directly in JS land with private symbol
We are now directly checking the existence of a private symbol in the object to determine if an object is a ContextifyContext anyway, so there is no need to implement it in C++ anymore. PR-URL: https://github.com/nodejs/node/pull/51685 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
This commit is contained in:
1 parent
68fd5cbd5a
commit
ec3c7bc2c4
4 files changed
+22
-24
No files matched your search
@@ -342,7 +342,6 @@ void ContextifyContext::CreatePerIsolateProperties(
|
||||
IsolateData* isolate_data, Local<ObjectTemplate> target) {
|
||||
Isolate* isolate = isolate_data->isolate();
|
||||
SetMethod(isolate, target, "makeContext", MakeContext);
|
||||
SetMethod(isolate, target, "isContext", IsContext);
|
||||
SetMethod(isolate, target, "compileFunction", CompileFunction);
|
||||
SetMethod(isolate, target, "containsModuleSyntax", ContainsModuleSyntax);
|
||||
}
|
||||
@@ -350,7 +349,6 @@ void ContextifyContext::CreatePerIsolateProperties(
|
||||
void ContextifyContext::RegisterExternalReferences(
|
||||
ExternalReferenceRegistry* registry) {
|
||||
registry->Register(MakeContext);
|
||||
registry->Register(IsContext);
|
||||
registry->Register(CompileFunction);
|
||||
registry->Register(ContainsModuleSyntax);
|
||||
registry->Register(PropertyGetterCallback);
|
||||
@@ -415,20 +413,6 @@ void ContextifyContext::MakeContext(const FunctionCallbackInfo<Value>& args) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ContextifyContext::IsContext(const FunctionCallbackInfo<Value>& args) {
|
||||
Environment* env = Environment::GetCurrent(args);
|
||||
|
||||
CHECK(args[0]->IsObject());
|
||||
Local<Object> sandbox = args[0].As<Object>();
|
||||
|
||||
Maybe<bool> result =
|
||||
sandbox->HasPrivate(env->context(),
|
||||
env->contextify_context_private_symbol());
|
||||
args.GetReturnValue().Set(result.FromJust());
|
||||
}
|
||||
|
||||
|
||||
void ContextifyContext::WeakCallback(
|
||||
const WeakCallbackInfo<ContextifyContext>& data) {
|
||||
ContextifyContext* context = data.GetParameter();
|
||||
|
||||
Reference in new issue
Block a user