mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
Allow hosts with no module loader to still load optional modules.
If the host doesn't set a loadModuleFn at all in the config, it should still be able to load random, meta, etc.
This commit is contained in:
@ -1339,10 +1339,15 @@ Value wrenImportModule(WrenVM* vm, Value name)
|
||||
{
|
||||
// If the module is already loaded, we don't need to do anything.
|
||||
if (!IS_UNDEFINED(wrenMapGet(vm->modules, name))) return NULL_VAL;
|
||||
|
||||
// Load the module's source code from the host.
|
||||
const char* source = vm->config.loadModuleFn(vm, AS_CSTRING(name));
|
||||
|
||||
|
||||
const char* source = NULL;
|
||||
|
||||
// Let the host try to provide the module.
|
||||
if (vm->config.loadModuleFn != NULL)
|
||||
{
|
||||
source = vm->config.loadModuleFn(vm, AS_CSTRING(name));
|
||||
}
|
||||
|
||||
// If the host didn't provide it, see if it's a built in optional module.
|
||||
if (source == NULL)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user