Berry created separate library `lv_berry` to isolate LVGL-Berry mapping

This commit is contained in:
Stephan Hadinger 2021-12-20 11:17:11 +01:00
parent 847203c927
commit 38e6a9fdf0
16 changed files with 1941 additions and 2833 deletions

View File

@ -206,6 +206,7 @@ extern const bcstring be_const_str_add;
extern const bcstring be_const_str_add_anim;
extern const bcstring be_const_str_add_cmd;
extern const bcstring be_const_str_add_driver;
extern const bcstring be_const_str_add_handler;
extern const bcstring be_const_str_add_header;
extern const bcstring be_const_str_add_rule;
extern const bcstring be_const_str_addr;
@ -464,6 +465,7 @@ extern const bcstring be_const_str_length_X20in_X20bits_X20must_X20be_X20between
extern const bcstring be_const_str_light;
extern const bcstring be_const_str_line_dsc;
extern const bcstring be_const_str_list;
extern const bcstring be_const_str_list_handlers;
extern const bcstring be_const_str_listdir;
extern const bcstring be_const_str_load;
extern const bcstring be_const_str_load_templates;
@ -473,11 +475,13 @@ extern const bcstring be_const_str_log10;
extern const bcstring be_const_str_loop;
extern const bcstring be_const_str_lower;
extern const bcstring be_const_str_lv;
extern const bcstring be_const_str_lv_;
extern const bcstring be_const_str_lv_event;
extern const bcstring be_const_str_lv_event_cb;
extern const bcstring be_const_str_lv_obj;
extern const bcstring be_const_str_lv_obj_class;
extern const bcstring be_const_str_lvgl_event_dispatch;
extern const bcstring be_const_str_make_cb;
extern const bcstring be_const_str_map;
extern const bcstring be_const_str_math;
extern const bcstring be_const_str_matrix;

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +1,16 @@
#include "be_constobj.h"
static be_define_const_map_slots(m_libcb_map) {
{ be_const_key(make_cb, -1), be_const_func(be_cb_make_cb) },
{ be_const_key(list_handlers, 3), be_const_func(be_cb_list_handlers) },
{ be_const_key(get_cb_list, -1), be_const_func(be_cb_get_cb_list) },
{ be_const_key(gen_cb, -1), be_const_func(be_cb_gen_cb) },
{ be_const_key(add_handler, -1), be_const_func(be_cb_add_handler) },
};
static be_define_const_map(
m_libcb_map,
2
5
);
static be_define_const_module(

View File

@ -10,6 +10,7 @@
#include "be_gc.h"
#include "be_exec.h"
#include "be_vm.h"
#include "be_mem.h"
/*********************************************************************************************\
* Callback structures
@ -69,11 +70,115 @@ static const berry_callback_t berry_callback_array[BE_MAX_CB] = {
typedef struct be_callback_hook {
bvm *vm;
bgcobject *f;
bvalue f;
} be_callback_hook;
typedef struct be_callback_handler_list_t {
bvm *vm;
bvalue f;
struct be_callback_handler_list_t *next;
} be_callback_handler_list_t;
static be_callback_hook be_cb_hooks[BE_MAX_CB] = {0};
static int32_t be_cb_gen_cb(bvm *vm);
static be_callback_handler_list_t be_callback_default_gen_cb = {
NULL,
be_const_func(&be_cb_gen_cb),
NULL
};
static be_callback_handler_list_t *be_callback_handler_list_head = &be_callback_default_gen_cb; /* linked list of handlers */
/*********************************************************************************************\
* `add_handler`: Add an external handler to `make_cb()`
*
* This is typically used by LVGL mapping to handle widget callbacks, the handler
* needs to record additional infomation to disambiguate the call
*
* arg1: function (or closure)
\*********************************************************************************************/
static int32_t be_cb_add_handler(bvm *vm) {
int32_t top = be_top(vm);
if (top >= 1 && be_isfunction(vm, 1)) {
bvalue *v = be_indexof(vm, 1);
be_callback_handler_list_t *elt = be_os_malloc(sizeof(be_callback_handler_list_t));
if (!elt) { be_throw(vm, BE_MALLOC_FAIL); }
if (be_isgcobj(v)) {
be_gc_fix_set(vm, v->v.gc, btrue); // mark the function as non-gc
}
elt->vm = vm;
elt->f = *v;
elt->next = be_callback_handler_list_head; /* insert as new head */
be_callback_handler_list_head = elt;
be_return_nil(vm);
}
be_raise(vm, "value_error", "arg must be a function");
}
/*********************************************************************************************\
* `list_handlers`: List all cb handlers registered for this VM
*
* Used for debugging only
*
* No args
\*********************************************************************************************/
static int32_t be_cb_list_handlers(bvm *vm) {
be_newobject(vm, "list");
for (be_callback_handler_list_t *elt = be_callback_handler_list_head; elt != NULL; elt = elt->next) {
if (elt->vm == vm) { /* on purpose don't show the default handler, just pretend it's not there since it's default */
bvalue *top = be_incrtop(vm);
*top = elt->f;
be_data_push(vm, -2);
be_pop(vm, 1);
}
}
be_pop(vm, 1);
be_return(vm);
}
/*********************************************************************************************\
* `make_cb`: high-level call for creating a callback.
*
* This function is called by `be_mapping` when generating a callback with a type name.
* LVGL typically needs to register typed callbacks
*
* arg1: function (or closure)
* arg2: type name for callback (optional)
* argN: any other callback specific arguments (unlimited number, passed as-is)
\*********************************************************************************************/
static int32_t be_cb_make_cb(bvm *vm) {
int32_t argc = be_top(vm);
if (argc >= 1 && be_isfunction(vm, 1)) {
bvalue *v = be_indexof(vm, 1);
for (be_callback_handler_list_t *elt = be_callback_handler_list_head; elt != NULL; elt = elt->next) {
if (elt->vm == vm || elt->vm == NULL) { // if elt->vm is NULL then we accept any VM
// call the handler and check result
bvalue *top = be_incrtop(vm);
*top = elt->f;
// var_setobj(top, elt->f->type, elt->f); // push function - arg0
for (int i=1; i<=argc; i++) { // push all arguments including function
be_pushvalue(vm, i);
}
be_call(vm, argc); // call handler
be_pop(vm, argc); // remove arguments, top of stack has the result
// if top of stack is `comptr` then it is successful
if (be_iscomptr(vm, -1)) {
be_return(vm);
} else {
be_pop(vm, 1); // remove top, rinse and repeat
}
}
}
// if we are here, it means that no handler has handled the request
}
be_raise(vm, "value_error", "arg must be a function");
}
/*********************************************************************************************\
* `gen_cb`: Generate a new callback
*
@ -85,17 +190,16 @@ static int32_t be_cb_gen_cb(bvm *vm) {
// find first available slot
int32_t slot;
for (slot = 0; slot < BE_MAX_CB; slot++) {
if (be_cb_hooks[slot].f == NULL) break;
if (be_cb_hooks[slot].f.type == BE_NIL) break;
}
bvalue *v = be_indexof(vm, 1);
if (slot < BE_MAX_CB) {
// found a free slot
bgcobject * f = v->v.gc;
// mark the function as non-gc
be_gc_fix_set(vm, f, btrue);
if (be_isgcobj(v)) {
be_gc_fix_set(vm, v->v.gc, btrue); // mark the function as non-gc
}
// record pointers
be_cb_hooks[slot].vm = vm;
be_cb_hooks[slot].f = f;
be_cb_hooks[slot].f = *v;
be_pushcomptr(vm, (void*) berry_callback_array[slot]);
be_return(vm);
} else {
@ -115,7 +219,9 @@ static int32_t be_cb_get_cb_list(bvm *vm) {
for (uint32_t i=0; i < BE_MAX_CB; i++) {
if (be_cb_hooks[i].vm) {
if (vm == be_cb_hooks[i].vm) { // make sure it corresponds to this vm
be_pushcomptr(vm, be_cb_hooks[i].f);
bvalue *top = be_incrtop(vm);
*top = be_cb_hooks[i].f;
// be_pushcomptr(vm, be_cb_hooks[i].f);
be_data_push(vm, -2);
be_pop(vm, 1);
}
@ -140,11 +246,11 @@ static int32_t call_berry_cb(int32_t num, int32_t v0, int32_t v1, int32_t v2, in
if (num < 0 || num >= BE_MAX_CB || be_cb_hooks[num].vm == NULL) return 0; // invalid call, avoid a crash
bvm * vm = be_cb_hooks[num].vm;
bgcobject * f = be_cb_hooks[num].f;
bvalue *f = &be_cb_hooks[num].f;
// push function (don't check type)
bvalue *top = be_incrtop(vm);
var_setobj(top, f->type, f);
*top = *f;
// push args
be_pushint(vm, v0);
be_pushint(vm, v1);
@ -166,6 +272,10 @@ static int32_t call_berry_cb(int32_t num, int32_t v0, int32_t v1, int32_t v2, in
module cb (scope: global) {
gen_cb, func(be_cb_gen_cb)
get_cb_list, func(be_cb_get_cb_list)
add_handler, func(be_cb_add_handler)
list_handlers, func(be_cb_list_handlers)
make_cb, func(be_cb_make_cb)
}
@const_object_info_end */
#include "../../berry/generate/be_fixed_cb.h"

View File

@ -21,6 +21,24 @@ void be_set_gen_cb_name(bvm *vm, const char * gen_cb) {
if (gen_cb) be_gen_cb_name = gen_cb;
}
/*********************************************************************************************\
* Converision from real <-> int
*
* Warning, works only if sizeof(intptr_t) == sizeof(breal)
* On ESP32, int=32bits, real=float (32bits)
\*********************************************************************************************/
static intptr_t realasint(breal v) {
intptr_t i;
i = *((intptr_t*) &v);
return i;
}
static breal intasreal(intptr_t v) {
breal r;
r = *((breal*) &v);
return r;
}
/*********************************************************************************************\
* Create an object of `class_name` given an external poinrt `ptr`.
*
@ -73,7 +91,14 @@ int be_find_global_or_module_member(bvm *vm, const char * name) {
char * prefix = strtok_r(name_buf, ".", &saveptr);
char * suffix = strtok_r(NULL, ".", &saveptr);
if (suffix) {
if (be_getglobal(vm, prefix)) {
if (!be_getglobal(vm, prefix)) {
// global not found, try module
be_pop(vm, 1);
if (!be_getmodule(vm, prefix)) {
return 0;
}
}
if (!be_isnil(vm, -1)) {
if (be_getmember(vm, -1, suffix)) {
if (be_isinstance(vm, -2)) { // instance, so we need to push method + instance
be_pushvalue(vm, -2);
@ -123,7 +148,7 @@ int be_find_global_or_module_member(bvm *vm, const char * name) {
* 's' be_str
*
* - arg_type: optionally check the types of input arguments, or throw an error
* string of argument types
* string of argument types, '[' indicates that the following parameters are optional
* '.' don't care
* 'i' be_int
* 'b' be_bool
@ -141,7 +166,7 @@ int be_find_global_or_module_member(bvm *vm, const char * name) {
// read a single value at stack position idx, convert to int.
// if object instance, get `_p` member and convert it recursively
intptr_t be_convert_single_elt(bvm *vm, int idx, const char * arg_type, const char * gen_cb) {
// berry_log_C("be_convert_single_elt(idx=%i, argtype='%s', gen_cb=%p", idx, arg_type, gen_cb);
// berry_log_C("be_convert_single_elt(idx=%i, argtype='%s', gen_cb=%p, type=%s", idx, arg_type ? arg_type : "", gen_cb ? gen_cb : "", be_typename(vm, idx));
int ret = 0;
char provided_type = 0;
idx = be_absindex(vm, idx); // make sure we have an absolute index
@ -156,7 +181,6 @@ intptr_t be_convert_single_elt(bvm *vm, int idx, const char * arg_type, const ch
if (be_isclosure(vm, idx)) {
ret = be_find_global_or_module_member(vm, gen_cb);
if (ret) {
be_remove(vm, -3); // stack contains method + instance
be_pushvalue(vm, idx);
be_pushvalue(vm, 1);
be_pushstring(vm, arg_type);
@ -175,18 +199,24 @@ intptr_t be_convert_single_elt(bvm *vm, int idx, const char * arg_type, const ch
}
// first convert the value to int32
if (be_isint(vm, idx)) { ret = be_toint(vm, idx); provided_type = 'i'; }
if (be_isint(vm, idx)) {
if (arg_type[0] == 'f') {
ret = realasint((float)be_toint(vm, idx)); provided_type = 'f';
} else {
ret = be_toint(vm, idx); provided_type = 'i'; }
}
else if (be_isbool(vm, idx)) { ret = be_tobool(vm, idx); provided_type = 'b'; }
else if (be_isstring(vm, idx)) { ret = (intptr_t) be_tostring(vm, idx); provided_type = 's'; }
else if (be_iscomptr(vm, idx)) { ret = (intptr_t) be_tocomptr(vm, idx); provided_type = 'c'; }
else if (be_isnil(vm, idx)) { ret = 0; provided_type = 'c'; }
else if (be_isreal(vm, idx)) { ret = realasint(be_toreal(vm, idx)); provided_type = 'f'; }
// check if simple type was a match
if (provided_type) {
bbool type_ok = bfalse;
type_ok = (arg_type[0] == '.'); // any type is accepted
type_ok = type_ok || (arg_type[0] == provided_type); // or type is a match
type_ok = type_ok || (ret == 0 && arg_type_len != 1); // or NULL is accepted for an instance
type_ok = type_ok || (ret == 0 && arg_type_len != 1); // or NULL is accepted for an instance
if (!type_ok) {
be_raisef(vm, "type_error", "Unexpected argument type '%c', expected '%s'", provided_type, arg_type);
@ -195,7 +225,6 @@ intptr_t be_convert_single_elt(bvm *vm, int idx, const char * arg_type, const ch
return ret;
}
// berry_log_C("be_convert_single_elt non simple type");
// non-simple type
if (be_isinstance(vm, idx)) {
// check if the instance is a subclass of `bytes()``
@ -265,6 +294,7 @@ intptr_t be_convert_single_elt(bvm *vm, int idx, const char * arg_type, const ch
void be_check_arg_type(bvm *vm, int arg_start, int argc, const char * arg_type, intptr_t p[8]) {
bbool arg_type_check = (arg_type != NULL); // is type checking activated
int32_t arg_idx = 0; // position in arg_type string
bbool arg_optional = bfalse; // are remaining types optional?
char type_short_name[32];
uint32_t p_idx = 0; // index in p[], is incremented with each parameter except '-'
@ -272,6 +302,10 @@ void be_check_arg_type(bvm *vm, int arg_start, int argc, const char * arg_type,
type_short_name[0] = 0; // clear string
// extract individual type
if (NULL != arg_type) {
if (arg_type[arg_idx] == '[' || arg_type[arg_idx] == ']') { // '[' is a marker that following parameters are optional and default to NULL
arg_optional = btrue;
arg_idx++;
}
switch (arg_type[arg_idx]) {
case '-':
arg_idx++;
@ -310,11 +344,13 @@ void be_check_arg_type(bvm *vm, int arg_start, int argc, const char * arg_type,
}
}
// AddLog(LOG_LEVEL_INFO, ">> be_call_c_func arg %i, type %s", i, arg_type_check ? type_short_name : "<null>");
p[p_idx++] = be_convert_single_elt(vm, i + arg_start, arg_type_check ? type_short_name : NULL, be_gen_cb_name);
p[p_idx] = be_convert_single_elt(vm, i + arg_start, arg_type_check ? type_short_name : NULL, "cb.make_cb");
// berry_log_C("< ret[%i]=%i", p_idx, p[p_idx]);
p_idx++;
}
// check if we are missing arguments
if (arg_type != NULL && arg_type[arg_idx] != 0) {
if (!arg_optional && arg_type != NULL && arg_type[arg_idx] != 0) {
be_raisef(vm, "value_error", "Missing arguments, remaining type '%s'", &arg_type[arg_idx]);
}
}
@ -337,7 +373,7 @@ void be_check_arg_type(bvm *vm, int arg_start, int argc, const char * arg_type,
// `+` forbids any NULL value (raises an exception) while `=` allows a NULL value
static void be_set_ctor_ptr(bvm *vm, void * ptr, const char *name) {
if (name == NULL) return; // do nothing if no name of attribute
if (name[0] == '=' && ptr == NULL) { be_raise(vm, "value_error", "argument cannot be NULL"); }
if (name[0] == '+' && ptr == NULL) { be_raise(vm, "value_error", "argument cannot be NULL"); }
if (name[0] == '+' || name[0] == '=') { name++; } // skip prefix '^' if any
if (strlen(name) == 0) return; // do nothing if name is empty
@ -386,7 +422,8 @@ int be_call_c_func(bvm *vm, void * func, const char * return_type, const char *
fn_any_callable f = (fn_any_callable) func;
be_check_arg_type(vm, arg_start, arg_count, arg_type, p);
intptr_t ret = (*f)(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
intptr_t ret = 0;
if (f) ret = (*f)(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
// berry_log_C("be_call_c_func '%s' -> '%s': (%i,%i,%i,%i,%i,%i) -> %i", return_type, arg_type, p[0], p[1], p[2], p[3], p[4], p[5], ret);
if ((return_type == NULL) || (strlen(return_type) == 0)) { be_return_nil(vm); } // does not return

View File

@ -16,11 +16,11 @@ extern int lco_init(bvm *vm); // generic function
extern int lco_tostring(bvm *vm); // generic function
extern int lco_toint(bvm *vm); // generic function
extern int lvx_member(bvm *vm);
extern int lvx_tostring(bvm *vm); // generic function
extern int lv_x_member(bvm *vm);
extern int lv_x_tostring(bvm *vm); // generic function
extern int lvs_init(bvm *vm);
extern int lvs_tostring(bvm *vm);
extern int lv_x_tostring(bvm *vm);
BE_EXPORT_VARIABLE extern const bclass be_class_lv_obj;
@ -877,9 +877,9 @@ be_local_class(lv_style,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lvs_init) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvs_tostring) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lv_x_member) },
})),
(be_nested_const_str("lv_style", -143355747, 8))
);
@ -893,8 +893,8 @@ be_local_class(lv_obj,
NULL,
be_nested_map(5,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("tostring", -1995258651, 8, 3), be_const_func(lvx_tostring) },
{ be_nested_key("member", 719708611, 6, -1), be_const_func(lvx_member) },
{ be_nested_key("tostring", -1995258651, 8, 3), be_const_func(lv_x_tostring) },
{ be_nested_key("member", 719708611, 6, -1), be_const_func(lv_x_member) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("init", 380752755, 4, 4), be_const_func(be_ntv_lv_obj_init) },
{ be_nested_key("_class", -1562820946, 6, -1), be_const_comptr(&lv_obj_class) },
@ -912,9 +912,9 @@ be_local_class(lv_group,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(be_ntv_lv_group_init) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lv_x_member) },
})),
(be_nested_const_str("lv_group", -442928277, 8))
);
@ -929,9 +929,9 @@ be_local_class(lv_indev,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lv0_init) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lv_x_member) },
})),
(be_nested_const_str("lv_indev", 225602374, 8))
);
@ -946,9 +946,9 @@ be_local_class(lv_disp,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lv0_init) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lv_x_member) },
})),
(be_nested_const_str("lv_disp", 609712084, 8))
);
@ -963,7 +963,7 @@ be_local_class(lv_font,
be_nested_map(3,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lvbe_font_create) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
})),
(be_nested_const_str("lv_font", 1550958453, 7))
@ -979,7 +979,7 @@ be_local_class(lv_theme,
be_nested_map(3,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lvbe_theme_create) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
})),
(be_nested_const_str("lv_theme", 1550958453, 7))

View File

@ -4,8 +4,8 @@
"description": "Mapping of LVGL functions to Berry",
"license": "MIT",
"homepage": "https://github.com/arendst/Tasmota",
"frameworks": "arduino",
"platforms": "espressif32",
"frameworks": "*",
"platforms": "*",
"authors":
{
"name": "Stephan Hadinger",
@ -20,6 +20,6 @@
"+<*.cpp>",
"+<*.h>"
],
"flags": [ "-I$PROJECT_DIR/include" ]
"flags": [ "-I$PROJECT_DIR/include", "-includetasmota_options.h" ]
}
}

View File

@ -40,11 +40,11 @@ be_local_closure(LVGL_glob_get_object_from_ptr, /* name */
/********************************************************************
** Solidified function: widget_event_impl
** Solidified function: widget_ctor_impl
********************************************************************/
be_local_closure(LVGL_glob_widget_event_impl, /* name */
be_local_closure(LVGL_glob_widget_ctor_impl, /* name */
be_nested_proto(
12, /* nstack */
10, /* nstack */
3, /* argc */
0, /* varg */
0, /* has upvals */
@ -56,124 +56,16 @@ be_local_closure(LVGL_glob_widget_event_impl, /* name */
/* K0 */ be_nested_str(introspect),
/* K1 */ be_nested_str(lv),
/* K2 */ be_nested_str(lv_obj_class),
/* K3 */ be_nested_str(lv_event),
/* K4 */ be_nested_str(target),
/* K5 */ be_nested_str(get_object_from_ptr),
/* K3 */ be_nested_str(get_object_from_ptr),
/* K4 */ be_nested_str(cb_obj),
/* K5 */ be_nested_str(find),
/* K6 */ be_nested_str(instance),
/* K7 */ be_nested_str(get),
/* K8 */ be_nested_str(widget_event),
/* K8 */ be_nested_str(widget_constructor),
}),
&be_const_str_widget_event_impl,
&be_const_str_widget_ctor_impl,
&be_const_str_solidified,
( &(const binstruction[28]) { /* code */
0xA40E0000, // 0000 IMPORT R3 K0
0xB8120200, // 0001 GETNGBL R4 K1
0x8C100902, // 0002 GETMET R4 R4 K2
0x5C180200, // 0003 MOVE R6 R1
0x7C100400, // 0004 CALL R4 2
0xB8160200, // 0005 GETNGBL R5 K1
0x8C140B03, // 0006 GETMET R5 R5 K3
0x5C1C0400, // 0007 MOVE R7 R2
0x7C140400, // 0008 CALL R5 2
0x88180B04, // 0009 GETMBR R6 R5 K4
0x8C1C0105, // 000A GETMET R7 R0 K5
0x5C240C00, // 000B MOVE R9 R6
0x7C1C0400, // 000C CALL R7 2
0x60200004, // 000D GETGBL R8 G4
0x5C240E00, // 000E MOVE R9 R7
0x7C200200, // 000F CALL R8 1
0x1C201106, // 0010 EQ R8 R8 K6
0x78220008, // 0011 JMPF R8 #001B
0x8C200707, // 0012 GETMET R8 R3 K7
0x5C280E00, // 0013 MOVE R10 R7
0x582C0008, // 0014 LDCONST R11 K8
0x7C200600, // 0015 CALL R8 3
0x78220003, // 0016 JMPF R8 #001B
0x8C200F08, // 0017 GETMET R8 R7 K8
0x5C280800, // 0018 MOVE R10 R4
0x5C2C0A00, // 0019 MOVE R11 R5
0x7C200600, // 001A CALL R8 3
0x80000000, // 001B RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: lvgl_event_dispatch
********************************************************************/
be_local_closure(LVGL_glob_lvgl_event_dispatch, /* name */
be_nested_proto(
10, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 7]) { /* constants */
/* K0 */ be_nested_str(introspect),
/* K1 */ be_nested_str(lv),
/* K2 */ be_nested_str(lv_event),
/* K3 */ be_nested_str(toptr),
/* K4 */ be_nested_str(target),
/* K5 */ be_nested_str(cb_event_closure),
/* K6 */ be_nested_str(get_object_from_ptr),
}),
&be_const_str_lvgl_event_dispatch,
&be_const_str_solidified,
( &(const binstruction[18]) { /* code */
0xA40A0000, // 0000 IMPORT R2 K0
0xB80E0200, // 0001 GETNGBL R3 K1
0x8C0C0702, // 0002 GETMET R3 R3 K2
0x8C140503, // 0003 GETMET R5 R2 K3
0x5C1C0200, // 0004 MOVE R7 R1
0x7C140400, // 0005 CALL R5 2
0x7C0C0400, // 0006 CALL R3 2
0x88100704, // 0007 GETMBR R4 R3 K4
0x88140105, // 0008 GETMBR R5 R0 K5
0x94140A04, // 0009 GETIDX R5 R5 R4
0x8C180106, // 000A GETMET R6 R0 K6
0x5C200800, // 000B MOVE R8 R4
0x7C180400, // 000C CALL R6 2
0x5C1C0A00, // 000D MOVE R7 R5
0x5C200C00, // 000E MOVE R8 R6
0x5C240600, // 000F MOVE R9 R3
0x7C1C0400, // 0010 CALL R7 2
0x80000000, // 0011 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: widget_dtor_impl
********************************************************************/
be_local_closure(LVGL_glob_widget_dtor_impl, /* name */
be_nested_proto(
10, /* nstack */
3, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 7]) { /* constants */
/* K0 */ be_nested_str(introspect),
/* K1 */ be_nested_str(lv),
/* K2 */ be_nested_str(lv_obj_class),
/* K3 */ be_nested_str(get_object_from_ptr),
/* K4 */ be_nested_str(instance),
/* K5 */ be_nested_str(get),
/* K6 */ be_nested_str(widget_destructor),
}),
&be_const_str_widget_dtor_impl,
&be_const_str_solidified,
( &(const binstruction[22]) { /* code */
( &(const binstruction[29]) { /* code */
0xA40E0000, // 0000 IMPORT R3 K0
0xB8120200, // 0001 GETNGBL R4 K1
0x8C100902, // 0002 GETMET R4 R4 K2
@ -182,200 +74,27 @@ be_local_closure(LVGL_glob_widget_dtor_impl, /* name */
0x8C140103, // 0005 GETMET R5 R0 K3
0x5C1C0400, // 0006 MOVE R7 R2
0x7C140400, // 0007 CALL R5 2
0x60180004, // 0008 GETGBL R6 G4
0x5C1C0A00, // 0009 MOVE R7 R5
0x7C180200, // 000A CALL R6 1
0x1C180D04, // 000B EQ R6 R6 K4
0x781A0007, // 000C JMPF R6 #0015
0x8C180705, // 000D GETMET R6 R3 K5
0x5C200A00, // 000E MOVE R8 R5
0x58240006, // 000F LDCONST R9 K6
0x7C180600, // 0010 CALL R6 3
0x781A0002, // 0011 JMPF R6 #0015
0x8C180B06, // 0012 GETMET R6 R5 K6
0x5C200800, // 0013 MOVE R8 R4
0x7C180400, // 0014 CALL R6 2
0x80000000, // 0015 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: register_obj
********************************************************************/
be_local_closure(LVGL_glob_register_obj, /* name */
be_nested_proto(
4, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_str(cb_obj),
/* K1 */ be_nested_str(_p),
}),
&be_const_str_register_obj,
&be_const_str_solidified,
( &(const binstruction[11]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x4C0C0000, // 0001 LDNIL R3
0x1C080403, // 0002 EQ R2 R2 R3
0x780A0002, // 0003 JMPF R2 #0007
0x60080013, // 0004 GETGBL R2 G19
0x7C080000, // 0005 CALL R2 0
0x90020002, // 0006 SETMBR R0 K0 R2
0x88080301, // 0007 GETMBR R2 R1 K1
0x880C0100, // 0008 GETMBR R3 R0 K0
0x980C0401, // 0009 SETIDX R3 R2 R1
0x80000000, // 000A RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: gen_cb
********************************************************************/
be_local_closure(LVGL_glob_gen_cb, /* name */
be_nested_proto(
8, /* nstack */
4, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
1, /* has sup protos */
( &(const struct bproto*[ 1]) {
be_nested_proto(
4, /* nstack */
1, /* argc */
0, /* varg */
1, /* has upvals */
( &(const bupvaldesc[ 1]) { /* upvals */
be_local_const_upval(1, 0),
}),
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str(lvgl_event_dispatch),
}),
&be_const_str__X3Clambda_X3E,
&be_const_str_solidified,
( &(const binstruction[ 5]) { /* code */
0x68040000, // 0000 GETUPV R1 U0
0x8C040300, // 0001 GETMET R1 R1 K0
0x5C0C0000, // 0002 MOVE R3 R0
0x7C040400, // 0003 CALL R1 2
0x80040200, // 0004 RET 1 R1
})
),
}),
1, /* has constants */
( &(const bvalue[ 9]) { /* constants */
/* K0 */ be_nested_str(cb),
/* K1 */ be_nested_str(lv_event_cb),
/* K2 */ be_nested_str(cb_event_closure),
/* K3 */ be_nested_str(event_cb),
/* K4 */ be_nested_str(gen_cb),
/* K5 */ be_nested_str(register_obj),
/* K6 */ be_nested_str(_p),
/* K7 */ be_nested_str(null_cb),
/* K8 */ be_nested_str(cb_do_nothing),
}),
&be_const_str_gen_cb,
&be_const_str_solidified,
( &(const binstruction[41]) { /* code */
0xA4120000, // 0000 IMPORT R4 K0
0x1C140701, // 0001 EQ R5 R3 K1
0x78160018, // 0002 JMPF R5 #001C
0x88140102, // 0003 GETMBR R5 R0 K2
0x4C180000, // 0004 LDNIL R6
0x1C140A06, // 0005 EQ R5 R5 R6
0x78160002, // 0006 JMPF R5 #000A
0x60140013, // 0007 GETGBL R5 G19
0x7C140000, // 0008 CALL R5 0
0x90020405, // 0009 SETMBR R0 K2 R5
0x88140103, // 000A GETMBR R5 R0 K3
0x4C180000, // 000B LDNIL R6
0x1C140A06, // 000C EQ R5 R5 R6
0x78160003, // 000D JMPF R5 #0012
0x8C140904, // 000E GETMET R5 R4 K4
0x841C0000, // 000F CLOSURE R7 P0
0x7C140400, // 0010 CALL R5 2
0x90020605, // 0011 SETMBR R0 K3 R5
0x8C140105, // 0012 GETMET R5 R0 K5
0x5C1C0400, // 0013 MOVE R7 R2
0x7C140400, // 0014 CALL R5 2
0x88140506, // 0015 GETMBR R5 R2 K6
0x88180102, // 0016 GETMBR R6 R0 K2
0x98180A01, // 0017 SETIDX R6 R5 R1
0x88140103, // 0018 GETMBR R5 R0 K3
0xA0000000, // 0019 CLOSE R0
0x80040A00, // 001A RET 1 R5
0x7002000A, // 001B JMP #0027
0x88140107, // 001C GETMBR R5 R0 K7
0x4C180000, // 001D LDNIL R6
0x1C140A06, // 001E EQ R5 R5 R6
0x78160003, // 001F JMPF R5 #0024
0x8C140904, // 0020 GETMET R5 R4 K4
0x881C0108, // 0021 GETMBR R7 R0 K8
0x7C140400, // 0022 CALL R5 2
0x90020E05, // 0023 SETMBR R0 K7 R5
0x88140107, // 0024 GETMBR R5 R0 K7
0xA0000000, // 0025 CLOSE R0
0x80040A00, // 0026 RET 1 R5
0xA0000000, // 0027 CLOSE R0
0x80000000, // 0028 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: deregister_obj
********************************************************************/
be_local_closure(LVGL_glob_deregister_obj, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 3]) { /* constants */
/* K0 */ be_nested_str(cb_obj),
/* K1 */ be_nested_str(remove),
/* K2 */ be_nested_str(cb_event_closure),
}),
&be_const_str_deregister_obj,
&be_const_str_solidified,
( &(const binstruction[17]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x4C0C0000, // 0001 LDNIL R3
0x20080403, // 0002 NE R2 R2 R3
0x780A0003, // 0003 JMPF R2 #0008
0x88080100, // 0004 GETMBR R2 R0 K0
0x8C080501, // 0005 GETMET R2 R2 K1
0x5C100200, // 0006 MOVE R4 R1
0x7C080400, // 0007 CALL R2 2
0x88080102, // 0008 GETMBR R2 R0 K2
0x4C0C0000, // 0009 LDNIL R3
0x20080403, // 000A NE R2 R2 R3
0x780A0003, // 000B JMPF R2 #0010
0x88080102, // 000C GETMBR R2 R0 K2
0x8C080501, // 000D GETMET R2 R2 K1
0x5C100200, // 000E MOVE R4 R1
0x7C080400, // 000F CALL R2 2
0x80000000, // 0010 RET 0
0x88180104, // 0008 GETMBR R6 R0 K4
0x8C180D05, // 0009 GETMET R6 R6 K5
0x5C200A00, // 000A MOVE R8 R5
0x7C180400, // 000B CALL R6 2
0x781A0001, // 000C JMPF R6 #000F
0x88180104, // 000D GETMBR R6 R0 K4
0x94140C05, // 000E GETIDX R5 R6 R5
0x60180004, // 000F GETGBL R6 G4
0x5C1C0A00, // 0010 MOVE R7 R5
0x7C180200, // 0011 CALL R6 1
0x1C180D06, // 0012 EQ R6 R6 K6
0x781A0007, // 0013 JMPF R6 #001C
0x8C180707, // 0014 GETMET R6 R3 K7
0x5C200A00, // 0015 MOVE R8 R5
0x58240008, // 0016 LDCONST R9 K8
0x7C180600, // 0017 CALL R6 3
0x781A0002, // 0018 JMPF R6 #001C
0x8C180B08, // 0019 GETMET R6 R5 K8
0x5C200800, // 001A MOVE R8 R4
0x7C180400, // 001B CALL R6 2
0x80000000, // 001C RET 0
})
)
);
@ -387,7 +106,7 @@ be_local_closure(LVGL_glob_deregister_obj, /* name */
********************************************************************/
be_local_closure(LVGL_glob_widget_cb, /* name */
be_nested_proto(
4, /* nstack */
5, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
@ -472,8 +191,8 @@ be_local_closure(LVGL_glob_widget_cb, /* name */
}),
1, /* has constants */
( &(const bvalue[15]) { /* constants */
/* K0 */ be_nested_str(widget_ctor_cb),
/* K1 */ be_nested_str(tasmota),
/* K0 */ be_nested_str(cb),
/* K1 */ be_nested_str(widget_ctor_cb),
/* K2 */ be_nested_str(gen_cb),
/* K3 */ be_nested_str(widget_dtor_cb),
/* K4 */ be_nested_str(widget_event_cb),
@ -490,63 +209,61 @@ be_local_closure(LVGL_glob_widget_cb, /* name */
}),
&be_const_str_widget_cb,
&be_const_str_solidified,
( &(const binstruction[56]) { /* code */
0x88040100, // 0000 GETMBR R1 R0 K0
0x4C080000, // 0001 LDNIL R2
0x1C040202, // 0002 EQ R1 R1 R2
0x78060004, // 0003 JMPF R1 #0009
0xB8060200, // 0004 GETNGBL R1 K1
0x8C040302, // 0005 GETMET R1 R1 K2
0x840C0000, // 0006 CLOSURE R3 P0
0x7C040400, // 0007 CALL R1 2
0x90020001, // 0008 SETMBR R0 K0 R1
0x88040103, // 0009 GETMBR R1 R0 K3
0x4C080000, // 000A LDNIL R2
0x1C040202, // 000B EQ R1 R1 R2
0x78060004, // 000C JMPF R1 #0012
0xB8060200, // 000D GETNGBL R1 K1
0x8C040302, // 000E GETMET R1 R1 K2
0x840C0001, // 000F CLOSURE R3 P1
0x7C040400, // 0010 CALL R1 2
0x90020601, // 0011 SETMBR R0 K3 R1
0x88040104, // 0012 GETMBR R1 R0 K4
0x4C080000, // 0013 LDNIL R2
0x1C040202, // 0014 EQ R1 R1 R2
0x78060004, // 0015 JMPF R1 #001B
0xB8060200, // 0016 GETNGBL R1 K1
0x8C040302, // 0017 GETMET R1 R1 K2
0x840C0002, // 0018 CLOSURE R3 P2
0x7C040400, // 0019 CALL R1 2
0x90020801, // 001A SETMBR R0 K4 R1
0x88040105, // 001B GETMBR R1 R0 K5
0x4C080000, // 001C LDNIL R2
0x1C040202, // 001D EQ R1 R1 R2
0x78060016, // 001E JMPF R1 #0036
0xB8060C00, // 001F GETNGBL R1 K6
0x8C040307, // 0020 GETMET R1 R1 K7
0xB80E0C00, // 0021 GETNGBL R3 K6
0x880C0708, // 0022 GETMBR R3 R3 K8
0x880C0709, // 0023 GETMBR R3 R3 K9
0x7C040400, // 0024 CALL R1 2
0x8C04030A, // 0025 GETMET R1 R1 K10
0x7C040200, // 0026 CALL R1 1
0x90020A01, // 0027 SETMBR R0 K5 R1
0x88040105, // 0028 GETMBR R1 R0 K5
0xB80A0C00, // 0029 GETNGBL R2 K6
0x88080508, // 002A GETMBR R2 R2 K8
0x88080509, // 002B GETMBR R2 R2 K9
0x90061602, // 002C SETMBR R1 K11 R2
0x88040105, // 002D GETMBR R1 R0 K5
0x88080100, // 002E GETMBR R2 R0 K0
0x90061802, // 002F SETMBR R1 K12 R2
0x88040105, // 0030 GETMBR R1 R0 K5
0x88080103, // 0031 GETMBR R2 R0 K3
0x90061A02, // 0032 SETMBR R1 K13 R2
0x88040105, // 0033 GETMBR R1 R0 K5
0x88080104, // 0034 GETMBR R2 R0 K4
0x90061C02, // 0035 SETMBR R1 K14 R2
0xA0000000, // 0036 CLOSE R0
0x80000000, // 0037 RET 0
( &(const binstruction[54]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0x88080101, // 0001 GETMBR R2 R0 K1
0x4C0C0000, // 0002 LDNIL R3
0x1C080403, // 0003 EQ R2 R2 R3
0x780A0003, // 0004 JMPF R2 #0009
0x8C080302, // 0005 GETMET R2 R1 K2
0x84100000, // 0006 CLOSURE R4 P0
0x7C080400, // 0007 CALL R2 2
0x90020202, // 0008 SETMBR R0 K1 R2
0x88080103, // 0009 GETMBR R2 R0 K3
0x4C0C0000, // 000A LDNIL R3
0x1C080403, // 000B EQ R2 R2 R3
0x780A0003, // 000C JMPF R2 #0011
0x8C080302, // 000D GETMET R2 R1 K2
0x84100001, // 000E CLOSURE R4 P1
0x7C080400, // 000F CALL R2 2
0x90020602, // 0010 SETMBR R0 K3 R2
0x88080104, // 0011 GETMBR R2 R0 K4
0x4C0C0000, // 0012 LDNIL R3
0x1C080403, // 0013 EQ R2 R2 R3
0x780A0003, // 0014 JMPF R2 #0019
0x8C080302, // 0015 GETMET R2 R1 K2
0x84100002, // 0016 CLOSURE R4 P2
0x7C080400, // 0017 CALL R2 2
0x90020802, // 0018 SETMBR R0 K4 R2
0x88080105, // 0019 GETMBR R2 R0 K5
0x4C0C0000, // 001A LDNIL R3
0x1C080403, // 001B EQ R2 R2 R3
0x780A0016, // 001C JMPF R2 #0034
0xB80A0C00, // 001D GETNGBL R2 K6
0x8C080507, // 001E GETMET R2 R2 K7
0xB8120C00, // 001F GETNGBL R4 K6
0x88100908, // 0020 GETMBR R4 R4 K8
0x88100909, // 0021 GETMBR R4 R4 K9
0x7C080400, // 0022 CALL R2 2
0x8C08050A, // 0023 GETMET R2 R2 K10
0x7C080200, // 0024 CALL R2 1
0x90020A02, // 0025 SETMBR R0 K5 R2
0x88080105, // 0026 GETMBR R2 R0 K5
0xB80E0C00, // 0027 GETNGBL R3 K6
0x880C0708, // 0028 GETMBR R3 R3 K8
0x880C0709, // 0029 GETMBR R3 R3 K9
0x900A1603, // 002A SETMBR R2 K11 R3
0x88080105, // 002B GETMBR R2 R0 K5
0x880C0101, // 002C GETMBR R3 R0 K1
0x900A1803, // 002D SETMBR R2 K12 R3
0x88080105, // 002E GETMBR R2 R0 K5
0x880C0103, // 002F GETMBR R3 R0 K3
0x900A1A03, // 0030 SETMBR R2 K13 R3
0x88080105, // 0031 GETMBR R2 R0 K5
0x880C0104, // 0032 GETMBR R3 R0 K4
0x900A1C03, // 0033 SETMBR R2 K14 R3
0xA0000000, // 0034 CLOSE R0
0x80000000, // 0035 RET 0
})
)
);
@ -720,9 +437,90 @@ be_local_closure(LVGL_glob_create_custom_widget, /* name */
/********************************************************************
** Solidified function: widget_ctor_impl
** Solidified function: register_obj
********************************************************************/
be_local_closure(LVGL_glob_widget_ctor_impl, /* name */
be_local_closure(LVGL_glob_register_obj, /* name */
be_nested_proto(
4, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_str(cb_obj),
/* K1 */ be_nested_str(_p),
}),
&be_const_str_register_obj,
&be_const_str_solidified,
( &(const binstruction[11]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x4C0C0000, // 0001 LDNIL R3
0x1C080403, // 0002 EQ R2 R2 R3
0x780A0002, // 0003 JMPF R2 #0007
0x60080013, // 0004 GETGBL R2 G19
0x7C080000, // 0005 CALL R2 0
0x90020002, // 0006 SETMBR R0 K0 R2
0x88080301, // 0007 GETMBR R2 R1 K1
0x880C0100, // 0008 GETMBR R3 R0 K0
0x980C0401, // 0009 SETIDX R3 R2 R1
0x80000000, // 000A RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: deregister_obj
********************************************************************/
be_local_closure(LVGL_glob_deregister_obj, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 3]) { /* constants */
/* K0 */ be_nested_str(cb_obj),
/* K1 */ be_nested_str(remove),
/* K2 */ be_nested_str(cb_event_closure),
}),
&be_const_str_deregister_obj,
&be_const_str_solidified,
( &(const binstruction[17]) { /* code */
0x88080100, // 0000 GETMBR R2 R0 K0
0x4C0C0000, // 0001 LDNIL R3
0x20080403, // 0002 NE R2 R2 R3
0x780A0003, // 0003 JMPF R2 #0008
0x88080100, // 0004 GETMBR R2 R0 K0
0x8C080501, // 0005 GETMET R2 R2 K1
0x5C100200, // 0006 MOVE R4 R1
0x7C080400, // 0007 CALL R2 2
0x88080102, // 0008 GETMBR R2 R0 K2
0x4C0C0000, // 0009 LDNIL R3
0x20080403, // 000A NE R2 R2 R3
0x780A0003, // 000B JMPF R2 #0010
0x88080102, // 000C GETMBR R2 R0 K2
0x8C080501, // 000D GETMET R2 R2 K1
0x5C100200, // 000E MOVE R4 R1
0x7C080400, // 000F CALL R2 2
0x80000000, // 0010 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: widget_dtor_impl
********************************************************************/
be_local_closure(LVGL_glob_widget_dtor_impl, /* name */
be_nested_proto(
10, /* nstack */
3, /* argc */
@ -732,49 +530,319 @@ be_local_closure(LVGL_glob_widget_ctor_impl, /* name */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 7]) { /* constants */
/* K0 */ be_nested_str(introspect),
/* K1 */ be_nested_str(lv),
/* K2 */ be_nested_str(lv_obj_class),
/* K3 */ be_nested_str(get_object_from_ptr),
/* K4 */ be_nested_str(instance),
/* K5 */ be_nested_str(get),
/* K6 */ be_nested_str(widget_destructor),
}),
&be_const_str_widget_dtor_impl,
&be_const_str_solidified,
( &(const binstruction[22]) { /* code */
0xA40E0000, // 0000 IMPORT R3 K0
0xB8120200, // 0001 GETNGBL R4 K1
0x8C100902, // 0002 GETMET R4 R4 K2
0x5C180200, // 0003 MOVE R6 R1
0x7C100400, // 0004 CALL R4 2
0x8C140103, // 0005 GETMET R5 R0 K3
0x5C1C0400, // 0006 MOVE R7 R2
0x7C140400, // 0007 CALL R5 2
0x60180004, // 0008 GETGBL R6 G4
0x5C1C0A00, // 0009 MOVE R7 R5
0x7C180200, // 000A CALL R6 1
0x1C180D04, // 000B EQ R6 R6 K4
0x781A0007, // 000C JMPF R6 #0015
0x8C180705, // 000D GETMET R6 R3 K5
0x5C200A00, // 000E MOVE R8 R5
0x58240006, // 000F LDCONST R9 K6
0x7C180600, // 0010 CALL R6 3
0x781A0002, // 0011 JMPF R6 #0015
0x8C180B06, // 0012 GETMET R6 R5 K6
0x5C200800, // 0013 MOVE R8 R4
0x7C180400, // 0014 CALL R6 2
0x80000000, // 0015 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: init
********************************************************************/
be_local_closure(LVGL_glob_init, /* name */
be_nested_proto(
5, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
1, /* has sup protos */
( &(const struct bproto*[ 1]) {
be_nested_proto(
8, /* nstack */
3, /* argc */
0, /* varg */
1, /* has upvals */
( &(const bupvaldesc[ 1]) { /* upvals */
be_local_const_upval(1, 0),
}),
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str(make_cb),
}),
&be_const_str__X3Clambda_X3E,
&be_const_str_solidified,
( &(const binstruction[ 7]) { /* code */
0x680C0000, // 0000 GETUPV R3 U0
0x8C0C0700, // 0001 GETMET R3 R3 K0
0x5C140000, // 0002 MOVE R5 R0
0x5C180200, // 0003 MOVE R6 R1
0x5C1C0400, // 0004 MOVE R7 R2
0x7C0C0800, // 0005 CALL R3 4
0x80040600, // 0006 RET 1 R3
})
),
}),
1, /* has constants */
( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_str(cb),
/* K1 */ be_nested_str(add_handler),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[ 6]) { /* code */
0xA4060000, // 0000 IMPORT R1 K0
0x8C080301, // 0001 GETMET R2 R1 K1
0x84100000, // 0002 CLOSURE R4 P0
0x7C080400, // 0003 CALL R2 2
0xA0000000, // 0004 CLOSE R0
0x80000000, // 0005 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: widget_event_impl
********************************************************************/
be_local_closure(LVGL_glob_widget_event_impl, /* name */
be_nested_proto(
12, /* nstack */
3, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 9]) { /* constants */
/* K0 */ be_nested_str(introspect),
/* K1 */ be_nested_str(lv),
/* K2 */ be_nested_str(lv_obj_class),
/* K3 */ be_nested_str(get_object_from_ptr),
/* K4 */ be_nested_str(cb_obj),
/* K5 */ be_nested_str(find),
/* K3 */ be_nested_str(lv_event),
/* K4 */ be_nested_str(target),
/* K5 */ be_nested_str(get_object_from_ptr),
/* K6 */ be_nested_str(instance),
/* K7 */ be_nested_str(get),
/* K8 */ be_nested_str(widget_constructor),
/* K8 */ be_nested_str(widget_event),
}),
&be_const_str_widget_ctor_impl,
&be_const_str_widget_event_impl,
&be_const_str_solidified,
( &(const binstruction[29]) { /* code */
( &(const binstruction[28]) { /* code */
0xA40E0000, // 0000 IMPORT R3 K0
0xB8120200, // 0001 GETNGBL R4 K1
0x8C100902, // 0002 GETMET R4 R4 K2
0x5C180200, // 0003 MOVE R6 R1
0x7C100400, // 0004 CALL R4 2
0x8C140103, // 0005 GETMET R5 R0 K3
0x5C1C0400, // 0006 MOVE R7 R2
0x7C140400, // 0007 CALL R5 2
0x88180104, // 0008 GETMBR R6 R0 K4
0x8C180D05, // 0009 GETMET R6 R6 K5
0x5C200A00, // 000A MOVE R8 R5
0x7C180400, // 000B CALL R6 2
0x781A0001, // 000C JMPF R6 #000F
0x88180104, // 000D GETMBR R6 R0 K4
0x94140C05, // 000E GETIDX R5 R6 R5
0x60180004, // 000F GETGBL R6 G4
0x5C1C0A00, // 0010 MOVE R7 R5
0x7C180200, // 0011 CALL R6 1
0x1C180D06, // 0012 EQ R6 R6 K6
0x781A0007, // 0013 JMPF R6 #001C
0x8C180707, // 0014 GETMET R6 R3 K7
0x5C200A00, // 0015 MOVE R8 R5
0x58240008, // 0016 LDCONST R9 K8
0x7C180600, // 0017 CALL R6 3
0x781A0002, // 0018 JMPF R6 #001C
0x8C180B08, // 0019 GETMET R6 R5 K8
0x5C200800, // 001A MOVE R8 R4
0x7C180400, // 001B CALL R6 2
0x80000000, // 001C RET 0
0xB8160200, // 0005 GETNGBL R5 K1
0x8C140B03, // 0006 GETMET R5 R5 K3
0x5C1C0400, // 0007 MOVE R7 R2
0x7C140400, // 0008 CALL R5 2
0x88180B04, // 0009 GETMBR R6 R5 K4
0x8C1C0105, // 000A GETMET R7 R0 K5
0x5C240C00, // 000B MOVE R9 R6
0x7C1C0400, // 000C CALL R7 2
0x60200004, // 000D GETGBL R8 G4
0x5C240E00, // 000E MOVE R9 R7
0x7C200200, // 000F CALL R8 1
0x1C201106, // 0010 EQ R8 R8 K6
0x78220008, // 0011 JMPF R8 #001B
0x8C200707, // 0012 GETMET R8 R3 K7
0x5C280E00, // 0013 MOVE R10 R7
0x582C0008, // 0014 LDCONST R11 K8
0x7C200600, // 0015 CALL R8 3
0x78220003, // 0016 JMPF R8 #001B
0x8C200F08, // 0017 GETMET R8 R7 K8
0x5C280800, // 0018 MOVE R10 R4
0x5C2C0A00, // 0019 MOVE R11 R5
0x7C200600, // 001A CALL R8 3
0x80000000, // 001B RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: make_cb
********************************************************************/
be_local_closure(LVGL_glob_make_cb, /* name */
be_nested_proto(
8, /* nstack */
4, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
1, /* has sup protos */
( &(const struct bproto*[ 1]) {
be_nested_proto(
4, /* nstack */
1, /* argc */
0, /* varg */
1, /* has upvals */
( &(const bupvaldesc[ 1]) { /* upvals */
be_local_const_upval(1, 0),
}),
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 1]) { /* constants */
/* K0 */ be_nested_str(lvgl_event_dispatch),
}),
&be_const_str__X3Clambda_X3E,
&be_const_str_solidified,
( &(const binstruction[ 5]) { /* code */
0x68040000, // 0000 GETUPV R1 U0
0x8C040300, // 0001 GETMET R1 R1 K0
0x5C0C0000, // 0002 MOVE R3 R0
0x7C040400, // 0003 CALL R1 2
0x80040200, // 0004 RET 1 R1
})
),
}),
1, /* has constants */
( &(const bvalue[12]) { /* constants */
/* K0 */ be_nested_str(cb),
/* K1 */ be_nested_str(lv_event_cb),
/* K2 */ be_nested_str(cb_event_closure),
/* K3 */ be_nested_str(event_cb),
/* K4 */ be_nested_str(gen_cb),
/* K5 */ be_nested_str(register_obj),
/* K6 */ be_nested_str(_p),
/* K7 */ be_const_int(0),
/* K8 */ be_const_int(2),
/* K9 */ be_nested_str(lv_),
/* K10 */ be_nested_str(null_cb),
/* K11 */ be_nested_str(cb_do_nothing),
}),
&be_const_str_make_cb,
&be_const_str_solidified,
( &(const binstruction[49]) { /* code */
0xA4120000, // 0000 IMPORT R4 K0
0x1C140701, // 0001 EQ R5 R3 K1
0x78160018, // 0002 JMPF R5 #001C
0x88140102, // 0003 GETMBR R5 R0 K2
0x4C180000, // 0004 LDNIL R6
0x1C140A06, // 0005 EQ R5 R5 R6
0x78160002, // 0006 JMPF R5 #000A
0x60140013, // 0007 GETGBL R5 G19
0x7C140000, // 0008 CALL R5 0
0x90020405, // 0009 SETMBR R0 K2 R5
0x88140103, // 000A GETMBR R5 R0 K3
0x4C180000, // 000B LDNIL R6
0x1C140A06, // 000C EQ R5 R5 R6
0x78160003, // 000D JMPF R5 #0012
0x8C140904, // 000E GETMET R5 R4 K4
0x841C0000, // 000F CLOSURE R7 P0
0x7C140400, // 0010 CALL R5 2
0x90020605, // 0011 SETMBR R0 K3 R5
0x8C140105, // 0012 GETMET R5 R0 K5
0x5C1C0400, // 0013 MOVE R7 R2
0x7C140400, // 0014 CALL R5 2
0x88140506, // 0015 GETMBR R5 R2 K6
0x88180102, // 0016 GETMBR R6 R0 K2
0x98180A01, // 0017 SETIDX R6 R5 R1
0x88140103, // 0018 GETMBR R5 R0 K3
0xA0000000, // 0019 CLOSE R0
0x80040A00, // 001A RET 1 R5
0x70020012, // 001B JMP #002F
0x40160F08, // 001C CONNECT R5 K7 K8
0x94140605, // 001D GETIDX R5 R3 R5
0x1C140B09, // 001E EQ R5 R5 K9
0x7816000B, // 001F JMPF R5 #002C
0x8814010A, // 0020 GETMBR R5 R0 K10
0x4C180000, // 0021 LDNIL R6
0x1C140A06, // 0022 EQ R5 R5 R6
0x78160003, // 0023 JMPF R5 #0028
0x8C140904, // 0024 GETMET R5 R4 K4
0x881C010B, // 0025 GETMBR R7 R0 K11
0x7C140400, // 0026 CALL R5 2
0x90021405, // 0027 SETMBR R0 K10 R5
0x8814010A, // 0028 GETMBR R5 R0 K10
0xA0000000, // 0029 CLOSE R0
0x80040A00, // 002A RET 1 R5
0x70020002, // 002B JMP #002F
0x4C140000, // 002C LDNIL R5
0xA0000000, // 002D CLOSE R0
0x80040A00, // 002E RET 1 R5
0xA0000000, // 002F CLOSE R0
0x80000000, // 0030 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: lvgl_event_dispatch
********************************************************************/
be_local_closure(LVGL_glob_lvgl_event_dispatch, /* name */
be_nested_proto(
10, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
NULL, /* no sub protos */
1, /* has constants */
( &(const bvalue[ 7]) { /* constants */
/* K0 */ be_nested_str(introspect),
/* K1 */ be_nested_str(lv),
/* K2 */ be_nested_str(lv_event),
/* K3 */ be_nested_str(toptr),
/* K4 */ be_nested_str(target),
/* K5 */ be_nested_str(cb_event_closure),
/* K6 */ be_nested_str(get_object_from_ptr),
}),
&be_const_str_lvgl_event_dispatch,
&be_const_str_solidified,
( &(const binstruction[18]) { /* code */
0xA40A0000, // 0000 IMPORT R2 K0
0xB80E0200, // 0001 GETNGBL R3 K1
0x8C0C0702, // 0002 GETMET R3 R3 K2
0x8C140503, // 0003 GETMET R5 R2 K3
0x5C1C0200, // 0004 MOVE R7 R1
0x7C140400, // 0005 CALL R5 2
0x7C0C0400, // 0006 CALL R3 2
0x88100704, // 0007 GETMBR R4 R3 K4
0x88140105, // 0008 GETMBR R5 R0 K5
0x94140A04, // 0009 GETIDX R5 R5 R4
0x8C180106, // 000A GETMET R6 R0 K6
0x5C200800, // 000B MOVE R8 R4
0x7C180400, // 000C CALL R6 2
0x5C1C0A00, // 000D MOVE R7 R5
0x5C200C00, // 000E MOVE R8 R6
0x5C240600, // 000F MOVE R9 R3
0x7C1C0400, // 0010 CALL R7 2
0x80000000, // 0011 RET 0
})
)
);
@ -787,28 +855,29 @@ be_local_closure(LVGL_glob_widget_ctor_impl, /* name */
be_local_class(LVGL_glob,
9,
NULL,
be_nested_map(20,
be_nested_map(21,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(widget_ctor_cb, 8), be_const_var(4) },
{ be_const_key(get_object_from_ptr, 4), be_const_closure(LVGL_glob_get_object_from_ptr_closure) },
{ be_const_key(cb_obj, 7), be_const_var(0) },
{ be_const_key(widget_struct_by_class, -1), be_const_var(8) },
{ be_const_key(widget_event_impl, -1), be_const_closure(LVGL_glob_widget_event_impl_closure) },
{ be_const_key(widget_dtor_cb, 6), be_const_var(5) },
{ be_const_key(cb_event_closure, -1), be_const_var(1) },
{ be_const_key(cb_do_nothing, 16), be_const_static_closure(LVGL_glob__anonymous__closure) },
{ be_const_key(null_cb, -1), be_const_var(3) },
{ be_const_key(register_obj, -1), be_const_closure(LVGL_glob_register_obj_closure) },
{ be_const_key(widget_dtor_impl, 9), be_const_closure(LVGL_glob_widget_dtor_impl_closure) },
{ be_const_key(gen_cb, -1), be_const_closure(LVGL_glob_gen_cb_closure) },
{ be_const_key(deregister_obj, -1), be_const_closure(LVGL_glob_deregister_obj_closure) },
{ be_const_key(widget_struct_default, 12), be_const_var(7) },
{ be_const_key(widget_event_cb, -1), be_const_var(6) },
{ be_const_key(get_object_from_ptr, 7), be_const_closure(LVGL_glob_get_object_from_ptr_closure) },
{ be_const_key(widget_ctor_impl, 6), be_const_closure(LVGL_glob_widget_ctor_impl_closure) },
{ be_const_key(widget_cb, -1), be_const_closure(LVGL_glob_widget_cb_closure) },
{ be_const_key(lvgl_event_dispatch, 3), be_const_closure(LVGL_glob_lvgl_event_dispatch_closure) },
{ be_const_key(lvgl_event_dispatch, -1), be_const_closure(LVGL_glob_lvgl_event_dispatch_closure) },
{ be_const_key(cb_do_nothing, 10), be_const_static_closure(LVGL_glob__anonymous__closure) },
{ be_const_key(widget_struct_by_class, -1), be_const_var(8) },
{ be_const_key(cb_event_closure, 19), be_const_var(1) },
{ be_const_key(widget_dtor_impl, -1), be_const_closure(LVGL_glob_widget_dtor_impl_closure) },
{ be_const_key(register_obj, -1), be_const_closure(LVGL_glob_register_obj_closure) },
{ be_const_key(deregister_obj, -1), be_const_closure(LVGL_glob_deregister_obj_closure) },
{ be_const_key(widget_event_cb, -1), be_const_var(6) },
{ be_const_key(widget_ctor_cb, -1), be_const_var(4) },
{ be_const_key(init, -1), be_const_closure(LVGL_glob_init_closure) },
{ be_const_key(widget_event_impl, -1), be_const_closure(LVGL_glob_widget_event_impl_closure) },
{ be_const_key(widget_dtor_cb, -1), be_const_var(5) },
{ be_const_key(cb_obj, 11), be_const_var(0) },
{ be_const_key(make_cb, -1), be_const_closure(LVGL_glob_make_cb_closure) },
{ be_const_key(null_cb, -1), be_const_var(3) },
{ be_const_key(event_cb, -1), be_const_var(2) },
{ be_const_key(create_custom_widget, -1), be_const_closure(LVGL_glob_create_custom_widget_closure) },
{ be_const_key(widget_ctor_impl, -1), be_const_closure(LVGL_glob_widget_ctor_impl_closure) },
{ be_const_key(widget_struct_default, 3), be_const_var(7) },
})),
be_str_literal("LVGL_glob")
);

View File

@ -20,6 +20,12 @@ class LVGL_glob
#- this is the fallback callback, if the event is unknown or unsupported -#
static cb_do_nothing = def() print("LVG: call to unsupported callback") end
# register our callback handler to `module cb`
def init()
import cb
cb.add_handler(/ f, obj, name -> self.make_cb(f, obj, name))
end
#- register an lv.lv_* object in the mapping -#
def register_obj(obj)
if self.cb_obj == nil self.cb_obj = {} end
@ -44,9 +50,9 @@ class LVGL_glob
f(obj, event)
end
def gen_cb(f, obj, name)
def make_cb(f, obj, name)
import cb
# print('>> gen_cb', f, name, obj)
# print('>> make_cb', f, name, obj)
# record the object, whatever the callback
if name == "lv_event_cb"
@ -57,9 +63,11 @@ class LVGL_glob
self.cb_event_closure[obj._p] = f
return self.event_cb
# elif name == "<other_cb>"
else
elif name[0..2] == "lv_"
if self.null_cb == nil self.null_cb = cb.gen_cb(self.cb_do_nothing) end
return self.null_cb
else
return nil # the call is not for us, pass to next handler
end
end
@ -96,9 +104,10 @@ class LVGL_glob
def widget_cb()
if self.widget_ctor_cb == nil self.widget_ctor_cb = tasmota.gen_cb(/ cl, obj -> self.widget_ctor_impl(cl, obj)) end
if self.widget_dtor_cb == nil self.widget_dtor_cb = tasmota.gen_cb(/ cl, obj -> self.widget_dtor_impl(cl, obj)) end
if self.widget_event_cb == nil self.widget_event_cb = tasmota.gen_cb(/ cl, e -> self.widget_event_impl(cl, e)) end
import cb
if self.widget_ctor_cb == nil self.widget_ctor_cb = cb.gen_cb(/ cl, obj -> self.widget_ctor_impl(cl, obj)) end
if self.widget_dtor_cb == nil self.widget_dtor_cb = cb.gen_cb(/ cl, obj -> self.widget_dtor_impl(cl, obj)) end
if self.widget_event_cb == nil self.widget_event_cb = cb.gen_cb(/ cl, e -> self.widget_event_impl(cl, e)) end
if self.widget_struct_default == nil
self.widget_struct_default = lv.lv_obj_class(lv.lv_obj._class).copy()

View File

@ -1,4 +1,13 @@
#include "lv_berry.h"
#include "be_mapping.h"
#include "be_exec.h"
#include "be_vm.h"
#include "be_mem.h"
#include <stdio.h>
#include "../generate/be_lv_c_mapping.h"
extern void be_load_lv_color_class(bvm *vm);
extern void be_load_lv_font_class(bvm *vm);
@ -9,3 +18,281 @@ void be_load_lvgl_classes(bvm *vm) {
be_load_lv_font_class(vm);
be_load_LVGL_glob_class(vm);
}
/*********************************************************************************************\
* Support for lv
\*********************************************************************************************/
// Get the `_p` member of instance at `index`
void * lv_get_arg(bvm *vm, int index) {
void * ret = NULL;
if (be_isinstance(vm, index)) {
be_getmember(vm, index, "_p");
ret = be_tocomptr(vm, -1);
be_pop(vm, 1); // remove _p attribute
}
return ret;
}
/*********************************************************************************************\
* Support for lv_indev and objects that don't need creator
\*********************************************************************************************/
int lv0_init(bvm *vm);
int lv0_init(bvm *vm) {
// "+_p" indicates that there must be an non NULL argument, either passed as comptr or returned by the function
// Here, there is no function, so calling the constructor without a non-null comptr argument is rejected
return be_call_c_func(vm, NULL, "+_p", NULL);
}
/*********************************************************************************************\
* Generalized tostring method, shows class and _p value
\*********************************************************************************************/
int lv_x_tostring(bvm *vm) {
lv_obj_t * obj = (lv_obj_t*) lv_get_arg(vm, 1);
const char * classname = be_classname(vm, 1);
char s[48];
snprintf(s, sizeof(s), "<instance: %s(0x%08X)>", classname, obj);
be_pushnstring(vm, s, strlen(s)); /* make escape string from buffer */
be_return(vm);
}
/*********************************************************************************************\
* Support for lv_style
\*********************************************************************************************/
int lvs_init(bvm *vm) {
int argc = be_top(vm);
lv_style_t * style = NULL;
if (argc > 1) {
style = (lv_style_t*) be_convert_single_elt(vm, 2, NULL, NULL);
}
if (style == NULL) {
style = (lv_style_t*) be_malloc(vm, sizeof(lv_style_t));
if (style == NULL) {
be_throw(vm, BE_MALLOC_FAIL);
}
if (style != NULL) {
lv_style_init(style);
}
}
be_pushcomptr(vm, style);
be_setmember(vm, 1, "_p");
be_return_nil(vm);
}
// native closure to call `be_call_c_func`
int lv_x_call_c(bvm *vm) {
// berry_log_C("lv_x_call_c enter");
// keep parameters unchanged
be_getupval(vm, 0, 0); // if index is zero, it's the current native closure
void * func = be_tocomptr(vm, -1);
be_getupval(vm, 0, 1); // if index is zero, it's the current native closure
const char * return_type = be_tostring(vm, -1);
be_getupval(vm, 0, 2); // if index is zero, it's the current native closure
const char * arg_type = be_tostring(vm, -1);
be_pop(vm, 3); // remove 3 upvals
// berry_log_C("lv_x_call_c %p '%s' <- (%s)", func, return_type, arg_type);
return be_call_c_func(vm, func, return_type, arg_type);
}
// virtual method, arg1: instance, arg2: name of method
int lv_x_member(bvm *vm) {
int32_t argc = be_top(vm); // Get the number of arguments
if (argc == 2 && be_isinstance(vm, 1) && be_isstring(vm, 2)) {
const char * method_name = be_tostring(vm, 2); // the method we are looking for
while (be_isinstance(vm, 1)) {
const char * class_name = be_classname(vm, 1);
// berry_log_C("lv_x_member looking for method '%s' of class '%s'", method_name, class_name);
// look for class descriptor
int32_t class_idx = be_map_bin_search(class_name, &lv_classes[0].name, sizeof(lv_classes[0]), lv_classes_size);
if (class_idx >= 0) {
const be_ntv_func_def_t * methods_calls = lv_classes[class_idx].func_table;
size_t methods_size = lv_classes[class_idx].size;
int32_t method_idx = be_map_bin_search(method_name, methods_calls, sizeof(be_ntv_func_def_t), methods_size);
if (method_idx >= 0) {
// method found
const be_ntv_func_def_t * method = &methods_calls[method_idx];
// berry_log_C("lv_x_member method found func=%p return_type=%s arg_type=%s", method->func, method->return_type, method->arg_type);
// push native closure
be_pushntvclosure(vm, &lv_x_call_c, 3); // 3 upvals
be_pushcomptr(vm, method->func);
be_setupval(vm, -2, 0);
be_pop(vm, 1);
be_pushstring(vm, method->return_type);
be_setupval(vm, -2, 1);
be_pop(vm, 1);
be_pushstring(vm, method->arg_type);
be_setupval(vm, -2, 2);
be_pop(vm, 1);
// all good
be_return(vm);
}
}
// get super if any, or nil if none
be_getsuper(vm, 1);
be_moveto(vm, -1, 1);
be_pop(vm, 1);
}
// berry_log_C("lv_x_member method not found");
be_return_nil(vm);
}
be_raise(vm, "type_error", NULL);
}
// lv_color
// First arg is a 24 bits RGB color
// If first arg is `nil` second arg is the native value of color
int lco_init(bvm *vm) {
int argc = be_top(vm);
uint32_t color32 = 0x000000; // default to black
if (argc > 1) {
color32 = be_toint(vm, 2);
}
lv_color_t lv_color = lv_color_hex(color32);
if (argc > 2 && be_toint(vm, 3) == -1) {
lv_color.full = be_toint(vm, 2);
}
be_pushint(vm, lv_color_to_uint32(lv_color));
be_setmember(vm, 1, "_p");
be_return_nil(vm);
}
int lco_tostring(bvm *vm) {
lv_color_t lv_color = {};
be_getmember(vm, 1, "_p");
uint32_t ntv_color = be_toint(vm, -1);
lv_color = lv_color_from_uint32(ntv_color);
uint32_t color = lv_color_to32(lv_color) & 0xFFFFFF;
be_pop(vm, 1); // remove attribute
char s[48];
snprintf(s, sizeof(s), "lv_color(0x%06x - native:0x%04x)", color, ntv_color);
be_pushnstring(vm, s, strlen(s)); /* make escape string from buffer */
be_return(vm);
}
int lco_toint(bvm *vm) {
lv_color_t lv_color = {};
be_getmember(vm, 1, "_p");
uint32_t ntv_color = be_toint(vm, -1);
be_pushint(vm, ntv_color);
be_return(vm);
}
// function is (void) -> lv_obt_t*
typedef lv_obj_t* (*fn_lvobj__void)(void); // f() -> newly created lv_obj()
int lv0_lvobj__void_call(bvm *vm, fn_lvobj__void func) {
lv_obj_t * obj = (*func)();
be_find_global_or_module_member(vm, "lv.lv_obj");
be_pushcomptr(vm, (void*) -1); // stack = class, -1
be_pushcomptr(vm, (void*) obj); // stack = class, -1, ptr
be_call(vm, 2); // instanciate, stack = instance (don't call init() )
be_pop(vm, 2); // stack = instance
be_return(vm);
}
/*********************************************************************************************\
* Support for lv_fonts
\*********************************************************************************************/
// load font by name on file-system
int lv0_load_font(bvm *vm) {
int argc = be_top(vm);
if (argc == 1 && be_isstring(vm, 1)) {
lv_font_t * font = lv_font_load(be_tostring(vm, 1));
if (font != NULL) {
be_find_global_or_module_member(vm, "lv.lv_font");
be_pushcomptr(vm, font);
be_call(vm, 1);
be_pop(vm, 1);
be_return(vm);
} else {
be_return_nil(vm);
}
}
be_raise(vm, "type_error", NULL);
}
/*********************************************************************************************\
* LVGL top level virtual members
*
* Responds to virtual constants
\*********************************************************************************************/
extern const be_ntv_func_def_t lv_func[];
extern const size_t lv_func_size;
extern const be_const_member_t lv0_constants[];
extern const size_t lv0_constants_size;
extern const be_ctypes_class_by_name_t be_ctypes_lvgl_classes[];
extern const size_t be_ctypes_lvgl_classes_size;
int lv0_member(bvm *vm);
int lv0_member(bvm *vm) {
// first try the standard way
if (be_const_member(vm, lv0_constants, lv0_constants_size)) {
be_return(vm);
}
// try alternative members
int32_t argc = be_top(vm); // Get the number of arguments
if (argc == 1 && be_isstring(vm, 1)) {
const char * needle = be_tostring(vm, 1);
int32_t idx;
// search for a class with this name
char cl_prefixed[32];
snprintf(cl_prefixed, sizeof(cl_prefixed), "lv_%s", needle); // we try both actual name and prefixed with `lv_` so both `lv.obj` and `lv.lv_obj` work
idx = be_map_bin_search(cl_prefixed, &lv_classes[0].name, sizeof(lv_classes[0]), lv_classes_size);
if (idx < 0) {
idx = be_map_bin_search(needle, &lv_classes[0].name, sizeof(lv_classes[0]), lv_classes_size);
}
if (idx >= 0) {
// we did have a match
be_pushntvclass(vm, lv_classes[idx].cl);
be_return(vm);
}
// same search for ctypes
idx = be_map_bin_search(cl_prefixed, &be_ctypes_lvgl_classes[0].name, sizeof(be_ctypes_lvgl_classes[0]), be_ctypes_lvgl_classes_size);
if (idx < 0) {
idx = be_map_bin_search(needle, &be_ctypes_lvgl_classes[0].name, sizeof(be_ctypes_lvgl_classes[0]), be_ctypes_lvgl_classes_size);
}
if (idx >= 0) {
// we did have a match
be_pushntvclass(vm, be_ctypes_lvgl_classes[idx].cl);
be_return(vm);
}
// search for a method with this name
idx = be_map_bin_search(needle, &lv_func[0].name, sizeof(lv_func[0]), lv_func_size);
if (idx >= 0) {
const be_ntv_func_def_t * method = &lv_func[idx];
// push native closure
be_pushntvclosure(vm, &lv_x_call_c, 3); // 3 upvals
be_pushcomptr(vm, method->func);
be_setupval(vm, -2, 0);
be_pop(vm, 1);
be_pushstring(vm, method->return_type);
be_setupval(vm, -2, 1);
be_pop(vm, 1);
be_pushstring(vm, method->arg_type);
be_setupval(vm, -2, 2);
be_pop(vm, 1);
// all good
be_return(vm);
}
}
be_return_nil(vm);
}

View File

@ -8,9 +8,25 @@ extern "C" {
#endif
#include "berry.h"
#include "lvgl.h"
/*********************************************************************************************\
* Support for lv_color
\*********************************************************************************************/
inline lv_color_t lv_color_from_uint32(uint32_t ucol) {
lv_color_t * col = (lv_color_t*) &ucol;
return *col;
}
inline uint32_t lv_color_to_uint32(lv_color_t col) {
uint16_t *p = (uint16_t*) &col;
return *p;
}
extern void be_load_lvgl_classes(bvm *vm);
// TODO temporary fix
extern void lv_img_set_tasmota_logo(lv_obj_t * img);
#ifdef __cplusplus
}
#endif

View File

@ -433,11 +433,11 @@ extern int lco_init(bvm *vm); // generic function
extern int lco_tostring(bvm *vm); // generic function
extern int lco_toint(bvm *vm); // generic function
extern int lvx_member(bvm *vm);
extern int lvx_tostring(bvm *vm); // generic function
extern int lv_x_member(bvm *vm);
extern int lv_x_tostring(bvm *vm); // generic function
extern int lvs_init(bvm *vm);
extern int lvs_tostring(bvm *vm);
extern int lv_x_tostring(bvm *vm);
BE_EXPORT_VARIABLE extern const bclass be_class_lv_obj;
@ -484,9 +484,9 @@ be_local_class(lv_style,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lvs_init) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvs_tostring) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lv_x_member) },
})),
(be_nested_const_str("lv_style", -143355747, 8))
);
@ -500,8 +500,8 @@ be_local_class(lv_obj,
NULL,
be_nested_map(5,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("tostring", -1995258651, 8, 3), be_const_func(lvx_tostring) },
{ be_nested_key("member", 719708611, 6, -1), be_const_func(lvx_member) },
{ be_nested_key("tostring", -1995258651, 8, 3), be_const_func(lv_x_tostring) },
{ be_nested_key("member", 719708611, 6, -1), be_const_func(lv_x_member) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("init", 380752755, 4, 4), be_const_func(be_ntv_lv_obj_init) },
{ be_nested_key("_class", -1562820946, 6, -1), be_const_comptr(&lv_obj_class) },
@ -519,9 +519,9 @@ be_local_class(lv_group,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(be_ntv_lv_group_init) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lv_x_member) },
})),
(be_nested_const_str("lv_group", -442928277, 8))
);
@ -536,9 +536,9 @@ be_local_class(lv_indev,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lv0_init) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lv_x_member) },
})),
(be_nested_const_str("lv_indev", 225602374, 8))
);
@ -553,9 +553,9 @@ be_local_class(lv_disp,
be_nested_map(4,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lv0_init) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lvx_member) },
{ be_nested_key("member", 719708611, 6, 0), be_const_func(lv_x_member) },
})),
(be_nested_const_str("lv_disp", 609712084, 8))
);
@ -570,7 +570,7 @@ be_local_class(lv_font,
be_nested_map(3,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lvbe_font_create) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
})),
(be_nested_const_str("lv_font", 1550958453, 7))
@ -586,7 +586,7 @@ be_local_class(lv_theme,
be_nested_map(3,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("init", 380752755, 4, -1), be_const_func(lvbe_theme_create) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lvx_tostring) },
{ be_nested_key("tostring", -1995258651, 8, -1), be_const_func(lv_x_tostring) },
{ be_nested_key("_p", 1594591802, 2, -1), be_const_var(0) },
})),
(be_nested_const_str("lv_theme", 1550958453, 7))

