LVGL improved lv_coord_arr

This commit is contained in:
Stephan Hadinger 2022-03-08 23:20:35 +01:00
parent 5c89585d10
commit 3dea5fbf58
4 changed files with 1272 additions and 1162 deletions

View File

@ -257,6 +257,7 @@ extern const bcstring be_const_str_arg_name;
extern const bcstring be_const_str_arg_size; extern const bcstring be_const_str_arg_size;
extern const bcstring be_const_str_argument_X20must_X20be_X20a_X20function; extern const bcstring be_const_str_argument_X20must_X20be_X20a_X20function;
extern const bcstring be_const_str_argument_X20must_X20be_X20a_X20list; extern const bcstring be_const_str_argument_X20must_X20be_X20a_X20list;
extern const bcstring be_const_str_argument_X20must_X20be_X20a_X20list_X20or_X20a_X20pointer_X2Bsize;
extern const bcstring be_const_str_as; extern const bcstring be_const_str_as;
extern const bcstring be_const_str_asin; extern const bcstring be_const_str_asin;
extern const bcstring be_const_str_assert; extern const bcstring be_const_str_assert;
@ -645,6 +646,7 @@ extern const bcstring be_const_str_pow;
extern const bcstring be_const_str_power_off; extern const bcstring be_const_str_power_off;
extern const bcstring be_const_str_preinit; extern const bcstring be_const_str_preinit;
extern const bcstring be_const_str_print; extern const bcstring be_const_str_print;
extern const bcstring be_const_str_ptr;
extern const bcstring be_const_str_public_key; extern const bcstring be_const_str_public_key;
extern const bcstring be_const_str_publish; extern const bcstring be_const_str_publish;
extern const bcstring be_const_str_publish_result; extern const bcstring be_const_str_publish_result;

File diff suppressed because it is too large Load Diff

View File

