mirror of https://github.com/nodejs/node.git
src: add way to get IsolateData and allocator from Environment
Add a way to get the current `IsolateData*` and, from it, the current Node.js `ArrayBufferAllocator` if there is one. This can be useful for re-using either one of these structures as an embedder. PR-URL: https://github.com/nodejs/node/pull/36441 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>pull/36509/head
parent
7069d22343
commit
d313bf7d47
|
@ -438,6 +438,14 @@ Environment* GetCurrentEnvironment(Local<Context> context) {
|
|||
return Environment::GetCurrent(context);
|
||||
}
|
||||
|
||||
IsolateData* GetEnvironmentIsolateData(Environment* env) {
|
||||
return env->isolate_data();
|
||||
}
|
||||
|
||||
ArrayBufferAllocator* GetArrayBufferAllocator(IsolateData* isolate_data) {
|
||||
return isolate_data->node_allocator();
|
||||
}
|
||||
|
||||
MultiIsolatePlatform* GetMultiIsolatePlatform(Environment* env) {
|
||||
return GetMultiIsolatePlatform(env->isolate_data());
|
||||
}
|
||||
|
|
|
@ -464,6 +464,8 @@ NODE_EXTERN void DefaultProcessExitHandler(Environment* env, int exit_code);
|
|||
|
||||
// This may return nullptr if context is not associated with a Node instance.
|
||||
NODE_EXTERN Environment* GetCurrentEnvironment(v8::Local<v8::Context> context);
|
||||
NODE_EXTERN IsolateData* GetEnvironmentIsolateData(Environment* env);
|
||||
NODE_EXTERN ArrayBufferAllocator* GetArrayBufferAllocator(IsolateData* data);
|
||||
|
||||
NODE_EXTERN void OnFatalError(const char* location, const char* message);
|
||||
NODE_EXTERN void PromiseRejectCallback(v8::PromiseRejectMessage message);
|
||||
|
|
|
@ -586,6 +586,9 @@ TEST_F(NodeZeroIsolateTestFixture, CtrlCWithOnlySafeTerminationTest) {
|
|||
{}),
|
||||
node::FreeEnvironment};
|
||||
CHECK(environment);
|
||||
EXPECT_EQ(node::GetEnvironmentIsolateData(environment.get()),
|
||||
isolate_data.get());
|
||||
EXPECT_EQ(node::GetArrayBufferAllocator(isolate_data.get()), nullptr);
|
||||
|
||||
v8::Local<v8::Value> main_ret =
|
||||
node::LoadEnvironment(environment.get(),
|
||||
|
|
Loading…
Reference in New Issue