Skip to content

Commit

Permalink
src: register zlib external references for snapshot
Browse files Browse the repository at this point in the history
PR-URL: #40050
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Tobias Nießen <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Khaidi Chu <[email protected]>
  • Loading branch information
joyeecheung authored and BethGriggs committed Sep 21, 2021
1 parent 81cb14b commit 31994fb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/node_external_reference.h
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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)

0 comments on commit 31994fb

Please sign in to comment.