@ -53,7 +53,96 @@ be_local_closure(lv_extra__anonymous_, /* name */
********************************************************************/ ********************************************************************/
be_local_closure(lv_coord_arr_init, /* name */ be_local_closure(lv_coord_arr_init, /* name */
be_nested_proto( be_nested_proto(
8, /* nstack */ 9, /* nstack */
3, /* argc */
2, /* 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(instance),
/* K1 */ be_nested_str(init),
/* K2 */ be_const_int(2),
/* K3 */ be_nested_str(add),
/* K4 */ be_nested_str(stop_iteration),
/* K5 */ be_nested_str(ptr),
/* K6 */ be_nested_str(int),
/* K7 */ be_nested_str(value_error),
/* K8 */ be_nested_str(argument_X20must_X20be_X20a_X20list_X20or_X20a_X20pointer_X2Bsize),
}),
&be_const_str_init,
&be_const_str_solidified,
( &(const binstruction[56]) { /* code */
0x600C0004, // 0000 GETGBL R3 G4
0x5C100200, // 0001 MOVE R4 R1
0x7C0C0200, // 0002 CALL R3 1
0x1C0C0700, // 0003 EQ R3 R3 K0
0x780E001E, // 0004 JMPF R3 #0024
0x600C000F, // 0005 GETGBL R3 G15
0x5C100200, // 0006 MOVE R4 R1
0x60140012, // 0007 GETGBL R5 G18
0x7C0C0400, // 0008 CALL R3 2
0x780E0019, // 0009 JMPF R3 #0024
0x600C0003, // 000A GETGBL R3 G3
0x5C100000, // 000B MOVE R4 R0
0x7C0C0200, // 000C CALL R3 1
0x8C0C0701, // 000D GETMET R3 R3 K1
0x6014000C, // 000E GETGBL R5 G12
0x5C180200, // 000F MOVE R6 R1
0x7C140200, // 0010 CALL R5 1
0x08140B02, // 0011 MUL R5 R5 K2
0x7C0C0400, // 0012 CALL R3 2
0x600C0010, // 0013 GETGBL R3 G16
0x5C100200, // 0014 MOVE R4 R1
0x7C0C0200, // 0015 CALL R3 1
0xA8020008, // 0016 EXBLK 0 #0020
0x5C100600, // 0017 MOVE R4 R3
0x7C100000, // 0018 CALL R4 0
0x8C140103, // 0019 GETMET R5 R0 K3
0x601C0009, // 001A GETGBL R7 G9
0x5C200800, // 001B MOVE R8 R4
0x7C1C0200, // 001C CALL R7 1
0x58200002, // 001D LDCONST R8 K2
0x7C140600, // 001E CALL R5 3
0x7001FFF6, // 001F JMP #0017
0x580C0004, // 0020 LDCONST R3 K4
0xAC0C0200, // 0021 CATCH R3 1 0
0xB0080000, // 0022 RAISE 2 R0 R0
0x70020012, // 0023 JMP #0037
0x600C0004, // 0024 GETGBL R3 G4
0x5C100200, // 0025 MOVE R4 R1
0x7C0C0200, // 0026 CALL R3 1
0x1C0C0705, // 0027 EQ R3 R3 K5
0x780E000C, // 0028 JMPF R3 #0036
0x600C0004, // 0029 GETGBL R3 G4
0x5C100400, // 002A MOVE R4 R2
0x7C0C0200, // 002B CALL R3 1
0x1C0C0706, // 002C EQ R3 R3 K6
0x780E0007, // 002D JMPF R3 #0036
0x600C0003, // 002E GETGBL R3 G3
0x5C100000, // 002F MOVE R4 R0
0x7C0C0200, // 0030 CALL R3 1
0x8C0C0701, // 0031 GETMET R3 R3 K1
0x5C140200, // 0032 MOVE R5 R1
0x08180502, // 0033 MUL R6 R2 K2
0x7C0C0600, // 0034 CALL R3 3
0x70020000, // 0035 JMP #0037
0xB0060F08, // 0036 RAISE 1 K7 K8
0x80000000, // 0037 RET 0
})
)
);
/*******************************************************************/
/********************************************************************
** Solidified function: item
********************************************************************/
be_local_closure(lv_coord_arr_item, /* name */
be_nested_proto(
6, /* nstack */
2, /* argc */ 2, /* argc */
2, /* varg */ 2, /* varg */
0, /* has upvals */ 0, /* has upvals */
@ -61,55 +150,50 @@ be_local_closure(lv_coord_arr_init, /* name */
0, /* has sup protos */ 0, /* has sup protos */
NULL, /* no sub protos */ NULL, /* no sub protos */
1, /* has constants */ 1, /* has constants */
( &(const bvalue[ 7]) { /* constants */ ( &(const bvalue[ 2]) { /* constants */
/* K0 */ be_nested_str(instance), /* K0 */ be_nested_str(get),
/* K1 */ be_nested_str(value_error), /* K1 */ be_const_int(2),
/* K2 */ be_nested_str(argument_X20must_X20be_X20a_X20list),
/* K3 */ be_nested_str(init),
/* K4 */ be_const_int(2),
/* K5 */ be_nested_str(add),
/* K6 */ be_nested_str(stop_iteration),
}), }),
&be_const_str_init, &be_const_str_item,
&be_const_str_solidified, &be_const_str_solidified,
( &(const binstruction[37]) { /* code */ ( &(const binstruction[ 5]) { /* code */
0x60080004, // 0000 GETGBL R2 G4 0x8C080100, // 0000 GETMET R2 R0 K0
0x5C0C0200, // 0001 MOVE R3 R1 0x08100301, // 0001 MUL R4 R1 K1
0x7C080200, // 0002 CALL R2 1 0x58140001, // 0002 LDCONST R5 K1
0x20080500, // 0003 NE R2 R2 K0 0x7C080600, // 0003 CALL R2 3
0x740A0004, // 0004 JMPT R2 #000A 0x80040400, // 0004 RET 1 R2
0x6008000F, // 0005 GETGBL R2 G15 })
0x5C0C0200, // 0006 MOVE R3 R1 )
0x60100012, // 0007 GETGBL R4 G18 );
0x7C080400, // 0008 CALL R2 2 /*******************************************************************/
0x740A0000, // 0009 JMPT R2 #000B
0xB0060302, // 000A RAISE 1 K1 K2
0x60080003, // 000B GETGBL R2 G3 /********************************************************************
0x5C0C0000, // 000C MOVE R3 R0 ** Solidified function: setitem
0x7C080200, // 000D CALL R2 1 ********************************************************************/
0x8C080503, // 000E GETMET R2 R2 K3 be_local_closure(lv_coord_arr_setitem, /* name */
0x6010000C, // 000F GETGBL R4 G12 be_nested_proto(
0x5C140200, // 0010 MOVE R5 R1 8, /* nstack */
0x7C100200, // 0011 CALL R4 1 3, /* argc */
0x08100904, // 0012 MUL R4 R4 K4 2, /* varg */
0x7C080400, // 0013 CALL R2 2 0, /* has upvals */
0x60080010, // 0014 GETGBL R2 G16 NULL, /* no upvals */
0x5C0C0200, // 0015 MOVE R3 R1 0, /* has sup protos */
0x7C080200, // 0016 CALL R2 1 NULL, /* no sub protos */
0xA8020008, // 0017 EXBLK 0 #0021 1, /* has constants */
0x5C0C0400, // 0018 MOVE R3 R2 ( &(const bvalue[ 2]) { /* constants */
0x7C0C0000, // 0019 CALL R3 0 /* K0 */ be_nested_str(set),
0x8C100105, // 001A GETMET R4 R0 K5 /* K1 */ be_const_int(2),
0x60180009, // 001B GETGBL R6 G9 }),
0x5C1C0600, // 001C MOVE R7 R3 &be_const_str_setitem,
0x7C180200, // 001D CALL R6 1 &be_const_str_solidified,
0x581C0004, // 001E LDCONST R7 K4 ( &(const binstruction[ 6]) { /* code */
0x7C100600, // 001F CALL R4 3 0x8C0C0100, // 0000 GETMET R3 R0 K0
0x7001FFF6, // 0020 JMP #0018 0x08140301, // 0001 MUL R5 R1 K1
0x58080006, // 0021 LDCONST R2 K6 0x5C180400, // 0002 MOVE R6 R2
0xAC080200, // 0022 CATCH R2 1 0 0x581C0001, // 0003 LDCONST R7 K1
0xB0080000, // 0023 RAISE 2 R0 R0 0x7C0C0800, // 0004 CALL R3 4
0x80000000, // 0024 RET 0 0x80000000, // 0005 RET 0
}) })
) )
); );
@ -123,9 +207,11 @@ extern const bclass be_class_bytes;
be_local_class(lv_coord_arr, be_local_class(lv_coord_arr,
0, 0,
&be_class_bytes, &be_class_bytes,
be_nested_map(1, be_nested_map(3,
( (struct bmapnode*) &(const bmapnode[]) { ( (struct bmapnode*) &(const bmapnode[]) {
{ be_const_key(init, -1), be_const_closure(lv_coord_arr_init_closure) }, { be_const_key(init, -1), be_const_closure(lv_coord_arr_init_closure) },
{ be_const_key(item, -1), be_const_closure(lv_coord_arr_item_closure) },
{ be_const_key(setitem, -1), be_const_closure(lv_coord_arr_setitem_closure) },
})), })),
be_str_literal("lv_coord_arr") be_str_literal("lv_coord_arr")
); );

View File

@ -3,15 +3,34 @@
var lv_extra = module("lv_extra") var lv_extra = module("lv_extra")
class lv_coord_arr : bytes class lv_coord_arr : bytes
def init(l) # initializer can either create a new structure or map an existing
if type(l) != 'instance' || !isinstance(l, list) raise "value_error", "argument must be a list" end # 1. create a new
# size of the array is 2x number of elements # arg 1 : list of ints
super(self).init(size(l) * 2) #
# 2. map an existing
for e: l # arg 1 : pointer of existing array
self.add(int(e), 2) # arg 2 : number of items in array
def init(l, n)
if type(l) == 'instance' && isinstance(l, list)
# size of the array is 2x number of elements
super(self).init(size(l) * 2)
for e: l
self.add(int(e), 2)
end
elif type(l) == 'ptr' && type(n) == 'int'
super(self).init(l, n * 2)
else
raise "value_error", "argument must be a list or a pointer+size"
end end
end end
def item(n)
return self.get(n * 2, 2)
end
def setitem(n, v)
self.set(n * 2, v, 2)
end
end end
class lv_point_arr : bytes class lv_point_arr : bytes