mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-19 00:36:33 +00:00
Berry 'introspect.module' option to not cache module entry (#23451)
This commit is contained in:
parent
6a27899241
commit
7ce3ba376c
@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file.
|
||||
- HASPmota auto-dimming when no touch (#23425)
|
||||
- Provide serial upload port from VSC to PIO (#23436)
|
||||
- Berry support for `sortedmap` (#23441)
|
||||
- Berry `introspect.module` option to not cache module entry
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
|
@ -182,7 +182,11 @@ static int m_getmodule(bvm *vm)
|
||||
if (top >= 1) {
|
||||
bvalue *v = be_indexof(vm, 1);
|
||||
if (var_isstr(v)) {
|
||||
int ret = be_module_load(vm, var_tostr(v));
|
||||
bbool no_cache = bfalse;
|
||||
if (top >= 2) {
|
||||
no_cache = be_tobool(vm, 2);
|
||||
}
|
||||
int ret = be_module_load_nocache(vm, var_tostr(v), no_cache);
|
||||
if (ret == BE_OK) {
|
||||
be_return(vm);
|
||||
}
|
||||
|
@ -278,8 +278,8 @@ static void module_init(bvm *vm) {
|
||||
}
|
||||
}
|
||||
|
||||
/* load module to vm->top */
|
||||
int be_module_load(bvm *vm, bstring *path)
|
||||
/* load module to vm->top, option to cache or not */
|
||||
int be_module_load_nocache(bvm *vm, bstring *path, bbool nocache)
|
||||
{
|
||||
int res = BE_OK;
|
||||
if (!load_cached(vm, path)) {
|
||||
@ -287,14 +287,22 @@ int be_module_load(bvm *vm, bstring *path)
|
||||
if (res == BE_IO_ERROR)
|
||||
res = load_package(vm, path);
|
||||
if (res == BE_OK) {
|
||||
/* on first load of the module, try running the '()' function */
|
||||
/* on first load of the module, try running the 'init' function */
|
||||
module_init(vm);
|
||||
be_cache_module(vm, path);
|
||||
if (!nocache) { /* cache the module if it is loaded successfully */
|
||||
be_cache_module(vm, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/* load module to vm->top */
|
||||
int be_module_load(bvm *vm, bstring *path)
|
||||
{
|
||||
return be_module_load_nocache(vm, path, btrue);
|
||||
}
|
||||
|
||||
BERRY_API bbool be_getmodule(bvm *vm, const char *k)
|
||||
{
|
||||
int res = be_module_load(vm, be_newstr(vm, k));
|
||||
|
@ -34,6 +34,7 @@ typedef struct bmodule {
|
||||
bmodule* be_module_new(bvm *vm);
|
||||
void be_module_delete(bvm *vm, bmodule *module);
|
||||
int be_module_load(bvm *vm, bstring *path);
|
||||
int be_module_load_nocache(bvm *vm, bstring *path, bbool cache);
|
||||
void be_cache_module(bvm *vm, bstring *name);
|
||||
int be_module_attr(bvm *vm, bmodule *module, bstring *attr, bvalue *dst);
|
||||
bbool be_module_setmember(bvm *vm, bmodule *module, bstring *attr, bvalue *src);
|
||||
|
Loading…
x
Reference in New Issue
Block a user