Issue #618 - Simplify module resolve hook to be a function pointer

This is an ahead-of time port to try and address #1624.
This is based on BZ 1461751 and Jon Coppeard's work in it.
This commit is contained in:
Moonchild 2020-08-06 18:31:36 +00:00 committed by Roy Tam
commit 34db761758
10 changed files with 76 additions and 74 deletions

View file

@ -4325,17 +4325,19 @@ extern JS_PUBLIC_API(bool)
Evaluate(JSContext* cx, const ReadOnlyCompileOptions& options,
const char* filename, JS::MutableHandleValue rval);
/**
* Get the HostResolveImportedModule hook for a global.
*/
extern JS_PUBLIC_API(JSFunction*)
GetModuleResolveHook(JSContext* cx);
using ModuleResolveHook = JSObject* (*)(JSContext*, HandleObject, HandleString);
/**
* Set the HostResolveImportedModule hook for a global to the given function.
* Get the HostResolveImportedModule hook for the runtime.
*/
extern JS_PUBLIC_API(ModuleResolveHook)
GetModuleResolveHook(JSRuntime* rt);
/**
* Set the HostResolveImportedModule hook for the runtime to the given function.
*/
extern JS_PUBLIC_API(void)
SetModuleResolveHook(JSContext* cx, JS::HandleFunction func);
SetModuleResolveHook(JSRuntime* rt, ModuleResolveHook func);
/**
* Parse the given source buffer as a module in the scope of the current global