This commit is contained in:
Lyon 2022-09-24 21:02:44 +08:00
parent a6a1c357d1
commit 968e1433d9
32 changed files with 575 additions and 150 deletions

View File

@ -16,8 +16,8 @@
<repository type="git">https://github.com/pikasTech/pikascript.git</repository>
<releases>
<release date="2022-09-16" version="1.11.0" url="https://gitee.com/Lyon1998/pikascript/attach_files/1151246/download">
- PikaScript v1.11.0
<release date="2022-09-24" version="1.11.2" url="https://gitee.com/Lyon1998/pikascript/attach_files/1151246/download">
- PikaScript v1.11.2
</release>
</releases>
@ -91,7 +91,7 @@
<condition id="Kernel">
<description>The Kernel of the PikaScript</description>
<require Cclass="PikaScript" Cgroup="PikaScript" Csub="Core" Cversion="1.11.0" />
<require Cclass="PikaScript" Cgroup="PikaScript" Csub="Core" Cversion="1.11.2" />
</condition>
<condition id="NO_LVGL_Pack">
@ -142,11 +142,11 @@
-->
<components>
<bundle Cbundle="PikaScript" Cclass="PikaScript" Cversion="1.11.0">
<bundle Cbundle="PikaScript" Cclass="PikaScript" Cversion="1.11.2">
<description>an ultra-lightweight Python engine</description>
<doc>https://pikadoc.readthedocs.io/en/latest/index.html</doc>
<component Cgroup="PikaScript" Csub="Core" Cversion="1.11.0">
<component Cgroup="PikaScript" Csub="Core" Cversion="1.11.2">
<description>PikaScript Kernel</description>
<files>
<file attr="config" category="sourceC" name="pikascript-core/BaseObj.c" />
@ -208,7 +208,7 @@
</RTE_Components_h>
</component>
<component Cgroup="PikaScript" Csub="PikaStdLib" Cversion="1.11.0" condition="Kernel">
<component Cgroup="PikaScript" Csub="PikaStdLib" Cversion="1.11.2" condition="Kernel">
<description>The standard library for PikaScript</description>
<Pre_Include_Local_Component_h>
@ -286,7 +286,7 @@
</files>
</component>
<component Cgroup="PikaScript" Csub="pika_lvgl" Cversion="0.2.0" condition="Kernel">
<component Cgroup="PikaScript" Csub="pika_lvgl" Cversion="latest" condition="Kernel">
<description>The lvgl module for PikaScript</description>
<files>
<file attr="config" category="sourceC" name="pikascript-lib/pika_lvgl/pika_lvgl.c" condition="NO_LVGL_Pack" />

View File

@ -1,3 +1,6 @@
from PikaObj import *
class Tuple:
def __init__(self): ...
@ -36,6 +39,15 @@ class List(Tuple):
def reverse(self):
"""reverse the list"""
def pop(self) -> any:
"""pop the last element"""
def remove(self, val: any):
"""remove the first element"""
def insert(self, i: int, arg: any):
"""insert an arg before the index"""
def __setitem__(self, __key: any, __val: any):
"""support list[] = val"""
@ -75,12 +87,14 @@ class dict_keys:
def __str__(self) -> str: ...
def __len__(self) -> int: ...
class dict_items:
def __iter__(self) -> any: ...
def __next__(self) -> any: ...
def __str__(self) -> str: ...
def __len__(self) -> int: ...
class String:
def __init__(self, s: str): ...
def set(self, s: str): ...

View File

@ -53,7 +53,7 @@ class SysObj:
@staticmethod
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")
def list() -> any: ...
def list(*val) -> any: ...
@staticmethod
@PIKA_C_MACRO_IF("PIKA_BUILTIN_STRUCT_ENABLE")

View File

@ -16,8 +16,8 @@
<repository type="git">https://github.com/pikasTech/pikascript.git</repository>
<releases>
<release date="2022-09-16" version="1.11.0" url="https://gitee.com/Lyon1998/pikascript/attach_files/1151246/download">
- PikaScript v1.11.0
<release date="2022-09-24" version="1.11.2" url="https://gitee.com/Lyon1998/pikascript/attach_files/1151246/download">
- PikaScript v1.11.2
</release>
</releases>
@ -91,7 +91,7 @@
<condition id="Kernel">
<description>The Kernel of the PikaScript</description>
<require Cclass="PikaScript" Cgroup="PikaScript" Csub="Core" Cversion="1.11.0" />
<require Cclass="PikaScript" Cgroup="PikaScript" Csub="Core" Cversion="1.11.2" />
</condition>
<condition id="NO_LVGL_Pack">
@ -142,11 +142,11 @@
-->
<components>
<bundle Cbundle="PikaScript" Cclass="PikaScript" Cversion="1.11.0">
<bundle Cbundle="PikaScript" Cclass="PikaScript" Cversion="1.11.2">
<description>an ultra-lightweight Python engine</description>
<doc>https://pikadoc.readthedocs.io/en/latest/index.html</doc>
<component Cgroup="PikaScript" Csub="Core" Cversion="1.11.0">
<component Cgroup="PikaScript" Csub="Core" Cversion="1.11.2">
<description>PikaScript Kernel</description>
<files>
<file attr="config" category="sourceC" name="pikascript-core/BaseObj.c" />
@ -208,7 +208,7 @@
</RTE_Components_h>
</component>
<component Cgroup="PikaScript" Csub="PikaStdLib" Cversion="1.11.0" condition="Kernel">
<component Cgroup="PikaScript" Csub="PikaStdLib" Cversion="1.11.2" condition="Kernel">
<description>The standard library for PikaScript</description>
<Pre_Include_Local_Component_h>
@ -286,7 +286,7 @@
</files>
</component>
<component Cgroup="PikaScript" Csub="pika_lvgl" Cversion="0.2.0" condition="Kernel">
<component Cgroup="PikaScript" Csub="pika_lvgl" Cversion="latest" condition="Kernel">
<description>The lvgl module for PikaScript</description>
<files>
<file attr="config" category="sourceC" name="pikascript-lib/pika_lvgl/pika_lvgl.c" condition="NO_LVGL_Pack" />

View File

@ -1,9 +1,9 @@
import shutil
import os
version = "1.11.0"
version_lvgl = "0.2.0"
date = "2022-09-16"
version = "1.11.2"
version_lvgl = "latest"
date = "2022-09-24"
url = "https://gitee.com/Lyon1998/pikascript/attach_files/1151246/download"

View File

