Berry vararg prep (#12951)

* Berry prepare for vararg, and fix string format

* Cosmetic fix
This commit is contained in:
s-hadinger 2021-08-23 13:29:15 +02:00 committed by GitHub
parent 4720d79dcf
commit aa6af84693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
74 changed files with 215 additions and 139 deletions

View File

@ -13,6 +13,7 @@ be_local_closure(init, /* name */
be_nested_proto(
1, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -36,6 +37,7 @@ be_local_closure(get_tasmota, /* name */
be_nested_proto(
2, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -62,6 +64,7 @@ be_local_closure(add_cmd, /* name */
be_nested_proto(
7, /* nstack */
3, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
1, /* has sup protos */
@ -69,6 +72,7 @@ be_local_closure(add_cmd, /* name */
be_nested_proto(
10, /* nstack */
4, /* argc */
0, /* varg */
1, /* has upvals */
( &(const bupvaldesc[ 2]) { /* upvals */
be_local_const_upval(1, 2),
@ -121,21 +125,21 @@ be_local_class(Driver,
NULL,
be_nested_map(16,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("web_add_main_button", -334599632, 19, 14), be_const_index(4) },
{ be_nested_key("web_add_console_button", -813531104, 22, -1), be_const_index(7) },
{ be_nested_key("web_add_management_button", -1556090110, 25, 8), be_const_index(5) },
{ be_nested_key("web_add_main_button", -334599632, 19, 14), be_const_var(4) },
{ be_nested_key("web_add_console_button", -813531104, 22, -1), be_const_var(7) },
{ be_nested_key("web_add_management_button", -1556090110, 25, 8), be_const_var(5) },
{ be_nested_key("init", 380752755, 4, -1), be_const_closure(init_closure) },
{ be_nested_key("json_append", -1292948012, 11, -1), be_const_index(10) },
{ be_nested_key("web_add_config_button", 639674325, 21, 7), be_const_index(6) },
{ be_nested_key("every_100ms", 1546407804, 11, -1), be_const_index(1) },
{ be_nested_key("display", 1164572437, 7, -1), be_const_index(12) },
{ be_nested_key("web_add_button", -757092238, 14, 13), be_const_index(3) },
{ be_nested_key("every_second", 2075451465, 12, -1), be_const_index(0) },
{ be_nested_key("save_before_restart", 1253239338, 19, -1), be_const_index(8) },
{ be_nested_key("json_append", -1292948012, 11, -1), be_const_var(10) },
{ be_nested_key("web_add_config_button", 639674325, 21, 7), be_const_var(6) },
{ be_nested_key("every_100ms", 1546407804, 11, -1), be_const_var(1) },
{ be_nested_key("display", 1164572437, 7, -1), be_const_var(12) },
{ be_nested_key("web_add_button", -757092238, 14, 13), be_const_var(3) },
{ be_nested_key("every_second", 2075451465, 12, -1), be_const_var(0) },
{ be_nested_key("save_before_restart", 1253239338, 19, -1), be_const_var(8) },
{ be_nested_key("get_tasmota", 334356779, 11, -1), be_const_closure(get_tasmota_closure) },
{ be_nested_key("web_sensor", -1394870324, 10, 6), be_const_index(9) },
{ be_nested_key("web_add_handler", -304792334, 15, -1), be_const_index(2) },
{ be_nested_key("button_pressed", 1694209616, 14, 1), be_const_index(11) },
{ be_nested_key("web_sensor", -1394870324, 10, 6), be_const_var(9) },
{ be_nested_key("web_add_handler", -304792334, 15, -1), be_const_var(2) },
{ be_nested_key("button_pressed", 1694209616, 14, 1), be_const_var(11) },
{ be_nested_key("add_cmd", -933336417, 7, -1), be_const_closure(add_cmd_closure) },
})),
(be_nested_const_str("Driver", -718580993, 6))

View File

@ -18,6 +18,7 @@ be_local_closure(init, /* name */
be_nested_proto(
10, /* nstack */
4, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -94,6 +95,7 @@ be_local_closure(write8, /* name */
be_nested_proto(
9, /* nstack */
3, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -128,6 +130,7 @@ be_local_closure(write_bit, /* name */
be_nested_proto(
11, /* nstack */
4, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -180,6 +183,7 @@ be_local_closure(read8, /* name */
be_nested_proto(
7, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -213,6 +217,7 @@ be_local_closure(read12, /* name */
be_nested_proto(
7, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -253,6 +258,7 @@ be_local_closure(read13, /* name */
be_nested_proto(
7, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -293,6 +299,7 @@ be_local_closure(read24, /* name */
be_nested_proto(
7, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -338,6 +345,7 @@ be_local_closure(read32, /* name */
be_nested_proto(
7, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */

View File

@ -14,6 +14,7 @@ be_local_closure(my_design_cb, /* name */
be_nested_proto(
21, /* nstack */
3, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
1, /* has sup protos */
@ -21,6 +22,7 @@ be_local_closure(my_design_cb, /* name */
be_nested_proto(
2, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -212,6 +214,7 @@ be_local_closure(get_percentage, /* name */
be_nested_proto(
2, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -238,6 +241,7 @@ be_local_closure(init, /* name */
be_nested_proto(
7, /* nstack */
3, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -304,6 +308,7 @@ be_local_closure(set_percentage, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -350,16 +355,16 @@ be_local_class(lv_signal_bars,
&be_class_lv_obj,
be_nested_map(10,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("p1", -1605446022, 2, -1), be_const_index(2) },
{ be_nested_key("p1", -1605446022, 2, -1), be_const_var(2) },
{ be_nested_key("my_design_cb", -1173588798, 12, -1), be_const_closure(my_design_cb_closure) },
{ be_nested_key("get_percentage", -1414483304, 14, -1), be_const_closure(get_percentage_closure) },
{ be_nested_key("init", 380752755, 4, 7), be_const_closure(init_closure) },
{ be_nested_key("set_percentage", -1342944572, 14, 0), be_const_closure(set_percentage_closure) },
{ be_nested_key("percentage", -1756136011, 10, 3), be_const_index(1) },
{ be_nested_key("area", -1693507260, 4, -1), be_const_index(5) },
{ be_nested_key("p2", -1622223641, 2, -1), be_const_index(3) },
{ be_nested_key("line_dsc", -200476318, 8, 1), be_const_index(4) },
{ be_nested_key("ancestor_design", 421545719, 15, -1), be_const_index(0) },
{ be_nested_key("percentage", -1756136011, 10, 3), be_const_var(1) },
{ be_nested_key("area", -1693507260, 4, -1), be_const_var(5) },
{ be_nested_key("p2", -1622223641, 2, -1), be_const_var(3) },
{ be_nested_key("line_dsc", -200476318, 8, 1), be_const_var(4) },
{ be_nested_key("ancestor_design", 421545719, 15, -1), be_const_var(0) },
})),
(be_nested_const_str("lv_signal_bars", -780994737, 14))
);

View File

@ -14,6 +14,7 @@ be_local_closure(init, /* name */
be_nested_proto(
7, /* nstack */
3, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -54,6 +55,7 @@ be_local_closure(every_second, /* name */
be_nested_proto(
6, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */

View File

@ -20,8 +20,8 @@ be_extern_native_module(sys);
be_extern_native_module(debug);
be_extern_native_module(gc);
be_extern_native_module(solidify);
be_extern_native_module(strict);
be_extern_native_module(introspect);
be_extern_native_module(strict);
/* Tasmota specific */
be_extern_native_module(light);

View File

@ -505,6 +505,7 @@ be_local_closure(remove_rule, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -932,6 +933,7 @@ be_local_closure(set_timer, /* name */
be_nested_proto(
10, /* nstack */
4, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -974,6 +976,7 @@ be_local_closure(run_deferred, /* name */
be_nested_proto(
6, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -1031,6 +1034,7 @@ be_local_closure(remove_timer, /* name */
be_nested_proto(
6, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -1182,6 +1186,7 @@ be_local_closure(remove_cmd, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -1213,6 +1218,7 @@ be_local_closure(exec_cmd, /* name */
be_nested_proto(
12, /* nstack */
4, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -1276,6 +1282,7 @@ be_local_closure(gc, /* name */
be_nested_proto(
4, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -1307,6 +1314,7 @@ be_local_closure(event, /* name */
be_nested_proto(
19, /* nstack */
6, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -1423,6 +1431,7 @@ be_local_closure(add_driver, /* name */
be_nested_proto(
5, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -1459,6 +1468,7 @@ be_local_closure(load, /* name */
be_nested_proto(
14, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -1670,6 +1680,7 @@ be_local_closure(time_str, /* name */
be_nested_proto(
13, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -1989,6 +2000,7 @@ be_local_closure(cb_dispatch, /* name */
be_nested_proto(
12, /* nstack */
6, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -2034,6 +2046,7 @@ be_local_closure(gen_cb, /* name */
be_nested_proto(
7, /* nstack */
2, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */

View File

@ -12,6 +12,7 @@ be_local_closure(tostring, /* name */
be_nested_proto(
10, /* nstack */
1, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -60,6 +61,7 @@ be_local_closure(init, /* name */
be_nested_proto(
4, /* nstack */
4, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -92,9 +94,9 @@ be_local_class(Timer,
be_nested_map(5,
( (struct bmapnode*) &(const bmapnode[]) {
{ be_nested_key("tostring", -1995258651, 8, 4), be_const_closure(tostring_closure) },
{ be_nested_key("id", 926444256, 2, 2), be_const_index(2) },
{ be_nested_key("f", -485742695, 1, -1), be_const_index(1) },
{ be_nested_key("due", -399437003, 3, -1), be_const_index(0) },
{ be_nested_key("id", 926444256, 2, 2), be_const_var(2) },
{ be_nested_key("f", -485742695, 1, -1), be_const_var(1) },
{ be_nested_key("due", -399437003, 3, -1), be_const_var(0) },
{ be_nested_key("init", 380752755, 4, -1), be_const_closure(init_closure) },
})),
(be_nested_const_str("Timer", -346839614, 5))

View File

@ -45,6 +45,7 @@ be_local_closure(read_bytes, /* name */
be_nested_proto(
8, /* nstack */
4, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -107,6 +108,7 @@ be_local_closure(write_bytes, /* name */
be_nested_proto(
7, /* nstack */
4, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */

View File

@ -2,10 +2,10 @@
static be_define_const_map_slots(be_class_aes_gcm_map) {
{ be_const_key(encrypt, 4), be_const_func(m_aes_gcm_encryt) },
{ be_const_key(dot_p2, -1), be_const_index(0) },
{ be_const_key(dot_p2, -1), be_const_var(0) },
{ be_const_key(decrypt, -1), be_const_func(m_aes_gcm_decryt) },
{ be_const_key(init, -1), be_const_func(m_aes_gcm_init) },
{ be_const_key(dot_p1, -1), be_const_index(1) },
{ be_const_key(dot_p1, -1), be_const_var(1) },
{ be_const_key(tag, -1), be_const_func(m_aes_gcm_tag) },
};

View File

@ -1,7 +1,7 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_audio_file_source_map) {
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
};
static be_define_const_map(

View File

@ -1,7 +1,7 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_audio_generator_map) {
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
};
static be_define_const_map(

View File

@ -1,7 +1,7 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_audio_output_map) {
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
};
static be_define_const_map(

View File

@ -1,7 +1,7 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_bytes_map) {
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(seti, 6), be_const_func(m_set) },
{ be_const_key(get, 7), be_const_func(m_getu) },
{ be_const_key(size, 10), be_const_func(m_size) },

View File

@ -14,7 +14,7 @@ static be_define_const_map_slots(be_class_list_map) {
{ be_const_key(tostring, 3), be_const_func(m_tostring) },
{ be_const_key(opt_eq, -1), be_const_func(m_equal) },
{ be_const_key(init, -1), be_const_func(m_init) },
{ be_const_key(dot_p, 17), be_const_index(0) },
{ be_const_key(dot_p, 17), be_const_var(0) },
{ be_const_key(setitem, -1), be_const_func(m_setitem) },
{ be_const_key(opt_connect, 4), be_const_func(m_connect) },
{ be_const_key(opt_neq, -1), be_const_func(m_nequal) },

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_arc_map) {
{ be_const_key(init, 2), be_const_func(lvbe_arc_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_bar_map) {
{ be_const_key(init, 2), be_const_func(lvbe_bar_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_btn_map) {
{ be_const_key(init, 2), be_const_func(lvbe_btn_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_btnmatrix_map) {
{ be_const_key(init, 2), be_const_func(lvbe_btnmatrix_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_calendar_map) {
{ be_const_key(init, 2), be_const_func(lvbe_calendar_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_canvas_map) {
{ be_const_key(init, 2), be_const_func(lvbe_canvas_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_chart_map) {
{ be_const_key(init, 2), be_const_func(lvbe_chart_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_checkbox_map) {
{ be_const_key(init, 2), be_const_func(lvbe_checkbox_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -4,7 +4,7 @@ static be_define_const_map_slots(be_class_lv_color_map) {
{ be_const_key(init, -1), be_const_func(lco_init) },
{ be_const_key(tostring, 2), be_const_func(lco_tostring) },
{ be_const_key(toint, -1), be_const_func(lco_toint) },
{ be_const_key(dot_p, 0), be_const_index(0) },
{ be_const_key(dot_p, 0), be_const_var(0) },
};
static be_define_const_map(

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_cont_map) {
{ be_const_key(init, 2), be_const_func(lvbe_cont_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_cpicker_map) {
{ be_const_key(init, 2), be_const_func(lvbe_cpicker_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -1,7 +1,7 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_lv_ctypes_map) {
{ be_const_key(dot_def, -1), be_const_index(0) },
{ be_const_key(dot_def, -1), be_const_var(0) },
{ be_const_key(setmember, -1), be_const_func(be_ctypes_setmember) },
{ be_const_key(init, -1), be_const_func(be_ctypes_init) },
{ be_const_key(member, 2), be_const_func(be_ctypes_member) },

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_dropdown_map) {
{ be_const_key(init, 2), be_const_func(lvbe_dropdown_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_font_map) {
{ be_const_key(init, -1), be_const_func(lvx_init) },
{ be_const_key(tostring, 2), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
};
static be_define_const_map(

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_gauge_map) {
{ be_const_key(init, 2), be_const_func(lvbe_gauge_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_group_map) {
{ be_const_key(init, 2), be_const_func(lvbe_group_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_img_map) {
{ be_const_key(init, 2), be_const_func(lvbe_img_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_imgbtn_map) {
{ be_const_key(init, 2), be_const_func(lvbe_imgbtn_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_indev_map) {
{ be_const_key(init, 2), be_const_func(lv0_init) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_keyboard_map) {
{ be_const_key(init, 2), be_const_func(lvbe_keyboard_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_label_map) {
{ be_const_key(init, 2), be_const_func(lvbe_label_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_led_map) {
{ be_const_key(init, 2), be_const_func(lvbe_led_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_line_map) {
{ be_const_key(init, 2), be_const_func(lvbe_line_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_linemeter_map) {
{ be_const_key(init, 2), be_const_func(lvbe_linemeter_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_list_map) {
{ be_const_key(init, 2), be_const_func(lvbe_list_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_msgbox_map) {
{ be_const_key(init, 2), be_const_func(lvbe_msgbox_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_obj_map) {
{ be_const_key(init, 2), be_const_func(lvbe_obj_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_objmask_map) {
{ be_const_key(init, 2), be_const_func(lvbe_objmask_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_page_map) {
{ be_const_key(init, 2), be_const_func(lvbe_page_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_roller_map) {
{ be_const_key(init, 2), be_const_func(lvbe_roller_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_slider_map) {
{ be_const_key(init, 2), be_const_func(lvbe_slider_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_spinbox_map) {
{ be_const_key(init, 2), be_const_func(lvbe_spinbox_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_spinner_map) {
{ be_const_key(init, 2), be_const_func(lvbe_spinner_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_style_map) {
{ be_const_key(init, 2), be_const_func(lvs_init) },
{ be_const_key(tostring, -1), be_const_func(lvs_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_switch_map) {
{ be_const_key(init, 2), be_const_func(lvbe_switch_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_table_map) {
{ be_const_key(init, 2), be_const_func(lvbe_table_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_tabview_map) {
{ be_const_key(init, 2), be_const_func(lvbe_tabview_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_textarea_map) {
{ be_const_key(init, 2), be_const_func(lvbe_textarea_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_tileview_map) {
{ be_const_key(init, 2), be_const_func(lvbe_tileview_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -3,7 +3,7 @@
static be_define_const_map_slots(be_class_lv_win_map) {
{ be_const_key(init, 2), be_const_func(lvbe_win_create) },
{ be_const_key(tostring, -1), be_const_func(lvx_tostring) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(member, 0), be_const_func(lvx_member) },
};

View File

@ -1,7 +1,7 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_class_map_map) {
{ be_const_key(dot_p, 2), be_const_index(0) },
{ be_const_key(dot_p, 2), be_const_var(0) },
{ be_const_key(insert, -1), be_const_func(m_insert) },
{ be_const_key(remove, -1), be_const_func(m_remove) },
{ be_const_key(tostring, -1), be_const_func(m_tostring) },

View File

@ -2,7 +2,7 @@
static be_define_const_map_slots(be_class_md5_map) {
{ be_const_key(update, -1), be_const_func(m_md5_update) },
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(finish, -1), be_const_func(m_md5_finish) },
{ be_const_key(init, 1), be_const_func(m_md5_init) },
};

View File

@ -5,9 +5,9 @@ static be_define_const_map_slots(be_class_range_map) {
{ be_const_key(iter, -1), be_const_func(m_iter) },
{ be_const_key(lower, -1), be_const_func(m_lower) },
{ be_const_key(init, 4), be_const_func(m_init) },
{ be_const_key(__upper__, -1), be_const_index(0) },
{ be_const_key(__upper__, -1), be_const_var(0) },
{ be_const_key(tostring, -1), be_const_func(m_tostring) },
{ be_const_key(__lower__, -1), be_const_index(1) },
{ be_const_key(__lower__, -1), be_const_var(1) },
{ be_const_key(upper, 1), be_const_func(m_upper) },
};

View File

@ -10,24 +10,24 @@ static be_define_const_map_slots(be_class_tasmota_map) {
{ be_const_key(remove_rule, -1), be_const_closure(remove_rule_closure) },
{ be_const_key(event, -1), be_const_closure(event_closure) },
{ be_const_key(log, 25), be_const_func(l_logInfo) },
{ be_const_key(_drivers, -1), be_const_index(0) },
{ be_const_key(_drivers, -1), be_const_var(0) },
{ be_const_key(set_light, -1), be_const_closure(set_light_closure) },
{ be_const_key(wire2, 26), be_const_index(1) },
{ be_const_key(wire2, 26), be_const_var(1) },
{ be_const_key(get_free_heap, -1), be_const_func(l_getFreeHeap) },
{ be_const_key(resp_cmnd_failed, -1), be_const_func(l_respCmndFailed) },
{ be_const_key(publish_result, -1), be_const_func(l_publish_result) },
{ be_const_key(wire1, -1), be_const_index(2) },
{ be_const_key(wire1, -1), be_const_var(2) },
{ be_const_key(set_power, 46), be_const_func(l_setpower) },
{ be_const_key(cmd, -1), be_const_closure(cmd_closure) },
{ be_const_key(get_light, 42), be_const_closure(get_light_closure) },
{ be_const_key(_rules, 54), be_const_index(3) },
{ be_const_key(_rules, 54), be_const_var(3) },
{ be_const_key(run_deferred, 19), be_const_closure(run_deferred_closure) },
{ be_const_key(try_rule, 18), be_const_closure(try_rule_closure) },
{ be_const_key(remove_cmd, 41), be_const_closure(remove_cmd_closure) },
{ be_const_key(add_driver, 0), be_const_closure(add_driver_closure) },
{ be_const_key(get_power, 36), be_const_func(l_getpower) },
{ be_const_key(remove_timer, -1), be_const_closure(remove_timer_closure) },
{ be_const_key(_timers, -1), be_const_index(4) },
{ be_const_key(_timers, -1), be_const_var(4) },
{ be_const_key(add_rule, 33), be_const_closure(add_rule_closure) },
{ be_const_key(time_reached, -1), be_const_func(l_timereached) },
{ be_const_key(resp_cmnd_done, -1), be_const_func(l_respCmndDone) },
@ -49,7 +49,7 @@ static be_define_const_map_slots(be_class_tasmota_map) {
{ be_const_key(web_send_decimal, 44), be_const_func(l_webSendDecimal) },
{ be_const_key(load, -1), be_const_closure(load_closure) },
{ be_const_key(web_send, 56), be_const_func(l_webSend) },
{ be_const_key(_ccmd, -1), be_const_index(5) },
{ be_const_key(_ccmd, -1), be_const_var(5) },
{ be_const_key(i2c_enabled, 48), be_const_func(l_i2cenabled) },
{ be_const_key(save, -1), be_const_func(l_save) },
{ be_const_key(exec_cmd, 2), be_const_closure(exec_cmd_closure) },
@ -57,7 +57,7 @@ static be_define_const_map_slots(be_class_tasmota_map) {
{ be_const_key(wire_scan, -1), be_const_closure(wire_scan_closure) },
{ be_const_key(scale_uint, -1), be_const_func(l_scaleuint) },
{ be_const_key(delay, -1), be_const_func(l_delay) },
{ be_const_key(_cb, -1), be_const_index(6) },
{ be_const_key(_cb, -1), be_const_var(6) },
{ be_const_key(add_cmd, -1), be_const_closure(add_cmd_closure) },
{ be_const_key(_get_cb, -1), be_const_func(l_get_cb) },
{ be_const_key(yield, -1), be_const_func(l_yield) },

View File

@ -3,13 +3,13 @@
static be_define_const_map_slots(be_class_tasmota_i2c_driver_map) {
{ be_const_key(read32, -1), be_const_closure(read32_closure) },
{ be_const_key(write8, 6), be_const_closure(write8_closure) },
{ be_const_key(name, -1), be_const_index(0) },
{ be_const_key(addr, 10), be_const_index(1) },
{ be_const_key(name, -1), be_const_var(0) },
{ be_const_key(addr, 10), be_const_var(1) },
{ be_const_key(read12, -1), be_const_closure(read12_closure) },
{ be_const_key(write_bit, 8), be_const_closure(write_bit_closure) },
{ be_const_key(read13, -1), be_const_closure(read13_closure) },
{ be_const_key(read24, -1), be_const_closure(read24_closure) },
{ be_const_key(wire, -1), be_const_index(2) },
{ be_const_key(wire, -1), be_const_var(2) },
{ be_const_key(init, -1), be_const_closure(init_closure) },
{ be_const_key(read8, -1), be_const_closure(read8_closure) },
};

View File

@ -2,7 +2,7 @@
static be_define_const_map_slots(be_class_tasmota_wire_map) {
{ be_const_key(_end_transmission, 10), be_const_func(b_wire_endtransmission) },
{ be_const_key(bus, -1), be_const_index(0) },
{ be_const_key(bus, -1), be_const_var(0) },
{ be_const_key(_read, 7), be_const_func(b_wire_read) },
{ be_const_key(read, -1), be_const_func(b_wire_validread) },
{ be_const_key(_request_from, -1), be_const_func(b_wire_requestfrom) },

View File

@ -1,7 +1,7 @@
#include "be_constobj.h"
static be_define_const_map_slots(be_lvgl_cb_map) {
{ be_const_key(dot_p, -1), be_const_index(0) },
{ be_const_key(dot_p, -1), be_const_var(0) },
{ be_const_key(tostring, 2), be_const_func(lvx_tostring) },
{ be_const_key(call, -1), be_const_func(lv_cb_call) },
{ be_const_key(init, 0), be_const_func(lv0_init) },

View File

@ -536,7 +536,7 @@ static size_t tohex(char * out, size_t outsz, const uint8_t * in, size_t insz) {
static int m_tostring(bvm *vm)
{
int argc = be_top(vm);
int max_len = 32; /* limit to 32 bytes by default */
size_t max_len = 32; /* limit to 32 bytes by default */
int truncated = 0;
if (argc > 1 && be_isint(vm, 2)) {
max_len = be_toint(vm, 2); /* you can specify the len as second argument, or 0 for unlimited */
@ -918,7 +918,7 @@ static int m_tob64(bvm *vm)
size_t b64_len = encode_base64_length(len) + 1; /* size of base64 encoded string for this binary length, add NULL terminator */
char * b64_out = be_pushbuffer(vm, b64_len);
size_t converted = encode_base64(buf_get_buf(buf), len, b64_out);
size_t converted = encode_base64(buf_get_buf(buf), len, (unsigned char*)b64_out);
be_pushnstring(vm, b64_out, converted); /* make string from buffer */
be_remove(vm, -2); /* remove buffer */
@ -935,8 +935,7 @@ static int m_fromb64(bvm *vm)
int argc = be_top(vm);
if (argc >= 2 && be_isstring(vm, 2)) {
const char *s = be_tostring(vm, 2);
size_t len = be_strlen(vm, 2);
size_t bin_len = decode_base64_length(s); /* do a first pass to calculate the buffer size */
size_t bin_len = decode_base64_length((unsigned char*)s); /* do a first pass to calculate the buffer size */
buf_impl * buf = bytes_check_data(vm, 0);
buf = bytes_resize(vm, buf, bin_len); /* resize if needed */
@ -944,7 +943,7 @@ static int m_fromb64(bvm *vm)
be_raise(vm, "memory_error", "cannot allocate buffer");
}
size_t bin_len_final = decode_base64(s, buf_get_buf(buf)); /* decode */
size_t bin_len_final = decode_base64((unsigned char*)s, buf_get_buf(buf)); /* decode */
buf->len = bin_len_final;
be_pop(vm, 1); /* remove arg to leave instance */
be_return(vm);
@ -1106,6 +1105,7 @@ be_local_closure(getbits, /* name */
be_nested_proto(
9, /* nstack */
3, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */
@ -1165,6 +1165,7 @@ be_local_closure(setbits, /* name */
be_nested_proto(
10, /* nstack */
4, /* argc */
0, /* varg */
0, /* has upvals */
NULL, /* no upvals */
0, /* has sup protos */

View File

@ -47,7 +47,7 @@ extern "C" {
.type = BE_INT \
}
#define be_const_index(_val) { \
#define be_const_var(_val) { \
.v.i = (bint)(_val), \
.type = BE_INDEX \
}
@ -203,7 +203,7 @@ const bntvmodule be_native_module(_module) = { \
BE_BOOL \
}
#define be_const_index(_val) { \
#define be_const_var(_val) { \
bvaldata(bint(_val)), \
BE_INDEX \
}

View File

@ -60,16 +60,20 @@ void be_print_inst(binstruction ins, int pc)
case OP_GETMBR: case OP_SETMBR: case OP_GETMET:
case OP_GETIDX: case OP_SETIDX: case OP_AND:
case OP_OR: case OP_XOR: case OP_SHL: case OP_SHR:
logbuf("%s\tR%d\tR%d\tR%d", opc2str(op), IGET_RA(ins), IGET_RKB(ins), IGET_RKC(ins));
logbuf("%s\tR%d\t%c%d\t%c%d", opc2str(op), IGET_RA(ins),
isKB(ins) ? 'K' : 'R', IGET_RKB(ins) & KR_MASK,
isKB(ins) ? 'K' : 'R', IGET_RKC(ins) & KR_MASK);
break;
case OP_GETNGBL: case OP_SETNGBL:
logbuf("%s\tR%d\tR%d", opc2str(op), IGET_RA(ins), IGET_RKB(ins));
logbuf("%s\tR%d\t%c%d", opc2str(op), IGET_RA(ins),
isKB(ins) ? 'K' : 'R', IGET_RKB(ins) & KR_MASK);
break;
case OP_GETGBL: case OP_SETGBL:
logbuf("%s\tR%d\tG%d", opc2str(op), IGET_RA(ins), IGET_Bx(ins));
break;
case OP_MOVE: case OP_SETSUPER: case OP_NEG: case OP_FLIP: case OP_IMPORT:
logbuf("%s\tR%d\tR%d", opc2str(op), IGET_RA(ins), IGET_RKB(ins));
logbuf("%s\tR%d\t%c%d", opc2str(op), IGET_RA(ins),
isKB(ins) ? 'K' : 'R', IGET_RKB(ins) & KR_MASK);
break;
case OP_JMP:
logbuf("%s\t\t#%.4X", opc2str(op), IGET_sBx(ins) + pc + 1);
@ -84,7 +88,12 @@ void be_print_inst(binstruction ins, int pc)
logbuf("%s\tR%d\t%d\t%d", opc2str(op), IGET_RA(ins), IGET_RKB(ins), IGET_RKC(ins));
break;
case OP_RET:
logbuf("%s\t%d\tR%d", opc2str(op), IGET_RA(ins), IGET_RKB(ins));
if (IGET_RA(ins)) {
logbuf("%s\t%d\t%c%d", opc2str(op), IGET_RA(ins),
isKB(ins) ? 'K' : 'R', IGET_RKB(ins) & KR_MASK);
} else {
logbuf("%s\t%d", opc2str(op), IGET_RA(ins)); /* RET 0 does not take an additional parameter */
}
break;
case OP_GETUPV: case OP_SETUPV:
logbuf("%s\tR%d\tU%d", opc2str(op), IGET_RA(ins), IGET_Bx(ins));
@ -105,7 +114,9 @@ void be_print_inst(binstruction ins, int pc)
logbuf("%s\t%d", opc2str(op), IGET_RA(ins));
break;
case OP_RAISE:
logbuf("%s\t%d\tR%d\tR%d", opc2str(op), IGET_RA(ins), IGET_RKB(ins), IGET_RKC(ins));
logbuf("%s\t%d\t%c%d\t%c%d", opc2str(op), IGET_RA(ins),
isKB(ins) ? 'K' : 'R', IGET_RKB(ins) & KR_MASK,
isKB(ins) ? 'K' : 'R', IGET_RKC(ins) & KR_MASK);
break;
case OP_EXBLK:
if (IGET_RA(ins)) {

View File

@ -46,6 +46,9 @@
#define IsBx_MAX cast_int(IBx_MASK >> 1)
#define IsBx_MIN cast_int(-IsBx_MAX - 1)
/* mask for K/R values */
#define KR_MASK ((1 << (IRKB_BITS-1)) - 1)
/* get field */
#define IGET_OP(i) cast(bopcode, INS_GETx(i, IOP_MASK, IOP_POS))
#define IGET_RA(i) INS_GETx(i, IRA_MASK, IRA_POS)

View File

@ -53,5 +53,5 @@ OPCODE(EXBLK), /* A, Bx | ... */
OPCODE(CATCH), /* A, B, C | ... */
OPCODE(RAISE), /* A, B, C | RAISE(B,C) B is code, C is description. A==0 only B provided, A==1 B and C are provided, A==2 rethrow with both parameters already on stack */
OPCODE(CLASS), /* Bx | init class in K[Bx] */
OPCODE(GETNGBL), /* A, B | R(A) <- GLOBAL[B] by name */
OPCODE(SETNGBL) /* A, B | R(A) -> GLOBAL[B] by name */
OPCODE(GETNGBL), /* A, B | R(A) <- GLOBAL[RK(B)] by name */
OPCODE(SETNGBL) /* A, B | R(A) -> GLOBAL[RK(B)] by name */

View File

@ -51,9 +51,9 @@ static void m_solidify_bvalue(bvm *vm, bvalue * value)
break;
case BE_INDEX:
#if BE_INTGER_TYPE == 2
logfmt("be_const_index(%lli)", var_toint(value));
logfmt("be_const_var(%lli)", var_toint(value));
#else
logfmt("be_const_index(%i)", var_toint(value));
logfmt("be_const_var(%i)", var_toint(value));
#endif
break;
case BE_REAL:
@ -96,6 +96,7 @@ static void m_solidify_proto(bvm *vm, bproto *pr, const char * func_name, int bu
logfmt("%*s%d, /* nstack */\n", indent, "", pr->nstack);
logfmt("%*s%d, /* argc */\n", indent, "", pr->argc);
logfmt("%*s%d, /* varg */\n", indent, "", pr->varg);
logfmt("%*s%d, /* has upvals */\n", indent, "", (pr->nupvals > 0) ? 1 : 0);
if (pr->nupvals > 0) {
@ -127,9 +128,9 @@ static void m_solidify_proto(bvm *vm, bproto *pr, const char * func_name, int bu
if (pr->nconst > 0) {
logfmt("%*s( &(const bvalue[%2d]) { /* constants */\n", indent, "", pr->nconst);
for (int k = 0; k < pr->nconst; k++) {
logfmt("%*s ", indent, "");
logfmt("%*s/* K%-3d */ ", indent, "", k);
m_solidify_bvalue(vm, &pr->ktab[k]);
logfmt(", /* R%d - K%d */\n", 256+k, k);
logfmt(",\n");
}
logfmt("%*s}),\n", indent, "");
} else {

View File

@ -512,11 +512,15 @@ static int str_format(bvm *vm)
concat2(vm);
p = get_mode(p + 1, mode);
buf[0] = '\0';
if (index > top) {
if (index > top && *p != '%') {
be_raise(vm, "runtime_error", be_pushfstring(vm,
"bad argument #%d to 'format': no value", index));
}
switch (*p) {
case '%':
be_pushstring(vm, "%");
--index; /* compensate the future ++index */
break;
case 'd': case 'i': case 'o':
case 'u': case 'x': case 'X':
if (be_isint(vm, index)) {

View File

@ -329,7 +329,7 @@ typedef struct bntvmodule {
}
/* new version for more compact literals */
#define be_nested_proto(_nstack, _argc, _has_upval, _upvals, _has_subproto, _protos, _has_const, _ktab, _fname, _source, _code) \
#define be_nested_proto(_nstack, _argc, _varg, _has_upval, _upvals, _has_subproto, _protos, _has_const, _ktab, _fname, _source, _code) \
& (const bproto) { \
NULL, /* bgcobject *next */ \
BE_PROTO, /* type BE_PROTO */ \
@ -337,7 +337,7 @@ typedef struct bntvmodule {
(_nstack), /* nstack */ \
BE_IIF(_has_upval)(sizeof(*_upvals)/sizeof(bupvaldesc),0), /* nupvals */ \
(_argc), /* argc */ \
0, /* varg */ \
(_varg), /* varg */ \
NULL, /* bgcobject *gray */ \
(bupvaldesc*) _upvals, /* bupvaldesc *upvals */ \
(bvalue*) _ktab, /* ktab */ \

View File

@ -164,34 +164,5 @@ b.fromstring("Aa0")
assert(str(b) =="bytes('416130')")
b=bytes()
b.fromstring("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
assert(str(b) =="bytes('4C6F72656D20697073756D20646F6C6F722073697420616D65742C20636F6E73656374657475722061646970697363696E6720656C69742C2073656420646F20656975736D6F642074656D706F7220696E6369646964756E74207574206C61626F726520657420646F6C6F7265206D61676E6120616C697175612E')")
#- setters -#
b=bytes().resize(16)
b.set(5,-1,2)
assert(b == bytes('0000000000FFFF000000000000000000'))
b.set(10,-2,4)
assert(b == bytes('0000000000FFFF000000FEFFFFFF0000'))
b.set(0,0xAA55,1)
assert(b == bytes('5500000000FFFF000000FEFFFFFF0000'))
#- getbits -#
b=bytes("00AAFF55010300")
assert(b.getbits(8,8) == 0xAA)
assert(b.getbits(0,1) == 0)
assert(b.getbits(8,1) == 0)
assert(b.getbits(9,1) == 1)
assert(b.getbits(16,8) == 0xFF)
assert(b.getbits(16,16) == 0x55FF)
assert(b.getbits(16,24) == 0x0155FF)
assert(b.getbits(16,32) == 0x030155FF)
assert(b.getbits(20,8) == 0x5F)
#- setbits -#
b=bytes("00000000FFFFFFFF")
assert(b.setbits(0,1,1) == bytes('01000000FFFFFFFF'))
assert(b.setbits(1,1,1) == bytes('03000000FFFFFFFF'))
assert(b.setbits(0,1,0) == bytes('02000000FFFFFFFF'))
assert(b.setbits(12,16,0xAA55) == bytes('0250A50AFFFFFFFF'))
assert(b.setbits(63,0,0) == bytes('0250A50AFFFFFFFF'))
assert(b.setbits(63,1,0) == bytes('0250A50AFFFFFF7F'))
assert(str(b) =="bytes('4C6F72656D20697073756D20646F6C6F722073697420616D65742C20636F6E73...')")
assert(b.tostring(0) =="bytes('4C6F72656D20697073756D20646F6C6F722073697420616D65742C20636F6E73656374657475722061646970697363696E6720656C69742C2073656420646F20656975736D6F642074656D706F7220696E6369646964756E74207574206C61626F726520657420646F6C6F7265206D61676E6120616C697175612E')")

View File

@ -0,0 +1,15 @@
#- base64 encode -#
b=bytes()
assert(b.tob64() == '')
b=bytes('00')
assert(b.tob64() == 'AA==')
b=bytes('1122334455')
assert(b.tob64() == 'ESIzRFU=')
#- base64 decode -#
b=bytes().fromb64('')
assert(str(b) == str(bytes('')))
b=bytes().fromb64('AA==')
assert(str(b) == str(bytes('00')))
b=bytes().fromb64('ESIzRFU=')
assert(str(b) == str(bytes('1122334455')))

View File

@ -0,0 +1,28 @@
#- test for issue #117 -#
class A var a end
a=A()
a.a = ["foo", "bar"]
s = nil
def fs(m) s = m end
class B
var b, i
def nok()
fs(self.b.a[self.i]) # wrong behavior
end
def ok()
var i = self.i
fs(self.b.a[i]) # works correctly
end
end
b=B()
b.i=0
b.b=a
b.nok()
assert(s == "foo")
b.ok()
assert(s == "foo")

View File

@ -28,3 +28,9 @@ assert(s.split('a b c d e f', '1') == ['a b c d e f'])
assert(s.split('a b c d e f', ' ') == ['a', 'b', 'c', 'd', 'e', 'f'])
assert(s.split('a b c d e f', ' ', 2) == ['a', 'b', 'c d e f'])
assert(s.split('a b c d e f', '') == ['a b c d e f'])
assert(s.format("%%") == "%")
assert(s.format("%i%%", 12) == "12%")
assert(s.format("%i%%%i", 12, 13) == "12%13")
assert(s.format("%s%%", "foo") == "foo%")
assert(s.format("%.1f%%", 3.5) == "3.5%")

View File

@ -128,7 +128,7 @@ hash_map::entry hash_map::entry_modify(entry entry, int *var_count)
{
entry.key = coc::escape_operator(entry.key);
if (entry.value == "var") {
entry.value = "be_const_index("
entry.value = "be_const_var("
+ std::to_string(*var_count) + ")";
++(*var_count);
} else {