View File

@ -23,9 +23,10 @@ def eventcb(class_p, e)
print(string.format("> event class_p=0x%08X event=%s obj=%s code=%i",
class_p, str(event), str(obj), event_code))
end
var cb_ctor = tasmota.gen_cb(ctorcb)
var cb_dtor = tasmota.gen_cb(dtorcb)
var cb_event = tasmota.gen_cb(eventcb)
import cb
var cb_ctor = cb.gen_cb(ctorcb)
var cb_dtor = cb.gen_cb(dtorcb)
var cb_event = cb.gen_cb(eventcb)
# static void lv_img_event(const lv_obj_class_t * class_p, lv_event_t * e)

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +0,0 @@
/*
tasmota_lv_stdlib.h - internationalization for Tasmota
Copyright (C) 2021 Theo Arends
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// replacement for <stdlib.h> used for PSRAM malloc in LVGL
extern void *lvbe_malloc(size_t size);
extern void lvbe_free(void *ptr);
extern void *lvbe_realloc(void *ptr, size_t size);

View File

@ -104,76 +104,7 @@ extern void lv_ex_get_started_1(void);
extern "C" {
void lv_init_set_member(bvm *vm, int index, void * ptr);
int be_call_c_func(bvm *vm, void * func, const char * return_type, const char * arg_type);
// native closure to call `be_call_c_func`
int lvx_call_c(bvm *vm) {
// berry_log_C("lvx_call_c enter");
// keep parameters unchanged
be_getupval(vm, 0, 0); // if index is zero, it's the current native closure
void * func = be_tocomptr(vm, -1);
be_getupval(vm, 0, 1); // if index is zero, it's the current native closure
const char * return_type = be_tostring(vm, -1);
be_getupval(vm, 0, 2); // if index is zero, it's the current native closure
const char * arg_type = be_tostring(vm, -1);
be_pop(vm, 3); // remove 3 upvals
// berry_log_C("lvx_call_c %p '%s' <- (%s)", func, return_type, arg_type);
return be_call_c_func(vm, func, return_type, arg_type);
}
// virtual method, arg1: instance, arg2: name of method
int lvx_member(bvm *vm) {
int32_t argc = be_top(vm); // Get the number of arguments
if (argc == 2 && be_isinstance(vm, 1) && be_isstring(vm, 2)) {
const char * method_name = be_tostring(vm, 2); // the method we are looking for
while (be_isinstance(vm, 1)) {
const char * class_name = be_classname(vm, 1);
// berry_log_C("lvx_member looking for method '%s' of class '%s'", method_name, class_name);
// look for class descriptor
int32_t class_idx = be_map_bin_search(class_name, &lv_classes[0].name, sizeof(lv_classes[0]), lv_classes_size);
if (class_idx >= 0) {
const be_ntv_func_def_t * methods_calls = lv_classes[class_idx].func_table;
size_t methods_size = lv_classes[class_idx].size;
int32_t method_idx = be_map_bin_search(method_name, methods_calls, sizeof(be_ntv_func_def_t), methods_size);
if (method_idx >= 0) {
// method found
const be_ntv_func_def_t * method = &methods_calls[method_idx];
// berry_log_C("lvx_member method found func=%p return_type=%s arg_type=%s", method->func, method->return_type, method->arg_type);
// push native closure
be_pushntvclosure(vm, &lvx_call_c, 3); // 3 upvals
be_pushcomptr(vm, method->func);
be_setupval(vm, -2, 0);
be_pop(vm, 1);
be_pushstring(vm, method->return_type);
be_setupval(vm, -2, 1);
be_pop(vm, 1);
be_pushstring(vm, method->arg_type);
be_setupval(vm, -2, 2);
be_pop(vm, 1);
// all good
be_return(vm);
}
}
// get super if any, or nil if none
be_getsuper(vm, 1);
be_moveto(vm, -1, 1);
be_pop(vm, 1);
}
// berry_log_C("lvx_member method not found");
be_return_nil(vm);
}
be_raise(vm, kTypeError, nullptr);
}
}
/*********************************************************************************************\
@ -186,116 +117,6 @@ extern "C" {
\*********************************************************************************************/
extern "C" {
#include "be_exec.h"
#include "be_vm.h"
#include "be_mem.h"
/*********************************************************************************************\
* Support for lv_color
\*********************************************************************************************/
inline lv_color_t lv_color_from_uint32(uint32_t ucol) {
lv_color_t * col = (lv_color_t*) &ucol;
return *col;
}
inline uint32_t lv_color_to_uint32(lv_color_t col) {
uint16_t *p = (uint16_t*) &col;
return *p;
}
// lv_color
// First arg is a 24 bits RGB color
// If first arg is `nil` second arg is the native value of color
int lco_init(bvm *vm) {
int argc = be_top(vm);
uint32_t color32 = 0x000000; // default to black
if (argc > 1) {
color32 = be_toint(vm, 2);
}
lv_color_t lv_color = lv_color_hex(color32);
if (argc > 2 && be_toint(vm, 3) == -1) {
lv_color.full = be_toint(vm, 2);
}
be_pushint(vm, lv_color_to_uint32(lv_color));
be_setmember(vm, 1, "_p");
be_return_nil(vm);
}
int lco_tostring(bvm *vm) {
lv_color_t lv_color = {};
be_getmember(vm, 1, "_p");
uint32_t ntv_color = be_toint(vm, -1);
lv_color = lv_color_from_uint32(ntv_color);
uint32_t color = lv_color_to32(lv_color) & 0xFFFFFF;
be_pop(vm, 1); // remove attribute
char s[48];
snprintf(s, sizeof(s), "lv_color(0x%06x - native:0x%04x)", color, ntv_color);
be_pushnstring(vm, s, strlen(s)); /* make escape string from buffer */
be_return(vm);
}
int lco_toint(bvm *vm) {
lv_color_t lv_color = {};
be_getmember(vm, 1, "_p");
uint32_t ntv_color = be_toint(vm, -1);
be_pushint(vm, ntv_color);
be_return(vm);
}
/*********************************************************************************************\
* Support for lv
\*********************************************************************************************/
// Get the `_p` member of instance at `index`
void * lv_get_arg(bvm *vm, int index) {
void * ret = nullptr;
if (be_isinstance(vm, index)) {
be_getmember(vm, index, "_p");
ret = be_tocomptr(vm, -1);
be_pop(vm, 1); // remove _p attribute
}
return ret;
}
// called during init, set the `_p` member with the pointer
void lv_init_set_member(bvm *vm, int index, void * ptr) {
be_pushcomptr(vm, ptr);
be_setmember(vm, index, "_p");
be_pop(vm, 1);
}
// function is (void) -> lv_obt_t*
typedef lv_obj_t* (*fn_lvobj__void)(void); // f() -> newly created lv_obj()
int lv0_lvobj__void_call(bvm *vm, fn_lvobj__void func) {
lv_obj_t * obj = (*func)();
be_find_global_or_module_member(vm, "lv.lv_obj");
be_pushcomptr(vm, (void*) -1); // stack = class, -1
be_pushcomptr(vm, (void*) obj); // stack = class, -1, ptr
be_call(vm, 2); // instanciate, stack = instance (don't call init() )
be_pop(vm, 2); // stack = instance
be_return(vm);
}
/*********************************************************************************************\
* Support for lv_fonts
\*********************************************************************************************/
// load font by name on file-system
int lv0_load_font(bvm *vm) {
int argc = be_top(vm);
if (argc == 1 && be_isstring(vm, 1)) {
lv_font_t * font = lv_font_load(be_tostring(vm, 1));
if (font != nullptr) {
be_find_global_or_module_member(vm, "lv.lv_font");
be_pushcomptr(vm, font);
be_call(vm, 1);
be_pop(vm, 1);
be_return(vm);
} else {
be_return_nil(vm);
}
}
be_raise(vm, kTypeError, nullptr);
}
/*********************************************************************************************\
* Support for Freetype fonts
@ -540,82 +361,6 @@ extern "C" {
lv_img_set_src(img, &tasmota_logo_64_truecolor);
}
/*********************************************************************************************\
* LVGL top level virtual members
*
* Responds to virtual constants
\*********************************************************************************************/
extern const be_ntv_func_def_t lv_func[];
extern const size_t lv_func_size;
extern const be_const_member_t lv0_constants[];
extern const size_t lv0_constants_size;
extern const be_ctypes_class_by_name_t be_ctypes_lvgl_classes[];
extern const size_t be_ctypes_lvgl_classes_size;
int lv0_member(bvm *vm);
int lv0_member(bvm *vm) {
// first try the standard way
if (be_const_member(vm, lv0_constants, lv0_constants_size)) {
be_return(vm);
}
// try alternative members
int32_t argc = be_top(vm); // Get the number of arguments
if (argc == 1 && be_isstring(vm, 1)) {
const char * needle = be_tostring(vm, 1);
int32_t idx;
// search for a class with this name
char cl_prefixed[32];
snprintf(cl_prefixed, sizeof(cl_prefixed), "lv_%s", needle); // we try both actual name and prefixed with `lv_` so both `lv.obj` and `lv.lv_obj` work
idx = be_map_bin_search(cl_prefixed, &lv_classes[0].name, sizeof(lv_classes[0]), lv_classes_size);
if (idx < 0) {
idx = be_map_bin_search(needle, &lv_classes[0].name, sizeof(lv_classes[0]), lv_classes_size);
}
if (idx >= 0) {
// we did have a match
be_pushntvclass(vm, lv_classes[idx].cl);
be_return(vm);
}
// same search for ctypes
idx = be_map_bin_search(cl_prefixed, &be_ctypes_lvgl_classes[0].name, sizeof(be_ctypes_lvgl_classes[0]), be_ctypes_lvgl_classes_size);
if (idx < 0) {
idx = be_map_bin_search(needle, &be_ctypes_lvgl_classes[0].name, sizeof(be_ctypes_lvgl_classes[0]), be_ctypes_lvgl_classes_size);
}
if (idx >= 0) {
// we did have a match
be_pushntvclass(vm, be_ctypes_lvgl_classes[idx].cl);
be_return(vm);
}
// search for a method with this name
idx = be_map_bin_search(needle, &lv_func[0].name, sizeof(lv_func[0]), lv_func_size);
if (idx >= 0) {
const be_ntv_func_def_t * method = &lv_func[idx];
// push native closure
be_pushntvclosure(vm, &lvx_call_c, 3); // 3 upvals
be_pushcomptr(vm, method->func);
be_setupval(vm, -2, 0);
be_pop(vm, 1);
be_pushstring(vm, method->return_type);
be_setupval(vm, -2, 1);
be_pop(vm, 1);
be_pushstring(vm, method->arg_type);
be_setupval(vm, -2, 2);
be_pop(vm, 1);
// all good
be_return(vm);
}
}
be_return_nil(vm);
}
/*********************************************************************************************\
* LVGL Start
*
@ -724,62 +469,6 @@ extern "C" {
}
}
/*********************************************************************************************\
* Support for lv_indev and objects that don't need creator
\*********************************************************************************************/
int lv0_init(bvm *vm);
int lv0_init(bvm *vm) {
void * obj = nullptr;
int argc = be_top(vm);
if (argc > 1) {
obj = (void*) be_convert_single_elt(vm, 2, NULL, NULL);
}
lv_init_set_member(vm, 1, obj);
be_return_nil(vm);
}
/*********************************************************************************************\
* Generalized tostring method, shows class and _p value
\*********************************************************************************************/
int lvx_tostring(bvm *vm) {
lv_obj_t * obj = (lv_obj_t*) lv_get_arg(vm, 1);
const char * classname = be_classname(vm, 1);
char s[48];
snprintf(s, sizeof(s), "<instance: %s(0x%08X)>", classname, obj);
be_pushnstring(vm, s, strlen(s)); /* make escape string from buffer */
be_return(vm);
}
/*********************************************************************************************\
* Support for lv_style
\*********************************************************************************************/
int lvs_init(bvm *vm) {
int argc = be_top(vm);
lv_style_t * style = nullptr;
if (argc > 1) {
style = (lv_style_t*) be_convert_single_elt(vm, 2, NULL, NULL);
}
if (style == nullptr) {
style = (lv_style_t*) be_malloc(vm, sizeof(lv_style_t));
if (style == nullptr) {
be_throw(vm, BE_MALLOC_FAIL);
}
if (style != nullptr) {
lv_style_init(style);
}
}
lv_init_set_member(vm, 1, style);
be_return_nil(vm);
}
int lvs_tostring(bvm *vm) {
lv_style_t * style1 = (lv_style_t*) lv_get_arg(vm, 1);
char s[32];
snprintf(s, sizeof(s), "<instance: lv_style(0x%08X)>", style1);
be_pushnstring(vm, s, strlen(s)); /* make escape string from buffer */
be_return(vm);
}
/*********************************************************************************************\
* Screenshot in raw format
\********************************************************************************************/
@ -847,8 +536,6 @@ extern "C" {
}
}
#include "lvgl_berry/be_lv_c_mapping.h"
#else // USE_LVGL
// // define weak aliases