@ -226,7 +226,7 @@ class dropdown(lv_obj):
def get_option_cnt(self) -> int: ...
def get_selected_str(self) -> str: ...
def get_option_index(self, option: str) -> int: ...
def get_symbol(self) -> int: ...
def get_symbol(self) -> str: ...
def get_selected_highlight(self) -> int: ...
def get_dir(self) -> int: ...
def open(self): ...

View File

@ -22,6 +22,9 @@ void PikaStdData_List___init__(PikaObj *self);
void PikaStdData_List___setitem__(PikaObj *self, Arg* __key, Arg* __val);
char* PikaStdData_List___str__(PikaObj *self);
void PikaStdData_List_append(PikaObj *self, Arg* arg);
void PikaStdData_List_insert(PikaObj *self, int i, Arg* arg);
Arg* PikaStdData_List_pop(PikaObj *self);
void PikaStdData_List_remove(PikaObj *self, Arg* val);
void PikaStdData_List_reverse(PikaObj *self);
void PikaStdData_List_set(PikaObj *self, int i, Arg* arg);

View File

@ -34,7 +34,7 @@ int PikaStdLib_SysObj_id(PikaObj *self, Arg* obj);
int PikaStdLib_SysObj_int(PikaObj *self, Arg* arg);
Arg* PikaStdLib_SysObj_iter(PikaObj *self, Arg* arg);
int PikaStdLib_SysObj_len(PikaObj *self, Arg* arg);
Arg* PikaStdLib_SysObj_list(PikaObj *self);
Arg* PikaStdLib_SysObj_list(PikaObj *self, PikaTuple* val);
PikaObj* PikaStdLib_SysObj_open(PikaObj *self, char* path, char* mode);
int PikaStdLib_SysObj_ord(PikaObj *self, char* val);
void PikaStdLib_SysObj_print(PikaObj *self, PikaTuple* val, PikaDict* ops);

View File

