Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: register zlib external references for snapshot #40050

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/node_external_reference.h
Expand Up @@ -81,6 +81,7 @@ class ExternalReferenceRegistry {
V(types) \
V(uv) \
V(v8) \
V(zlib) \
V(worker)

#if NODE_HAVE_I18N_SUPPORT
Expand Down
18 changes: 18 additions & 0 deletions src/node_zlib.cc
Expand Up @@ -25,6 +25,7 @@

#include "async_wrap-inl.h"
#include "env-inl.h"
#include "node_external_reference.h"
#include "threadpoolwork-inl.h"
#include "util-inl.h"

Expand Down Expand Up @@ -1266,6 +1267,16 @@ struct MakeClass {

env->SetConstructorFunction(target, name, z);
}

static void Make(ExternalReferenceRegistry* registry) {
registry->Register(Stream::New);
registry->Register(Stream::template Write<true>);
registry->Register(Stream::template Write<false>);
registry->Register(Stream::Close);
registry->Register(Stream::Init);
registry->Register(Stream::Params);
registry->Register(Stream::Reset);
}
};

void Initialize(Local<Object> target,
Expand All @@ -1283,6 +1294,12 @@ void Initialize(Local<Object> target,
FIXED_ONE_BYTE_STRING(env->isolate(), ZLIB_VERSION)).Check();
}

void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
MakeClass<ZlibStream>::Make(registry);
MakeClass<BrotliEncoderStream>::Make(registry);
MakeClass<BrotliDecoderStream>::Make(registry);
}

} // anonymous namespace

void DefineZlibConstants(Local<Object> target) {
Expand Down Expand Up @@ -1408,3 +1425,4 @@ void DefineZlibConstants(Local<Object> target) {
} // namespace node

NODE_MODULE_CONTEXT_AWARE_INTERNAL(zlib, node::Initialize)
NODE_MODULE_EXTERNAL_REFERENCE(zlib, node::RegisterExternalReferences)