Berry add 'cb.free_cb' for extension manager (#24014)
This commit is contained in:
parent
c463ba608d
commit
7a06aa2cfe
@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.
|
|||||||
## [15.1.0.1]
|
## [15.1.0.1]
|
||||||
### Added
|
### Added
|
||||||
- TLS enabled ECDSA by default for ESP8266 (#24009)
|
- TLS enabled ECDSA by default for ESP8266 (#24009)
|
||||||
|
- Berry add `cb.free_cb` for extension manager
|
||||||
|
|
||||||
### Breaking Changed
|
### Breaking Changed
|
||||||
|
|
||||||
|
|||||||
@ -343,6 +343,50 @@ static int call_berry_cb(int num, int v0, int v1, int v2, int v3, int v4) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************************************************************************************\
|
||||||
|
* Free a cb by function pointer
|
||||||
|
\*********************************************************************************************/
|
||||||
|
static int be_cb_free_cb(bvm *vm) {
|
||||||
|
int32_t top = be_top(vm);
|
||||||
|
#if BE_MAPPING_ENABLE_INPUT_VALIDATION
|
||||||
|
// SECURITY: Input validation
|
||||||
|
if (top < 1) {
|
||||||
|
be_raise(vm, "value_error", "gen_cb requires at least 1 argument");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!be_iscomptr(vm, 1)) {
|
||||||
|
be_raise(vm, "value_error", "arg must be a comptr");
|
||||||
|
}
|
||||||
|
#endif // BE_MAPPING_ENABLE_INPUT_VALIDATION
|
||||||
|
|
||||||
|
void *cb = be_tocomptr(vm, 1);
|
||||||
|
|
||||||
|
// Find slot number
|
||||||
|
int32_t slot;
|
||||||
|
for (slot = 0; slot < BE_MAX_CB; slot++) {
|
||||||
|
if (cb == (void*) berry_callback_array[slot]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (slot >= BE_MAX_CB) {
|
||||||
|
be_raise(vm, "internal_error", "could not find cb");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fix GC object if needed
|
||||||
|
bvalue *found = &be_cb_hooks[slot].f;
|
||||||
|
if (be_isgcobj(found)) {
|
||||||
|
be_gc_fix_set(vm, found->v.gc, bfalse); // mark the function as gc so it can be freed
|
||||||
|
}
|
||||||
|
|
||||||
|
// Record pointers
|
||||||
|
be_cb_hooks[slot].vm = NULL;
|
||||||
|
be_cb_hooks[slot].f.type = 0;
|
||||||
|
be_cb_hooks[slot].f.v.p = NULL;
|
||||||
|
|
||||||
|
be_return_nil(vm);
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************************************************************************\
|
/*********************************************************************************************\
|
||||||
* `be_cb_deinit`: SECURITY PATCHED
|
* `be_cb_deinit`: SECURITY PATCHED
|
||||||
* Clean any callback for this VM, they shouldn't call the registered function anymore
|
* Clean any callback for this VM, they shouldn't call the registered function anymore
|
||||||
@ -406,6 +450,7 @@ void be_cb_deinit(bvm *vm) {
|
|||||||
/* @const_object_info_begin
|
/* @const_object_info_begin
|
||||||
module cb (scope: global) {
|
module cb (scope: global) {
|
||||||
gen_cb, func(be_cb_gen_cb)
|
gen_cb, func(be_cb_gen_cb)
|
||||||
|
free_cb, func(be_cb_free_cb)
|
||||||
get_cb_list, func(be_cb_get_cb_list)
|
get_cb_list, func(be_cb_get_cb_list)
|
||||||
|
|
||||||
add_handler, func(be_cb_add_handler)
|
add_handler, func(be_cb_add_handler)
|
||||||
|
|||||||
BIN
tasmota/berry/extensions/LVGL_Panel.tapp
Normal file
BIN
tasmota/berry/extensions/LVGL_Panel.tapp
Normal file
Binary file not shown.
6
tasmota/berry/extensions/LVGL_Panel/autoexec.be
Normal file
6
tasmota/berry/extensions/LVGL_Panel/autoexec.be
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# rm LVGL_Panel.tapp; zip -j -0 LVGL_Panel.tapp LVGL_Panel/autoexec.be LVGL_Panel/lvgl_panel.be LVGL_Panel/manifest.json
|
||||||
|
do # embed in `do` so we don't add anything to global namespace
|
||||||
|
import introspect
|
||||||
|
var leds_panel = introspect.module('lvgl_panel', true) # load module but don't cache
|
||||||
|
tasmota.add_extension(leds_panel)
|
||||||
|
end
|
||||||
1096
tasmota/berry/extensions/LVGL_Panel/lvgl_panel.be
Normal file
1096
tasmota/berry/extensions/LVGL_Panel/lvgl_panel.be
Normal file
File diff suppressed because it is too large
Load Diff
8
tasmota/berry/extensions/LVGL_Panel/manifest.json
Normal file
8
tasmota/berry/extensions/LVGL_Panel/manifest.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"name": "LVGL Panel",
|
||||||
|
"version": "0x190A0100",
|
||||||
|
"description": "Realtime display of the LVGL display in browser",
|
||||||
|
"author": "Stephan Hadinger",
|
||||||
|
"min_tasmota": "0x0F010002",
|
||||||
|
"features": "display"
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user