From 5a7e77c8ead109e6c2b17b760d0cb4c868957798 Mon Sep 17 00:00:00 2001 From: Jeroen Ooms Date: Sat, 5 Oct 2024 20:56:29 +0200 Subject: [PATCH] Refactor --- src/bindings.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/bindings.cpp b/src/bindings.cpp index de74808..c67795f 100644 --- a/src/bindings.cpp +++ b/src/bindings.cpp @@ -104,6 +104,8 @@ static v8::MaybeLocal dynamic_module_loader(v8::Local return promise; } +#if V8_VERSION_TOTAL >= 908 + static v8::MaybeLocal ResolveDynamicModuleCallback( v8::Local context, v8::Local host_defined_options, @@ -113,13 +115,17 @@ static v8::MaybeLocal ResolveDynamicModuleCallback( return dynamic_module_loader(context, specifier); } -static v8::MaybeLocal ResolveDynamicModuleCallbackLegacy( +#else + +static v8::MaybeLocal ResolveDynamicModuleCallback( v8::Local context, v8::Local referrer, v8::Local specifier) { return dynamic_module_loader(context, specifier); } +#endif + /* Helper fun that compiles JavaScript source code */ static v8::Local read_module(std::string filename, v8::Local context){ v8::Local source_text = ToJSString(read_text(filename).c_str()); @@ -179,11 +185,7 @@ void start_v8_isolate(void *dll){ uintptr_t CurrentStackPosition = reinterpret_cast(__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 */