@ -462,6 +462,22 @@ void PikaStdData_List_appendMethod(PikaObj *self, Args *args){
PikaStdData_List_append(self, arg);
}
void PikaStdData_List_insertMethod(PikaObj *self, Args *args){
int i = args_getInt(args, "i");
Arg* arg = args_getArg(args, "arg");
PikaStdData_List_insert(self, i, arg);
}
void PikaStdData_List_popMethod(PikaObj *self, Args *args){
Arg* res = PikaStdData_List_pop(self);
method_returnArg(args, res);
}
void PikaStdData_List_removeMethod(PikaObj *self, Args *args){
Arg* val = args_getArg(args, "val");
PikaStdData_List_remove(self, val);
}
void PikaStdData_List_reverseMethod(PikaObj *self, Args *args){
PikaStdData_List_reverse(self);
}
@ -479,6 +495,9 @@ PikaObj *New_PikaStdData_List(Args *args){
class_defineMethod(self, "__setitem__(__key,__val)", PikaStdData_List___setitem__Method);
class_defineMethod(self, "__str__()", PikaStdData_List___str__Method);
class_defineMethod(self, "append(arg)", PikaStdData_List_appendMethod);
class_defineMethod(self, "insert(i,arg)", PikaStdData_List_insertMethod);
class_defineMethod(self, "pop()", PikaStdData_List_popMethod);
class_defineMethod(self, "remove(val)", PikaStdData_List_removeMethod);
class_defineMethod(self, "reverse()", PikaStdData_List_reverseMethod);
class_defineMethod(self, "set(i,arg)", PikaStdData_List_setMethod);
return self;
@ -1009,7 +1028,8 @@ void PikaStdLib_SysObj_lenMethod(PikaObj *self, Args *args){
}
void PikaStdLib_SysObj_listMethod(PikaObj *self, Args *args){
Arg* res = PikaStdLib_SysObj_list(self);
PikaTuple* val = args_getTuple(args, "val");
Arg* res = PikaStdLib_SysObj_list(self, val);
method_returnArg(args, res);
}
@ -1099,7 +1119,7 @@ PikaObj *New_PikaStdLib_SysObj(Args *args){
class_defineMethod(self, "iter(arg)", PikaStdLib_SysObj_iterMethod);
class_defineMethod(self, "len(arg)", PikaStdLib_SysObj_lenMethod);
#if PIKA_BUILTIN_STRUCT_ENABLE
class_defineMethod(self, "list()", PikaStdLib_SysObj_listMethod);
class_defineMethod(self, "list(*val)", PikaStdLib_SysObj_listMethod);
#endif
#if PIKA_FILEIO_ENABLE
class_defineMethod(self, "open(path,mode)", PikaStdLib_SysObj_openMethod);
@ -1804,8 +1824,8 @@ void pika_lvgl_dropdown_get_selected_strMethod(PikaObj *self, Args *args){
}
void pika_lvgl_dropdown_get_symbolMethod(PikaObj *self, Args *args){
int res = pika_lvgl_dropdown_get_symbol(self);
method_returnInt(args, res);
char* res = pika_lvgl_dropdown_get_symbol(self);
method_returnStr(args, res);
}
void pika_lvgl_dropdown_get_textMethod(PikaObj *self, Args *args){

View File

@ -17,8 +17,8 @@ PikaObj *__pikaMain;
PikaObj *pikaScriptInit(void){
__platform_printf("======[pikascript packages installed]======\r\n");
pks_printVersion();
__platform_printf("PikaStdLib==v1.11.0\r\n");
__platform_printf("pika_lvgl==v0.2.0\r\n");
__platform_printf("PikaStdLib==v1.11.2\r\n");
__platform_printf("pika_lvgl==latest\r\n");
__platform_printf("===========================================\r\n");
__pikaMain = newRootObj("pikaMain", New_PikaMain);
extern unsigned char pikaModules_py_a[];

View File

@ -28,7 +28,7 @@ char* pika_lvgl_dropdown_get_options(PikaObj *self);
int pika_lvgl_dropdown_get_selected(PikaObj *self);
int pika_lvgl_dropdown_get_selected_highlight(PikaObj *self);
char* pika_lvgl_dropdown_get_selected_str(PikaObj *self);
int pika_lvgl_dropdown_get_symbol(PikaObj *self);
char* pika_lvgl_dropdown_get_symbol(PikaObj *self);
char* pika_lvgl_dropdown_get_text(PikaObj *self);
int pika_lvgl_dropdown_is_open(PikaObj *self);
void pika_lvgl_dropdown_open(PikaObj *self);

View File

@ -197,14 +197,15 @@ int64_t obj_getInt(PikaObj* self, char* argPath) {
}
Arg* obj_getArg(PikaObj* self, char* argPath) {
PIKA_BOOL isClass = PIKA_FALSE;
PikaObj* obj = obj_getHostObjWithIsTemp(self, argPath, &isClass);
PIKA_BOOL is_temp = PIKA_FALSE;
PikaObj* obj = obj_getHostObjWithIsTemp(self, argPath, &is_temp);
if (NULL == obj) {
return NULL;
}
Arg* res = NULL;
char* argName = strPointToLastToken(argPath, '.');
Arg* res = args_getArg(obj->list, argName);
if (isClass) {
res = args_getArg(obj->list, argName);
if (is_temp) {
obj_setArg(self, "_buf", res);
res = obj_getArg(self, "_buf");
obj_deinit(obj);
@ -443,14 +444,18 @@ PikaObj* _arg_to_obj(Arg* self, PIKA_BOOL* pIsTemp) {
PikaObj* New_PikaStdData_String(Args * args);
PikaObj* obj = newNormalObj(New_PikaStdData_String);
obj_setStr(obj, "str", arg_getStr(self));
if (NULL != pIsTemp) {
*pIsTemp = PIKA_TRUE;
}
return obj;
}
if (arg_getType(self) == ARG_TYPE_BYTES) {
PikaObj* New_PikaStdData_ByteArray(Args * args);
PikaObj* obj = newNormalObj(New_PikaStdData_ByteArray);
obj_setArg(obj, "raw", self);
if (NULL != pIsTemp) {
*pIsTemp = PIKA_TRUE;
}
return obj;
}
#endif
@ -516,13 +521,13 @@ exit:
}
PikaObj* obj_getObj(PikaObj* self, char* objPath) {
PIKA_BOOL isClass = PIKA_FALSE;
return __obj_getObjWithKeepDeepth(self, objPath, &isClass, 0);
PIKA_BOOL is_temp = PIKA_FALSE;
return __obj_getObjWithKeepDeepth(self, objPath, &is_temp, 0);
}
PikaObj* obj_getHostObj(PikaObj* self, char* objPath) {
PIKA_BOOL isClass = PIKA_FALSE;
return __obj_getObjWithKeepDeepth(self, objPath, &isClass, 1);
PIKA_BOOL is_temp = PIKA_FALSE;
return __obj_getObjWithKeepDeepth(self, objPath, &is_temp, 1);
}
PikaObj* obj_getHostObjWithIsTemp(PikaObj* self,
@ -590,6 +595,30 @@ PikaObj* methodArg_getDefContext(Arg* method_arg) {
return context;
}
void _update_proxy(PikaObj* self, char* name) {
#if PIKA_NANO_ENABLE
return;
#endif
if (!(self->proxy & PIKA_PROXY_GETATTRIBUTE)) {
if (strEqu(name, "__getattribute__")) {
self->proxy |= PIKA_PROXY_GETATTRIBUTE;
return;
}
}
if (!(self->proxy & PIKA_PROXY_GETATTR)) {
if (strEqu(name, "__getattr__")) {
self->proxy |= PIKA_PROXY_GETATTR;
return;
}
}
if (!(self->proxy & PIKA_PROXY_SETATTR)) {
if (strEqu(name, "__setattr__")) {
self->proxy |= PIKA_PROXY_SETATTR;
return;
}
}
}
static void obj_saveMethodInfo(PikaObj* self, MethodInfo* method_info) {
Args buffs = {0};
method_info->pars = method_info->dec;
@ -608,6 +637,7 @@ static void obj_saveMethodInfo(PikaObj* self, MethodInfo* method_info) {
sizeof(method_info_def_context));
arg = arg_append(arg, method_info->pars, size_pars + 1);
_update_proxy(self, method_info->name);
args_setArg(self->list, arg);
strsDeinit(&buffs);
}
@ -997,6 +1027,7 @@ PikaObj* New_PikaObj(void) {
self->list = New_args(NULL);
self->refcnt = 0;
self->constructor = NULL;
self->proxy = 0;
return self;
}

View File

@ -71,8 +71,13 @@ struct PikaObj {
Args* list;
uint8_t refcnt;
void* constructor;
uint8_t proxy;
};
#define PIKA_PROXY_GETATTRIBUTE 0x01
#define PIKA_PROXY_GETATTR 0x02
#define PIKA_PROXY_SETATTR 0x04
typedef PikaObj* (*NewFun)(Args* args);
typedef PikaObj* (*InitFun)(PikaObj* self, Args* args);
typedef PikaObj VMParameters;

View File

@ -179,14 +179,21 @@ static char* __removeTokensBetween(Args* outBuffs,
return output;
}
char* _remove_sub_stmt(Args* outBuffs, char* stmt) {
Args buffs = {0};
stmt = strsCopy(&buffs, stmt);
stmt = __removeTokensBetween(&buffs, stmt, "(", ")");
stmt = __removeTokensBetween(&buffs, stmt, "[", "]");
stmt = __removeTokensBetween(&buffs, stmt, "{", "}");
char* res = args_cacheStr(outBuffs, stmt);
strsDeinit(&buffs);
return res;
}
static enum StmtType Lexer_matchStmtType(char* right) {
Args buffs = {0};
enum StmtType stmtType = STMT_none;
char* rightWithoutSubStmt = __removeTokensBetween(&buffs, right, "(", ")");
rightWithoutSubStmt =
__removeTokensBetween(&buffs, rightWithoutSubStmt, "[", "]");
rightWithoutSubStmt =
__removeTokensBetween(&buffs, rightWithoutSubStmt, "{", "}");
char* rightWithoutSubStmt = _remove_sub_stmt(&buffs, right);
PIKA_BOOL is_get_operator = PIKA_FALSE;
PIKA_BOOL is_get_method = PIKA_FALSE;
@ -1528,7 +1535,7 @@ AST* AST_parseStmt(AST* ast, char* stmt) {
enum StmtType stmtType = Lexer_matchStmtType(right);
/* solve operator stmt */
if (STMT_operator == stmtType) {
char* rightWithoutSubStmt = strsDeleteBetween(&buffs, right, '(', ')');
char* rightWithoutSubStmt = _remove_sub_stmt(&buffs, right);
char* operator= Lexer_getOperator(&buffs, rightWithoutSubStmt);
if (NULL == operator) {
result = PIKA_RES_ERR_SYNTAX_ERROR;

View File

@ -508,48 +508,147 @@ static Arg* VM_instruction_handler_NEW(PikaObj* self,
return new_arg;
}
static Arg* _proxy_getattribute(PikaObj* host, char* name) {
#if PIKA_NANO_ENABLE
return NULL;
#endif
if ('@' != name[0] && (host->proxy & PIKA_PROXY_GETATTRIBUTE)) {
args_setStr(host->list, "@name", name);
/* clang-format off */
PIKA_PYTHON(
@res = __getattribute__(@name)
)
/* clang-format on */
const uint8_t bytes[] = {
0x0c, 0x00, /* instruct array size */
0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x07, 0x00, 0x00, 0x04, 0x18,
0x00,
/* instruct array */
0x1d, 0x00, /* const pool size */
0x00, 0x40, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x5f, 0x5f, 0x67, 0x65,
0x74, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x5f,
0x5f, 0x00, 0x40, 0x72, 0x65, 0x73, 0x00, /* const pool */
};
pikaVM_runByteCode(host, (uint8_t*)bytes);
return args_getArg(host->list, "@res");
}
return NULL;
}
static Arg* _proxy_getattr(PikaObj* host, char* name) {
#if PIKA_NANO_ENABLE
return NULL;
#endif
if ('@' != name[0] && (host->proxy & PIKA_PROXY_GETATTR)) {
args_setStr(host->list, "@name", name);
/* clang-format off */
PIKA_PYTHON(
@res = __getattr__(@name)
)
/* clang-format on */
const uint8_t bytes[] = {
0x0c, 0x00, /* instruct array size */
0x10, 0x81, 0x01, 0x00, 0x00, 0x02, 0x07, 0x00, 0x00, 0x04, 0x13,
0x00,
/* instruct array */
0x18, 0x00, /* const pool size */
0x00, 0x40, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x5f, 0x5f, 0x67, 0x65,
0x74, 0x61, 0x74, 0x74, 0x72, 0x5f, 0x5f, 0x00, 0x40, 0x72, 0x65,
0x73, 0x00, /* const pool */
};
pikaVM_runByteCode(host, (uint8_t*)bytes);
return args_getArg(host->list, "@res");
}
return NULL;
}
static Arg* VM_instruction_handler_REF(PikaObj* self,
VMState* vm,
char* data,
Arg* arg_ret_reg) {
if (strEqu(data, (char*)"True")) {
PikaObj* host_object = NULL;
char* arg_path = data;
char* arg_name = strPointToLastToken(arg_path, '.');
PIKA_BOOL is_temp = PIKA_FALSE;
if (strEqu(arg_path, (char*)"True")) {
return arg_setInt(arg_ret_reg, "", 1);
}
if (strEqu(data, (char*)"False")) {
if (strEqu(arg_path, (char*)"False")) {
return arg_setInt(arg_ret_reg, "", 0);
}
if (strEqu(data, (char*)"None")) {
if (strEqu(arg_path, (char*)"None")) {
return arg_setNull(arg_ret_reg);
}
if (strEqu(data, (char*)"RuntimeError")) {
if (strEqu(arg_path, (char*)"RuntimeError")) {
return arg_setInt(arg_ret_reg, "", PIKA_RES_ERR_RUNTIME_ERROR);
}
Arg* arg = NULL;
if (data[0] == '.') {
Arg* res = NULL;
if (arg_path[0] == '.') {
/* find host from stack */
Arg* host_obj = stack_popArg_alloc(&(vm->stack));
if (argType_isObject(arg_getType(host_obj))) {
arg = arg_copy_noalloc(obj_getArg(arg_getPtr(host_obj), data + 1),
host_object = arg_getPtr(host_obj);
res = arg_copy_noalloc(obj_getArg(host_object, arg_path + 1),
arg_ret_reg);
}
arg_deinit(host_obj);
goto exit;
}
/* host_object is self */
if (NULL == host_object) {
if (!strIsContain(arg_path, '.')) {
host_object = vm->locals;
}
}
/* find in local list first */
arg = arg_copy_noalloc(obj_getArg(vm->locals, data), arg_ret_reg);
if (NULL == arg) {
/* find in global list second */
arg = arg_copy_noalloc(obj_getArg(vm->globals, data), arg_ret_reg);
if (NULL == host_object) {
host_object = obj_getHostObjWithIsTemp(vm->locals, arg_path, &is_temp);
}
/* find in global list */
if (NULL == host_object) {
host_object = obj_getHostObjWithIsTemp(vm->globals, arg_path, &is_temp);
}
/* error cannot found host_object */
if (NULL == host_object) {
goto exit;
}
/* proxy */
if (NULL == res) {
res = _proxy_getattribute(host_object, arg_name);
}
/* find res in host */
if (NULL == res) {
res = args_getArg(host_object->list, arg_name);
}
/* find res in globlas */
if (NULL == res) {
res = args_getArg(vm->globals->list, arg_name);
}
/* proxy */
if (NULL == res) {
res = _proxy_getattr(host_object, arg_name);
}
exit:
if (NULL == arg) {
if (NULL == res) {
VMState_setErrorCode(vm, PIKA_RES_ERR_ARG_NO_FOUND);
__platform_printf("NameError: name '%s' is not defined\r\n", data);
__platform_printf("NameError: name '%s' is not defined\r\n", arg_path);
} else {
res = arg_copy_noalloc(res, arg_ret_reg);
}
return arg;
if (is_temp) {
obj_deinit(host_object);
}
return res;
}
static Arg* VM_instruction_handler_GER(PikaObj* self,
@ -1051,6 +1150,7 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
if (strEqu(run_path, "super")) {
run_path = _find_super_class_name(vm);
vm->in_super = PIKA_TRUE;
vm->super_invoke_deepth = VMState_getInvokeDeepthNow(vm);
skip_init = PIKA_TRUE;
}
#endif
@ -1061,13 +1161,6 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
goto exit;
}
#if !PIKA_NANO_ENABLE
if (!skip_init && vm->in_super) {
vm->in_super = PIKA_FALSE;
obj_this = obj_getPtr(vm->locals, _find_self_name(vm));
}
#endif
/* get method host obj from reg */
if (NULL == method_host && _checkLReg(run_path)) {
uint8_t reg_index = _getLRegIndex(run_path);
@ -1120,6 +1213,14 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
goto exit;
}
#if !PIKA_NANO_ENABLE
if (!skip_init && vm->in_super &&
VMState_getInvokeDeepthNow(vm) == vm->super_invoke_deepth - 1) {
vm->in_super = PIKA_FALSE;
obj_this = obj_getPtr(vm->locals, _find_self_name(vm));
}
#endif
/* get object this */
if (NULL == obj_this) {
obj_this = method_host;
@ -1140,7 +1241,7 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
method = obj_getMethodArg_noalloc(vm->globals, run_path, &arg_reg1);
}
/* assert method type */
/* assert method exist */
if (NULL == method || ARG_TYPE_NONE == arg_getType(method)) {
/* error, method no found */
VMState_setErrorCode(vm, PIKA_RES_ERR_ARG_NO_FOUND);
@ -1148,6 +1249,15 @@ static Arg* VM_instruction_handler_RUN(PikaObj* self,
goto exit;
}
/* assert methodd type */
if (!argType_isCallable(arg_getType(method))) {
/* error, method no found */
VMState_setErrorCode(vm, PIKA_RES_ERR_ARG_NO_FOUND);
__platform_printf("TypeError: '%s' object is not callable\r\n",
run_path);
goto exit;
}
/* create sub local scope */
sub_locals = New_PikaObj();
@ -1247,7 +1357,7 @@ static char* __get_transferd_str(Args* buffs, char* str, size_t* iout_p) {
char hex_str[] = "0x00";
hex_str[2] = str_rep[i + 2];
hex_str[3] = str_rep[i + 3];
char hex = (char)strtol(hex_str, NULL, 0);
char hex = (char)strtoll(hex_str, NULL, 0);
transfered_str[i_out++] = hex;
i += 3;
continue;
@ -1292,33 +1402,65 @@ static Arg* VM_instruction_handler_BYT(PikaObj* self,
return arg_newBytes((uint8_t*)data, strGetSize(data));
}
static PIKA_BOOL _proxy_setattr(PikaObj* self, char* name, Arg* arg) {
#if PIKA_NANO_ENABLE
return PIKA_FALSE;
#endif
if (self->proxy & PIKA_PROXY_SETATTR) {
obj_setStr(self, "@name", name);
obj_setArg(self, "@value", arg);
/* clang-format off */
PIKA_PYTHON(
__setattr__(@name, @value)
)
/* clang-format on */
const uint8_t bytes[] = {
0x0c, 0x00, /* instruct array size */
0x10, 0x81, 0x01, 0x00, 0x10, 0x01, 0x07, 0x00, 0x00, 0x02, 0x0e,
0x00,
/* instruct array */
0x1a, 0x00, /* const pool size */
0x00, 0x40, 0x6e, 0x61, 0x6d, 0x65, 0x00, 0x40, 0x76, 0x61, 0x6c,
0x75, 0x65, 0x00, 0x5f, 0x5f, 0x73, 0x65, 0x74, 0x61, 0x74, 0x74,
0x72, 0x5f, 0x5f, 0x00, /* const pool */
};
pikaVM_runByteCode(self, (uint8_t*)bytes);
return PIKA_TRUE;
}
return PIKA_FALSE;
}
static Arg* VM_instruction_handler_OUT(PikaObj* self,
VMState* vm,
char* data,
Arg* arg_ret_reg) {
char* arg_path = data;
char* arg_name = strPointToLastToken(arg_path, '.');
PikaObj* host_obj = NULL;
PIKA_BOOL is_temp = PIKA_FALSE;
arg_newReg(outArg_reg, PIKA_ARG_BUFF_SIZE);
Arg* outArg = stack_popArg(&vm->stack, &outArg_reg);
Arg* out_arg = stack_popArg(&vm->stack, &outArg_reg);
// Arg* outArg = stack_popArg_alloc(&vm->stack);
ArgType outArg_type = arg_getType(outArg);
ArgType outArg_type = arg_getType(out_arg);
if (VMState_getInvokeDeepthNow(vm) > 0) {
/* in block, is a keyword arg */
arg_setIsKeyword(outArg, PIKA_TRUE);
arg_setName(outArg, data);
return arg_copy_noalloc(outArg, arg_ret_reg);
arg_setIsKeyword(out_arg, PIKA_TRUE);
arg_setName(out_arg, arg_path);
return arg_copy_noalloc(out_arg, arg_ret_reg);
}
if (_checkLReg(data)) {
uint8_t index = _getLRegIndex(data);
if (_checkLReg(arg_path)) {
uint8_t index = _getLRegIndex(arg_path);
if (argType_isObject(outArg_type)) {
PikaObj* obj = arg_getPtr(outArg);
PikaObj* obj = arg_getPtr(out_arg);
VMState_setLReg(vm, index, obj);
arg_deinit(outArg);
arg_deinit(out_arg);
}
return NULL;
}
PikaObj* hostObj = vm->locals;
PikaObj* context = vm->locals;
/* match global_list */
if (args_isArgExist(vm->locals->list, "__gl")) {
char* global_list = args_getStr(vm->locals->list, "__gl");
@ -1329,24 +1471,34 @@ static Arg* VM_instruction_handler_OUT(PikaObj* self,
char token_buff[32] = {0};
for (int i = 0; i < strCountSign(global_list, ',') + 1; i++) {
char* global_arg = strPopToken(token_buff, global_list_buff, ',');
/* matched global arg, hostObj set to global */
if (strEqu(global_arg, data)) {
hostObj = vm->globals;
/* matched global arg, context set to global */
if (strEqu(global_arg, arg_path)) {
context = vm->globals;
}
}
arg_deinit(global_list_arg);
}
/* use RunAs object */
if (args_isArgExist(vm->locals->list, "__runAs")) {
hostObj = args_getPtr(vm->locals->list, "__runAs");
context = args_getPtr(vm->locals->list, "__runAs");
}
/* set free object to nomal object */
if (ARG_TYPE_OBJECT_NEW == outArg_type) {
arg_setType(outArg, ARG_TYPE_OBJECT);
arg_setType(out_arg, ARG_TYPE_OBJECT);
}
/* ouput arg to locals */
obj_setArg_noCopy(hostObj, data, outArg);
/* ouput arg to context */
if (arg_path == arg_name) {
obj_setArg_noCopy(context, arg_path, out_arg);
return NULL;
}
host_obj = obj_getHostObjWithIsTemp(context, arg_path, &is_temp);
if (_proxy_setattr(host_obj, arg_name, out_arg)) {
return NULL;
}
obj_setArg_noCopy(context, arg_path, out_arg);
return NULL;
}
@ -1373,18 +1525,18 @@ static Arg* VM_instruction_handler_NUM(PikaObj* self,
Arg* numArg = arg_ret_reg;
/* hex */
if (data[1] == 'x' || data[1] == 'X') {
return arg_setInt(numArg, "", strtol(data, NULL, 0));
return arg_setInt(numArg, "", strtoll(data, NULL, 0));
}
if (data[1] == 'o' || data[1] == 'O') {
char strtol_buff[10] = {0};
strtol_buff[0] = '0';
__platform_memcpy(strtol_buff + 1, data + 2, strGetSize(data) - 2);
return arg_setInt(numArg, "", strtol(strtol_buff, NULL, 0));
char strtoll_buff[10] = {0};
strtoll_buff[0] = '0';
__platform_memcpy(strtoll_buff + 1, data + 2, strGetSize(data) - 2);
return arg_setInt(numArg, "", strtoll(strtoll_buff, NULL, 0));
}
if (data[1] == 'b' || data[1] == 'B') {
char strtol_buff[10] = {0};
__platform_memcpy(strtol_buff, data + 2, strGetSize(data) - 2);
return arg_setInt(numArg, "", strtol(strtol_buff, NULL, 2));
char strtoll_buff[10] = {0};
__platform_memcpy(strtoll_buff, data + 2, strGetSize(data) - 2);
return arg_setInt(numArg, "", strtoll(strtoll_buff, NULL, 2));
}
/* float */
if (strIsContain(data, '.') ||
@ -2664,7 +2816,11 @@ void VMState_solveUnusedStack(VMState* vm) {
char* res = obj_toStr(arg_getPtr(arg));
__platform_printf("%s\r\n", res);
} else if (type == ARG_TYPE_INT) {
#if PIKA_PRINT_LLD_ENABLE
__platform_printf("%lld\r\n", arg_getInt(arg));
#else
__platform_printf("%d\r\n", (int)arg_getInt(arg));
#endif
} else if (type == ARG_TYPE_FLOAT) {
__platform_printf("%f\r\n", arg_getFloat(arg));
} else if (type == ARG_TYPE_STRING) {
@ -2702,6 +2858,7 @@ static VMParameters* __pikaVM_runByteCodeFrameWithState(
.run_state = run_state,
.ins_cnt = 0,
.in_super = PIKA_FALSE,
.super_invoke_deepth = 0,
};
stack_init(&(vm.stack));
VMState_initReg(&vm);

View File

@ -77,6 +77,7 @@ struct VMState {
uint8_t try_error_code;
uint32_t ins_cnt;
PIKA_BOOL in_super;
uint8_t super_invoke_deepth;
PikaObj* lreg[PIKA_REGIST_SIZE];
PIKA_BOOL ireg[PIKA_REGIST_SIZE];
RunState* run_state;

View File

@ -1,5 +1,5 @@
#define PIKA_VERSION_MAJOR 1
#define PIKA_VERSION_MINOR 11
#define PIKA_VERSION_MICRO 0
#define PIKA_VERSION_MICRO 2
#define PIKA_EDIT_TIME "2022/09/16 15:33:53"
#define PIKA_EDIT_TIME "2022/09/24 20:58:10"

View File

@ -401,10 +401,10 @@ char* getPrintSring(Args* self, char* name, char* valString) {
return res;
}
char* getPrintStringFromInt(Args* self, char* name, int32_t val) {
char* getPrintStringFromInt(Args* self, char* name, int64_t val) {
Args buffs = {0};
char* res = NULL;
char* valString = strsFormat(&buffs, 32, "%d", val);
char* valString = strsFormat(&buffs, 32, "%lld", val);
res = getPrintSring(self, name, valString);
strsDeinit(&buffs);
return res;
@ -440,7 +440,7 @@ char* args_print(Args* self, char* name) {
}
if (type == ARG_TYPE_INT) {
int32_t val = args_getInt(self, name);
int64_t val = args_getInt(self, name);
res = getPrintStringFromInt(self, name, val);
goto exit;
}
@ -600,6 +600,64 @@ PIKA_RES list_append(PikaList* self, Arg* arg) {
return args_setInt(&self->super, "top", top + 1);
}
Arg* list_pop(PikaList* list) {
int top = args_getInt(&list->super, "top");
if (top <= 0) {
return NULL;
}
Arg* arg = list_getArg(list, top - 1);
Arg* res = arg_copy(arg);
args_removeArg(&list->super, arg);
args_setInt(&list->super, "top", top - 1);
return res;
}
PIKA_RES list_remove(PikaList* list, Arg* arg) {
int top = args_getInt(&list->super, "top");
int i_remove = 0;
if (top <= 0) {
return PIKA_RES_ERR_OUT_OF_RANGE;
}
for (int i = 0; i < top; i++) {
Arg* arg_now = list_getArg(list, i);
if (arg_isEqual(arg_now, arg)) {
i_remove = i;
args_removeArg(&list->super, arg_now);
break;
}
}
/* move args */
for (int i = i_remove + 1; i < top; i++) {
char buff[11];
char* i_str = fast_itoa(buff, i - 1);
Arg* arg_now = list_getArg(list, i);
arg_setName(arg_now, i_str);
}
args_setInt(&list->super, "top", top - 1);
return PIKA_RES_OK;
}
PIKA_RES list_insert(PikaList* self, int index, Arg* arg) {
int top = args_getInt(&self->super, "top");
if (index > top) {
return PIKA_RES_ERR_OUT_OF_RANGE;
}
/* move args */
for (int i = top - 1; i >= index; i--) {
char buff[11];
char* i_str = fast_itoa(buff, i + 1);
Arg* arg_now = list_getArg(self, i);
arg_setName(arg_now, i_str);
}
char buff[11];
char* i_str = fast_itoa(buff, index);
Arg* arg_to_push = arg_copy(arg);
arg_setName(arg_to_push, i_str);
args_setArg(&self->super, arg_to_push);
args_setInt(&self->super, "top", top + 1);
return PIKA_RES_OK;
}
size_t list_getSize(PikaList* self) {
pika_assert(NULL != self);
return args_getInt(&self->super, "top");

View File

@ -189,5 +189,8 @@ PikaDict* args_getDict(Args* self, char* name);
char* strsFormatList(Args* out_buffs, char* fmt, PikaList* list);
char* args_cacheStr(Args* self, char* str);
PIKA_RES list_insert(PikaList* self, int index, Arg* arg);
Arg* list_pop(PikaList* list);
PIKA_RES list_remove(PikaList* list, Arg* arg);
#endif

View File

@ -301,6 +301,10 @@
#define PIKA_STRING_UTF8_ENABLE 1
#endif
#ifndef PIKA_PRINT_LLD_ENABLE
#define PIKA_PRINT_LLD_ENABLE 1
#endif
/* configuration validation */
#endif

View File

@ -77,3 +77,22 @@ PikaObj* PikaStdData_List___add__(PikaObj* self, PikaObj* others) {
}
return res;
}
void PikaStdData_List_insert(PikaObj *self, int i, Arg* arg){
PikaList* list = obj_getPtr(self, "list");
if (PIKA_RES_OK != list_insert(list, i, arg)) {
obj_setErrorCode(self, 1);
obj_setSysOut(self, "Error: index exceeded lengh of list.");
}
}
Arg* PikaStdData_List_pop(PikaObj *self){
PikaList* list = obj_getPtr(self, "list");
return list_pop(list);
}
void PikaStdData_List_remove(PikaObj *self, Arg* val){
PikaList* list = obj_getPtr(self, "list");
list_remove(list, val);
}

View File

@ -148,18 +148,9 @@ exit:
}
Arg* PikaStdLib_SysObj_iter(PikaObj* self, Arg* arg) {
/* a String, return a StringObj */
if (ARG_TYPE_STRING == arg_getType(arg)) {
obj_setStr(self, "_sobj", arg_getStr(arg));
return arg_newMetaObj(New_PikaStdLib_StringObj);
}
/* a MATE object, return itself */
if (ARG_TYPE_OBJECT_META == arg_getType(arg)) {
return arg_copy(arg);
}
/* object */
if (argType_isObject(arg_getType(arg))) {
PikaObj* arg_obj = arg_getPtr(arg);
PIKA_BOOL is_temp = 0;
PikaObj* arg_obj = _arg_to_obj(arg, &is_temp);
NewFun _clsptr = (NewFun)arg_obj->constructor;
if (_clsptr == New_PikaStdLib_RangeObj) {
/* found RangeObj, return directly */
@ -179,9 +170,10 @@ Arg* PikaStdLib_SysObj_iter(PikaObj* self, Arg* arg) {
pikaVM_runByteCode(arg_obj, (uint8_t*)bytes);
Arg* res = arg_copy(args_getArg(arg_obj->list, "__res"));
obj_removeArg(arg_obj, "__res");
return res;
if (is_temp) {
obj_refcntDec(arg_obj);
}
return arg_newNull();
return res;
}
Arg* PikaStdLib_SysObj_range(PikaObj* self, PikaTuple* ax) {
@ -305,15 +297,48 @@ int PikaStdLib_SysObj_len(PikaObj* self, Arg* arg) {
return -1;
}
Arg* PikaStdLib_SysObj_list(PikaObj* self) {
Arg* PikaStdLib_SysObj_list(PikaObj* self, PikaTuple* val) {
#if PIKA_BUILTIN_STRUCT_ENABLE
if (1 == tuple_getSize(val)) {
Arg* in = tuple_getArg(val, 0);
obj_setArg(self, "__list", in);
/* clang-format off */
PIKA_PYTHON(
__res = []
for __item in __list:
__res.append(__item)
del __item
del __list
)
/* clang-format on */
const uint8_t bytes[] = {
0x3c, 0x00, /* instruct array size */
0x00, 0x95, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x10, 0x81, 0x07,
0x00, 0x00, 0x02, 0x0e, 0x00, 0x00, 0x04, 0x13, 0x00, 0x00, 0x82,
0x17, 0x00, 0x00, 0x04, 0x24, 0x00, 0x00, 0x0d, 0x24, 0x00, 0x00,
0x07, 0x2b, 0x00, 0x11, 0x81, 0x24, 0x00, 0x01, 0x02, 0x2d, 0x00,
0x00, 0x86, 0x3a, 0x00, 0x00, 0x8c, 0x13, 0x00, 0x00, 0x8c, 0x24,
0x00, 0x00, 0x8c, 0x07, 0x00,
/* instruct array */
0x3d, 0x00, /* const pool size */
0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x00, 0x5f, 0x5f, 0x6c, 0x69,
0x73, 0x74, 0x00, 0x69, 0x74, 0x65, 0x72, 0x00, 0x24, 0x6c, 0x30,
0x00, 0x24, 0x6c, 0x30, 0x2e, 0x5f, 0x5f, 0x6e, 0x65, 0x78, 0x74,
0x5f, 0x5f, 0x00, 0x5f, 0x5f, 0x69, 0x74, 0x65, 0x6d, 0x00, 0x32,
0x00, 0x5f, 0x5f, 0x72, 0x65, 0x73, 0x2e, 0x61, 0x70, 0x70, 0x65,
0x6e, 0x64, 0x00, 0x2d, 0x31, 0x00,
/* const pool */
};
pikaVM_runByteCode(self, (uint8_t*)bytes);
return arg_copy(obj_getArg(self, "__res"));
}
PikaObj* New_PikaStdData_List(Args * args);
return arg_newDirectObj(New_PikaStdData_List);
#else
obj_setErrorCode(self, 1);
__platform_printf("[Error] built-in list is not enabled.\r\n");
return arg_newNull();
#endif
return arg_newNull();
}
Arg* PikaStdLib_SysObj_dict(PikaObj* self) {
@ -369,6 +394,23 @@ Arg* PikaStdLib_SysObj_bytes(PikaObj* self, Arg* val) {
Arg* bytes = arg_newBytes((uint8_t*)arg_getStr(val), size);
return bytes;
}
#if !PIKA_NANO_ENABLE
if (argType_isObject(type)) {
PikaObj* obj = arg_getPtr(val);
PikaObj* New_PikaStdData_List(Args * args);
PikaObj* New_PikaStdData_Tuple(Args * args);
if (obj->constructor == New_PikaStdData_List ||
obj->constructor == New_PikaStdData_Tuple) {
PikaList* list = obj_getPtr(obj, "list");
Arg* bytes = arg_newBytes(NULL, list_getSize(list));
uint8_t* bytes_raw = arg_getBytes(bytes);
for (size_t i = 0; i < list_getSize(list); i++) {
bytes_raw[i] = (uint8_t)list_getInt(list, i);
}
return bytes;
}
}
#endif
obj_setErrorCode(self, 1);
__platform_printf("Error: input arg type not supported.\r\n");
return arg_newNull();
@ -539,6 +581,6 @@ exit:
return;
}
void PikaStdLib_SysObj_exit(PikaObj *self){
void PikaStdLib_SysObj_exit(PikaObj* self) {
pks_vm_exit();
}

View File

@ -1,4 +1,11 @@
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "../../lvgl.h"
#endif
#ifdef PIKASCRIPT
#include "pika_lvgl_point_t.h"
void pika_lvgl_point_t___init__(PikaObj* self) {
@ -6,3 +13,4 @@ void pika_lvgl_point_t___init__(PikaObj* self) {
args_setStruct(self->list, "lv_point_struct", lv_point);
obj_setPtr(self, "lv_point", args_getStruct(self->list, "lv_point_struct"));
}
#endif

View File

@ -1,4 +1,11 @@
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "../../lvgl.h"
#endif
#ifdef PIKASCRIPT
#include "pika_lvgl_lv_timer_t.h"
PikaEventListener* g_pika_lv_timer_event_listener;
@ -34,3 +41,4 @@ void pika_lvgl_lv_timer_t__del(PikaObj* self) {
lv_timer_t* lv_timer = obj_getPtr(self, "lv_timer");
lv_timer_del(lv_timer);
}
#endif

View File

@ -1,5 +1,11 @@
#include "BaseObj.h"
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "../../lvgl.h"
#endif
#ifdef PIKASCRIPT
#include "BaseObj.h"
#include "pika_lvgl.h"
#include "pika_lvgl_arc.h"
#include "pika_lvgl_bar.h"
@ -176,7 +182,7 @@ void pika_lvgl_checkbox_set_text_static(PikaObj *self, char* txt){
char* pika_lvgl_checkbox_get_text(PikaObj *self){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
return lv_checkbox_get_text(lv_obj);
return (char*) lv_checkbox_get_text(lv_obj);
}
void pika_lvgl_dropdown___init__(PikaObj* self, PikaObj* parent) {
@ -220,7 +226,7 @@ int pika_lvgl_dropdown_get_option_index(PikaObj *self, char* txt){
}
char* pika_lvgl_dropdown_get_options(PikaObj *self){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
return lv_dropdown_get_options(lv_obj);
return (char*) lv_dropdown_get_options(lv_obj);
}
int pika_lvgl_dropdown_get_selected(PikaObj *self){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
@ -234,17 +240,17 @@ int pika_lvgl_dropdown_get_selected_highlight(PikaObj *self){
char* pika_lvgl_dropdown_get_selected_str(PikaObj *self){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
obj_setBytes(self, "_buff",NULL, 128);
char* _buff = obj_getBytes(self, "_buff");
char* _buff = (char*)obj_getBytes(self, "_buff");
lv_dropdown_get_selected_str(lv_obj, _buff, 128);
return _buff;
}
int pika_lvgl_dropdown_get_symbol(PikaObj *self){
char* pika_lvgl_dropdown_get_symbol(PikaObj *self){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
return lv_dropdown_get_symbol(lv_obj);
return (char*)lv_dropdown_get_symbol(lv_obj);
}
char* pika_lvgl_dropdown_get_text(PikaObj *self){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
return lv_dropdown_get_text(lv_obj);
return (char*)lv_dropdown_get_text(lv_obj);
}
int pika_lvgl_dropdown_is_open(PikaObj *self){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
@ -355,3 +361,4 @@ void pika_lvgl_textarea_set_one_line(PikaObj* self, int en) {
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_textarea_set_one_line(lv_obj, en);
}
#endif

View File

@ -1,6 +1,12 @@
#include "pika_lvgl.h"
#include "BaseObj.h"
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "../../lvgl.h"
#endif
#ifdef PIKASCRIPT
#include "pika_lvgl.h"
#include "BaseObj.h"
#include "pika_lvgl_ALIGN.h"
#include "pika_lvgl_ANIM.h"
#include "pika_lvgl_EVENT.h"
@ -190,4 +196,4 @@ PikaObj* pika_lvgl_timer_create_basic(PikaObj *self){
obj_setPtr(new_obj,"lv_timer", lv_timer);
return new_obj;
}
#endif

View File

@ -1,5 +1,12 @@
#include "pika_lvgl_indev_t.h"
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "../../lvgl.h"
#endif
#ifdef PIKASCRIPT
#include "pika_lvgl_indev_t.h"
void pika_lvgl_indev_t_get_vect(PikaObj* self, PikaObj* point) {
lv_indev_t* lv_indev = obj_getPtr(self, "lv_indev");
@ -8,3 +15,4 @@ void pika_lvgl_indev_t_get_vect(PikaObj* self, PikaObj* point) {
obj_setInt(point, "x", lv_point->x);
obj_setInt(point, "y", lv_point->y);
}
#endif

View File

@ -1,4 +1,11 @@
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "../../lvgl.h"
#endif
#ifdef PIKASCRIPT
#include "pika_lvgl_lv_event.h"
int pika_lvgl_lv_event_get_code(PikaObj *self){
@ -14,3 +21,4 @@ PikaObj* pika_lvgl_lv_event_get_target(PikaObj *self){
obj_setPtr(new_obj, "lv_obj", lv_obj);
return new_obj;
}
#endif

View File

@ -1,7 +1,14 @@
#include "pika_lvgl_lv_obj.h"
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "../../lvgl.h"
#endif
#ifdef PIKASCRIPT
#include "pika_lvgl_lv_obj.h"
#include "BaseObj.h"
#include "dataStrs.h"
#include "lvgl.h"
#include "pika_lvgl.h"
#include "pika_lvgl_arc.h"
#include "pika_lvgl_lv_event.h"
@ -88,7 +95,7 @@ void pika_lvgl_lv_obj_add_event_cb(PikaObj* self,
void pika_lvgl_lv_obj_add_style(PikaObj *self, PikaObj* style, int selector){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_state_t* lv_style = obj_getPtr(style, "lv_style");
lv_style_t* lv_style = obj_getPtr(style, "lv_style");
lv_obj_add_style(lv_obj, lv_style, selector);
}
@ -106,3 +113,4 @@ void pika_lvgl_lv_obj_set_pos(PikaObj *self, int x, int y){
lv_obj_t* lv_obj = obj_getPtr(self, "lv_obj");
lv_obj_set_pos(lv_obj, x, y);
}
#endif

View File

@ -1,4 +1,11 @@
#include "lvgl.h"
#if defined(LV_LVGL_H_INCLUDE_SIMPLE)
#include "lvgl.h"
#else
#include "../../lvgl.h"
#endif
#ifdef PIKASCRIPT
#include "pika_lvgl_style_t.h"
void pika_lvgl_style_t_init(PikaObj* self) {
@ -60,3 +67,4 @@ void pika_lvgl_style_t_set_shadow_width(PikaObj *self, int w){
lv_style_t* lv_style = obj_getPtr(self, "lv_style");
lv_style_set_shadow_width(lv_style, w);
}
#endif

View File

@ -1,3 +1,3 @@
pikascript-core==v1.11.0
PikaStdLib==v1.11.0
pika_lvgl==v0.2.0
pikascript-core==v1.11.2
PikaStdLib==v1.11.2
pika_lvgl==latest