mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
src: split property helpers from node::Environment
PR-URL: https://github.com/nodejs/node/pull/44056 Backport-PR-URL: https://github.com/nodejs/node/pull/44251 Refs: https://github.com/nodejs/node/issues/42528 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Feng Yu <F3n67u@outlook.com>
This commit is contained in:
1 parent
e028edb17d
commit
68ee8e9089
79 files changed
+1468
-1256
No files matched your search
+21
-15
@@ -255,16 +255,19 @@ MaybeLocal<Context> ContextifyContext::CreateV8Context(
|
||||
|
||||
|
||||
void ContextifyContext::Init(Environment* env, Local<Object> target) {
|
||||
Isolate* isolate = env->isolate();
|
||||
Local<Context> context = env->context();
|
||||
|
||||
Local<FunctionTemplate> function_template =
|
||||
FunctionTemplate::New(env->isolate());
|
||||
NewFunctionTemplate(isolate, nullptr);
|
||||
function_template->InstanceTemplate()->SetInternalFieldCount(
|
||||
ContextifyContext::kInternalFieldCount);
|
||||
env->set_script_data_constructor_function(
|
||||
function_template->GetFunction(env->context()).ToLocalChecked());
|
||||
|
||||
env->SetMethod(target, "makeContext", MakeContext);
|
||||
env->SetMethod(target, "isContext", IsContext);
|
||||
env->SetMethod(target, "compileFunction", CompileFunction);
|
||||
SetMethod(context, target, "makeContext", MakeContext);
|
||||
SetMethod(context, target, "isContext", IsContext);
|
||||
SetMethod(context, target, "compileFunction", CompileFunction);
|
||||
}
|
||||
|
||||
void ContextifyContext::RegisterExternalReferences(
|
||||
@@ -657,16 +660,17 @@ void ContextifyContext::IndexedPropertyDeleterCallback(
|
||||
}
|
||||
|
||||
void ContextifyScript::Init(Environment* env, Local<Object> target) {
|
||||
Isolate* isolate = env->isolate();
|
||||
HandleScope scope(env->isolate());
|
||||
Local<String> class_name =
|
||||
FIXED_ONE_BYTE_STRING(env->isolate(), "ContextifyScript");
|
||||
|
||||
Local<FunctionTemplate> script_tmpl = env->NewFunctionTemplate(New);
|
||||
Local<FunctionTemplate> script_tmpl = NewFunctionTemplate(isolate, New);
|
||||
script_tmpl->InstanceTemplate()->SetInternalFieldCount(
|
||||
ContextifyScript::kInternalFieldCount);
|
||||
script_tmpl->SetClassName(class_name);
|
||||
env->SetProtoMethod(script_tmpl, "createCachedData", CreateCachedData);
|
||||
env->SetProtoMethod(script_tmpl, "runInContext", RunInContext);
|
||||
SetProtoMethod(isolate, script_tmpl, "createCachedData", CreateCachedData);
|
||||
SetProtoMethod(isolate, script_tmpl, "runInContext", RunInContext);
|
||||
|
||||
Local<Context> context = env->context();
|
||||
|
||||
@@ -1262,12 +1266,14 @@ void MicrotaskQueueWrap::New(const FunctionCallbackInfo<Value>& args) {
|
||||
}
|
||||
|
||||
void MicrotaskQueueWrap::Init(Environment* env, Local<Object> target) {
|
||||
HandleScope scope(env->isolate());
|
||||
Local<FunctionTemplate> tmpl = env->NewFunctionTemplate(New);
|
||||
Isolate* isolate = env->isolate();
|
||||
HandleScope scope(isolate);
|
||||
Local<Context> context = env->context();
|
||||
Local<FunctionTemplate> tmpl = NewFunctionTemplate(isolate, New);
|
||||
tmpl->InstanceTemplate()->SetInternalFieldCount(
|
||||
ContextifyScript::kInternalFieldCount);
|
||||
env->set_microtask_queue_ctor_template(tmpl);
|
||||
env->SetConstructorFunction(target, "MicrotaskQueue", tmpl);
|
||||
SetConstructorFunction(context, target, "MicrotaskQueue", tmpl);
|
||||
}
|
||||
|
||||
void MicrotaskQueueWrap::RegisterExternalReferences(
|
||||
@@ -1285,11 +1291,11 @@ void Initialize(Local<Object> target,
|
||||
ContextifyScript::Init(env, target);
|
||||
MicrotaskQueueWrap::Init(env, target);
|
||||
|
||||
env->SetMethod(target, "startSigintWatchdog", StartSigintWatchdog);
|
||||
env->SetMethod(target, "stopSigintWatchdog", StopSigintWatchdog);
|
||||
SetMethod(context, target, "startSigintWatchdog", StartSigintWatchdog);
|
||||
SetMethod(context, target, "stopSigintWatchdog", StopSigintWatchdog);
|
||||
// Used in tests.
|
||||
env->SetMethodNoSideEffect(
|
||||
target, "watchdogHasPendingSigint", WatchdogHasPendingSigint);
|
||||
SetMethodNoSideEffect(
|
||||
context, target, "watchdogHasPendingSigint", WatchdogHasPendingSigint);
|
||||
|
||||
{
|
||||
Local<FunctionTemplate> tpl = FunctionTemplate::New(env->isolate());
|
||||
@@ -1325,7 +1331,7 @@ void Initialize(Local<Object> target,
|
||||
|
||||
target->Set(context, env->constants_string(), constants).Check();
|
||||
|
||||
env->SetMethod(target, "measureMemory", MeasureMemory);
|
||||
SetMethod(context, target, "measureMemory", MeasureMemory);
|
||||
}
|
||||
|
||||
void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
|
||||
|
||||
Reference in new issue
Block a user