mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
src: create per isolate proxy env template
PR-URL: https://github.com/nodejs/node/pull/48655 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
This commit is contained in:
1 parent
91aa9dd23a
commit
aadff07e59
4 files changed
+7
-4
No files matched your search
@@ -501,6 +501,7 @@ void IsolateData::CreateProperties() {
|
||||
binding::CreateInternalBindingTemplates(this);
|
||||
|
||||
contextify::ContextifyContext::InitializeGlobalTemplates(this);
|
||||
CreateEnvProxyTemplate(this);
|
||||
}
|
||||
|
||||
constexpr uint16_t kDefaultCppGCEmebdderID = 0x90de;
|
||||
|
||||
+2
-1
@@ -456,7 +456,8 @@ static void EnvDefiner(Local<Name> property,
|
||||
}
|
||||
}
|
||||
|
||||
void CreateEnvProxyTemplate(Isolate* isolate, IsolateData* isolate_data) {
|
||||
void CreateEnvProxyTemplate(IsolateData* isolate_data) {
|
||||
Isolate* isolate = isolate_data->isolate();
|
||||
HandleScope scope(isolate);
|
||||
if (!isolate_data->env_proxy_template().IsEmpty()) return;
|
||||
Local<FunctionTemplate> env_proxy_ctor_template =
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ class MemoryTracker;
|
||||
class ExternalReferenceRegistry;
|
||||
class Realm;
|
||||
|
||||
void CreateEnvProxyTemplate(v8::Isolate* isolate, IsolateData* isolate_data);
|
||||
void CreateEnvProxyTemplate(IsolateData* isolate_data);
|
||||
|
||||
// Most of the time, it's best to use `console.error` to write
|
||||
// to the process.stderr stream. However, in some cases, such as
|
||||
|
||||
+3
-2
@@ -344,10 +344,11 @@ MaybeLocal<Value> PrincipalRealm::BootstrapRealm() {
|
||||
return MaybeLocal<Value>();
|
||||
}
|
||||
|
||||
// Setup process.env proxy.
|
||||
Local<String> env_string = FIXED_ONE_BYTE_STRING(isolate_, "env");
|
||||
Local<Object> env_proxy;
|
||||
CreateEnvProxyTemplate(isolate_, env_->isolate_data());
|
||||
if (!env_->env_proxy_template()->NewInstance(context()).ToLocal(&env_proxy) ||
|
||||
if (!isolate_data()->env_proxy_template()->NewInstance(context()).ToLocal(
|
||||
&env_proxy) ||
|
||||
process_object()->Set(context(), env_string, env_proxy).IsNothing()) {
|
||||
return MaybeLocal<Value>();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user