Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Oct 5, 2024
1 parent 9e47d40 commit 5a7e77c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ static v8::MaybeLocal<v8::Promise> dynamic_module_loader(v8::Local<v8::Context>
return promise;
}

#if V8_VERSION_TOTAL >= 908

static v8::MaybeLocal<v8::Promise> ResolveDynamicModuleCallback(
v8::Local<v8::Context> context,
v8::Local<v8::Data> host_defined_options,
Expand All @@ -113,13 +115,17 @@ static v8::MaybeLocal<v8::Promise> ResolveDynamicModuleCallback(
return dynamic_module_loader(context, specifier);
}

static v8::MaybeLocal<v8::Promise> ResolveDynamicModuleCallbackLegacy(
#else

static v8::MaybeLocal<v8::Promise> ResolveDynamicModuleCallback(
v8::Local<v8::Context> context,
v8::Local<v8::ScriptOrModule> referrer,
v8::Local<v8::String> specifier) {
return dynamic_module_loader(context, specifier);
}

#endif

/* Helper fun that compiles JavaScript source code */
static v8::Local<v8::Module> read_module(std::string filename, v8::Local<v8::Context> context){
v8::Local<v8::String> source_text = ToJSString(read_text(filename).c_str());
Expand Down Expand Up @@ -179,11 +185,7 @@ void start_v8_isolate(void *dll){
uintptr_t CurrentStackPosition = reinterpret_cast<uintptr_t>(__builtin_frame_address(0));
isolate->SetStackLimit(CurrentStackPosition - kWorkerMaxStackSize);
#endif
#if V8_VERSION_TOTAL >= 908
isolate->SetHostImportModuleDynamicallyCallback(ResolveDynamicModuleCallback);
#else
isolate->SetHostImportModuleDynamicallyCallback(ResolveDynamicModuleCallbackLegacy);
#endif
}

/* Helper fun that compiles JavaScript source code */
Expand Down

0 comments on commit 5a7e77c

Please sign in to comment.