mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
support __str__ for String(), find mem leak when print(String('test'))
This commit is contained in:
parent
9edb478e46
commit
a97d6f3f76
@ -2,104 +2,60 @@ from PikaObj import *
|
|||||||
|
|
||||||
|
|
||||||
class List(TinyObj):
|
class List(TinyObj):
|
||||||
def __init__(self):
|
def __init__(self): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# add an arg after the end of list
|
# add an arg after the end of list
|
||||||
def append(self, arg: any):
|
def append(self, arg: any): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# get an arg by the index
|
# get an arg by the index
|
||||||
def get(self, i: int) -> any:
|
def get(self, i: int) -> any: ...
|
||||||
pass
|
|
||||||
|
|
||||||
# set an arg by the index
|
# set an arg by the index
|
||||||
def set(self, i: int, arg: any):
|
def set(self, i: int, arg: any): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# get the length of list
|
# get the length of list
|
||||||
def len(self) -> int:
|
def len(self) -> int: ...
|
||||||
pass
|
|
||||||
|
|
||||||
# support for loop
|
# support for loop
|
||||||
def __iter__(self) -> any:
|
def __iter__(self) -> any: ...
|
||||||
pass
|
|
||||||
|
|
||||||
# support for loop
|
# support for loop
|
||||||
def __next__(self) -> any:
|
def __next__(self) -> any: ...
|
||||||
pass
|
|
||||||
|
|
||||||
# support list[] = val
|
# support list[] = val
|
||||||
def __set__(self, __key: any, __val: any):
|
def __set__(self, __key: any, __val: any): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# support val = list[]
|
# support val = list[]
|
||||||
def __get__(self, __key: any) -> any:
|
def __get__(self, __key: any) -> any: ...
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Dict(TinyObj):
|
class Dict(TinyObj):
|
||||||
def __init__(self):
|
def __init__(self): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# get an arg by the key
|
# get an arg by the key
|
||||||
def get(self, key: str) -> any:
|
def get(self, key: str) -> any: ...
|
||||||
pass
|
|
||||||
|
|
||||||
# set an arg by the key
|
# set an arg by the key
|
||||||
def set(self, key: str, arg: any):
|
def set(self, key: str, arg: any): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# remove an arg by the key
|
# remove an arg by the key
|
||||||
def remove(self, key: str):
|
def remove(self, key: str): ...
|
||||||
pass
|
def __iter__(self) -> any: ...
|
||||||
|
def __next__(self) -> any: ...
|
||||||
def __iter__(self) -> any:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __next__(self) -> any:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# support dict[] = val
|
# support dict[] = val
|
||||||
def __set__(self, __key: any, __val: any):
|
def __set__(self, __key: any, __val: any): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# support val = dict[]
|
# support val = dict[]
|
||||||
def __get__(self, __key: any) -> any:
|
def __get__(self, __key: any) -> any: ...
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class String(TinyObj):
|
class String(TinyObj):
|
||||||
def __init__(self, s: str):
|
def __init__(self, s: str): ...
|
||||||
pass
|
def set(self, s: str): ...
|
||||||
|
def get(self) -> str: ...
|
||||||
def set(self, s: str):
|
def __iter__(self) -> any: ...
|
||||||
pass
|
def __next__(self) -> any: ...
|
||||||
|
|
||||||
def get(self) -> str:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __iter__(self) -> any:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __next__(self) -> any:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# support string[] = val
|
# support string[] = val
|
||||||
def __set__(self, __key: any, __val: any):
|
def __set__(self, __key: any, __val: any): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# support val = string[]
|
# support val = string[]
|
||||||
def __get__(self, __key: any) -> any:
|
def __get__(self, __key: any) -> any: ...
|
||||||
pass
|
# support str()
|
||||||
|
def __str__(self) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
class ByteArray(List):
|
class ByteArray(List):
|
||||||
# convert a string to ByteArray
|
# convert a string to ByteArray
|
||||||
def fromString(self, s: str):
|
def fromString(self, s: str): ...
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Utils(TinyObj):
|
class Utils(TinyObj):
|
||||||
def int_to_bytes(self, val: int) -> bytes:
|
# convert a int to bytes
|
||||||
pass
|
def int_to_bytes(self, val: int) -> bytes: ...
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "PikaObj.h"
|
#include "PikaStdData_String.h"
|
||||||
|
|
||||||
Arg* PikaStdData_String___iter__(PikaObj* self) {
|
Arg* PikaStdData_String___iter__(PikaObj* self) {
|
||||||
obj_setInt(self, "__iter_i", 0);
|
obj_setInt(self, "__iter_i", 0);
|
||||||
@ -33,8 +33,8 @@ Arg* PikaStdData_String___next__(PikaObj* self) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arg* PikaStdData_String___get__(PikaObj* self) {
|
Arg* PikaStdData_String___get__(PikaObj* self, Arg* __key) {
|
||||||
int key_i = obj_getInt(self, "__key");
|
int key_i = arg_getInt(__key);
|
||||||
char* str = obj_getStr(self, "str");
|
char* str = obj_getStr(self, "str");
|
||||||
uint16_t len = strGetSize(str);
|
uint16_t len = strGetSize(str);
|
||||||
char char_buff[] = " ";
|
char char_buff[] = " ";
|
||||||
@ -46,4 +46,19 @@ Arg* PikaStdData_String___get__(PikaObj* self) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PikaStdData_String___set__(PikaObj* self) {}
|
void PikaStdData_String___set__(PikaObj* self, Arg* __key, Arg* __val) {
|
||||||
|
int key_i = arg_getInt(__key);
|
||||||
|
char* str = obj_getStr(self, "str");
|
||||||
|
char* val = arg_getStr(__val);
|
||||||
|
uint16_t len = strGetSize(str);
|
||||||
|
if (key_i >= len) {
|
||||||
|
obj_setErrorCode(self, 1);
|
||||||
|
__platform_printf("Error String Overflow\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
str[key_i] = val[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
char* PikaStdData_String___str__(PikaObj* self) {
|
||||||
|
return obj_getStr(self, "str");
|
||||||
|
}
|
||||||
|
@ -116,7 +116,7 @@ char* PikaStdLib_SysObj_str(PikaObj* self, Arg* arg) {
|
|||||||
res = strsFormat(&buffs, 11, "%f", val);
|
res = strsFormat(&buffs, 11, "%f", val);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if (ARG_TYPE_OBJECT == type) {
|
if (argType_isObject(type)) {
|
||||||
res = obj_toStr(arg_getPtr(arg));
|
res = obj_toStr(arg_getPtr(arg));
|
||||||
if (NULL != res) {
|
if (NULL != res) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -2,104 +2,60 @@ from PikaObj import *
|
|||||||
|
|
||||||
|
|
||||||
class List(TinyObj):
|
class List(TinyObj):
|
||||||
def __init__(self):
|
def __init__(self): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# add an arg after the end of list
|
# add an arg after the end of list
|
||||||
def append(self, arg: any):
|
def append(self, arg: any): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# get an arg by the index
|
# get an arg by the index
|
||||||
def get(self, i: int) -> any:
|
def get(self, i: int) -> any: ...
|
||||||
pass
|
|
||||||
|
|
||||||
# set an arg by the index
|
# set an arg by the index
|
||||||
def set(self, i: int, arg: any):
|
def set(self, i: int, arg: any): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# get the length of list
|
# get the length of list
|
||||||
def len(self) -> int:
|
def len(self) -> int: ...
|
||||||
pass
|
|
||||||
|
|
||||||
# support for loop
|
# support for loop
|
||||||
def __iter__(self) -> any:
|
def __iter__(self) -> any: ...
|
||||||
pass
|
|
||||||
|
|
||||||
# support for loop
|
# support for loop
|
||||||
def __next__(self) -> any:
|
def __next__(self) -> any: ...
|
||||||
pass
|
|
||||||
|
|
||||||
# support list[] = val
|
# support list[] = val
|
||||||
def __set__(self, __key: any, __val: any):
|
def __set__(self, __key: any, __val: any): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# support val = list[]
|
# support val = list[]
|
||||||
def __get__(self, __key: any) -> any:
|
def __get__(self, __key: any) -> any: ...
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Dict(TinyObj):
|
class Dict(TinyObj):
|
||||||
def __init__(self):
|
def __init__(self): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# get an arg by the key
|
# get an arg by the key
|
||||||
def get(self, key: str) -> any:
|
def get(self, key: str) -> any: ...
|
||||||
pass
|
|
||||||
|
|
||||||
# set an arg by the key
|
# set an arg by the key
|
||||||
def set(self, key: str, arg: any):
|
def set(self, key: str, arg: any): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# remove an arg by the key
|
# remove an arg by the key
|
||||||
def remove(self, key: str):
|
def remove(self, key: str): ...
|
||||||
pass
|
def __iter__(self) -> any: ...
|
||||||
|
def __next__(self) -> any: ...
|
||||||
def __iter__(self) -> any:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __next__(self) -> any:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# support dict[] = val
|
# support dict[] = val
|
||||||
def __set__(self, __key: any, __val: any):
|
def __set__(self, __key: any, __val: any): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# support val = dict[]
|
# support val = dict[]
|
||||||
def __get__(self, __key: any) -> any:
|
def __get__(self, __key: any) -> any: ...
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class String(TinyObj):
|
class String(TinyObj):
|
||||||
def __init__(self, s: str):
|
def __init__(self, s: str): ...
|
||||||
pass
|
def set(self, s: str): ...
|
||||||
|
def get(self) -> str: ...
|
||||||
def set(self, s: str):
|
def __iter__(self) -> any: ...
|
||||||
pass
|
def __next__(self) -> any: ...
|
||||||
|
|
||||||
def get(self) -> str:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __iter__(self) -> any:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __next__(self) -> any:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# support string[] = val
|
# support string[] = val
|
||||||
def __set__(self, __key: any, __val: any):
|
def __set__(self, __key: any, __val: any): ...
|
||||||
pass
|
|
||||||
|
|
||||||
# support val = string[]
|
# support val = string[]
|
||||||
def __get__(self, __key: any) -> any:
|
def __get__(self, __key: any) -> any: ...
|
||||||
pass
|
# support str()
|
||||||
|
def __str__(self) -> str: ...
|
||||||
|
|
||||||
|
|
||||||
class ByteArray(List):
|
class ByteArray(List):
|
||||||
# convert a string to ByteArray
|
# convert a string to ByteArray
|
||||||
def fromString(self, s: str):
|
def fromString(self, s: str): ...
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class Utils(TinyObj):
|
class Utils(TinyObj):
|
||||||
def int_to_bytes(self, val: int) -> bytes:
|
# convert a int to bytes
|
||||||
pass
|
def int_to_bytes(self, val: int) -> bytes: ...
|
||||||
|
@ -9,7 +9,11 @@ import test_module1
|
|||||||
import test_cmodule
|
import test_cmodule
|
||||||
import TempDevTest as dev
|
import TempDevTest as dev
|
||||||
import TemplateDevice
|
import TemplateDevice
|
||||||
|
from PikaStdData import String
|
||||||
|
|
||||||
|
mem = PikaStdLib.MemChecker()
|
||||||
print('hello pikascript!')
|
print('hello pikascript!')
|
||||||
|
print('mem used max:')
|
||||||
|
mem.max()
|
||||||
|
|
||||||
dev.test()
|
dev.test()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "PikaObj.h"
|
#include "PikaStdData_String.h"
|
||||||
|
|
||||||
Arg* PikaStdData_String___iter__(PikaObj* self) {
|
Arg* PikaStdData_String___iter__(PikaObj* self) {
|
||||||
obj_setInt(self, "__iter_i", 0);
|
obj_setInt(self, "__iter_i", 0);
|
||||||
@ -33,8 +33,8 @@ Arg* PikaStdData_String___next__(PikaObj* self) {
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
Arg* PikaStdData_String___get__(PikaObj* self) {
|
Arg* PikaStdData_String___get__(PikaObj* self, Arg* __key) {
|
||||||
int key_i = obj_getInt(self, "__key");
|
int key_i = arg_getInt(__key);
|
||||||
char* str = obj_getStr(self, "str");
|
char* str = obj_getStr(self, "str");
|
||||||
uint16_t len = strGetSize(str);
|
uint16_t len = strGetSize(str);
|
||||||
char char_buff[] = " ";
|
char char_buff[] = " ";
|
||||||
@ -46,4 +46,19 @@ Arg* PikaStdData_String___get__(PikaObj* self) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PikaStdData_String___set__(PikaObj* self) {}
|
void PikaStdData_String___set__(PikaObj* self, Arg* __key, Arg* __val) {
|
||||||
|
int key_i = arg_getInt(__key);
|
||||||
|
char* str = obj_getStr(self, "str");
|
||||||
|
char* val = arg_getStr(__val);
|
||||||
|
uint16_t len = strGetSize(str);
|
||||||
|
if (key_i >= len) {
|
||||||
|
obj_setErrorCode(self, 1);
|
||||||
|
__platform_printf("Error String Overflow\r\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
str[key_i] = val[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
char* PikaStdData_String___str__(PikaObj* self) {
|
||||||
|
return obj_getStr(self, "str");
|
||||||
|
}
|
||||||
|
@ -116,7 +116,7 @@ char* PikaStdLib_SysObj_str(PikaObj* self, Arg* arg) {
|
|||||||
res = strsFormat(&buffs, 11, "%f", val);
|
res = strsFormat(&buffs, 11, "%f", val);
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
if (ARG_TYPE_OBJECT == type) {
|
if (argType_isObject(type)) {
|
||||||
res = obj_toStr(arg_getPtr(arg));
|
res = obj_toStr(arg_getPtr(arg));
|
||||||
if (NULL != res) {
|
if (NULL != res) {
|
||||||
goto exit;
|
goto exit;
|
||||||
|
@ -2091,3 +2091,44 @@ TEST(pikaMain, slice_a12) {
|
|||||||
EXPECT_EQ(pikaMemNow(), 0);
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
TEST(pikaMain, str_string) {
|
||||||
|
/* init */
|
||||||
|
pikaMemInfo.heapUsedMax = 0;
|
||||||
|
/* run */
|
||||||
|
PikaObj* self = newRootObj("pikaMain", New_PikaMain);
|
||||||
|
__platform_printf("BEGIN\r\n");
|
||||||
|
obj_run(self,
|
||||||
|
"a = PikaStdData.String('test')\n"
|
||||||
|
"print(a)\n"
|
||||||
|
);
|
||||||
|
/* assert */
|
||||||
|
EXPECT_STREQ(log_buff[0], "test\r\n");
|
||||||
|
EXPECT_STREQ(log_buff[1], "BEGIN\r\n");
|
||||||
|
/* deinit */
|
||||||
|
obj_deinit(self);
|
||||||
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if PIKA_SYNTEX_ITEM_SLICE_ENABLE
|
||||||
|
TEST(pikaMain, string_index) {
|
||||||
|
/* init */
|
||||||
|
pikaMemInfo.heapUsedMax = 0;
|
||||||
|
/* run */
|
||||||
|
PikaObj* self = newRootObj("pikaMain", New_PikaMain);
|
||||||
|
__platform_printf("BEGIN\r\n");
|
||||||
|
obj_run(self,
|
||||||
|
"a = PikaStdData.String('test')\n"
|
||||||
|
"a[1]\n"
|
||||||
|
"a[1] = 'q'\n"
|
||||||
|
"print(a)\n"
|
||||||
|
);
|
||||||
|
/* assert */
|
||||||
|
EXPECT_STREQ(log_buff[0], "tqst\r\n");
|
||||||
|
EXPECT_STREQ(log_buff[1], "e\r\n");
|
||||||
|
EXPECT_STREQ(log_buff[2], "BEGIN\r\n");
|
||||||
|
/* deinit */
|
||||||
|
obj_deinit(self);
|
||||||
|
EXPECT_EQ(pikaMemNow(), 0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
@ -59,7 +59,7 @@ void Baseobj_print(PikaObj* self, Args* args) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ARG_TYPE_OBJECT == arg_type) {
|
if (argType_isObject(arg_type)) {
|
||||||
char* to_str = obj_toStr(arg_getPtr(arg));
|
char* to_str = obj_toStr(arg_getPtr(arg));
|
||||||
if (NULL != to_str) {
|
if (NULL != to_str) {
|
||||||
__platform_printf("%s\r\n", to_str);
|
__platform_printf("%s\r\n", to_str);
|
||||||
|
@ -178,7 +178,7 @@ int LibObj_staticLinkFile(LibObj* self, char* input_file_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t __foreach_handler_listModules(Arg* argEach, Args* context) {
|
static int32_t __foreach_handler_listModules(Arg* argEach, Args* context) {
|
||||||
if (arg_getType(argEach) == ARG_TYPE_OBJECT) {
|
if (argType_isObject(arg_getType(argEach))) {
|
||||||
PikaObj* module_obj = arg_getPtr(argEach);
|
PikaObj* module_obj = arg_getPtr(argEach);
|
||||||
__platform_printf("%s\r\n", obj_getStr(module_obj, "name"));
|
__platform_printf("%s\r\n", obj_getStr(module_obj, "name"));
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ void LibObj_listModules(LibObj* self) {
|
|||||||
|
|
||||||
static int32_t __foreach_handler_writeBytecode(Arg* argEach, Args* context) {
|
static int32_t __foreach_handler_writeBytecode(Arg* argEach, Args* context) {
|
||||||
FILE* out_file = args_getPtr(context, "out_file");
|
FILE* out_file = args_getPtr(context, "out_file");
|
||||||
if (arg_getType(argEach) == ARG_TYPE_OBJECT) {
|
if (argType_isObject(arg_getType(argEach))) {
|
||||||
PikaObj* module_obj = arg_getPtr(argEach);
|
PikaObj* module_obj = arg_getPtr(argEach);
|
||||||
char* bytecode = obj_getPtr(module_obj, "bytecode");
|
char* bytecode = obj_getPtr(module_obj, "bytecode");
|
||||||
size_t bytecode_size = obj_getBytesSize(module_obj, "buff");
|
size_t bytecode_size = obj_getBytesSize(module_obj, "buff");
|
||||||
@ -206,7 +206,7 @@ static int32_t __foreach_handler_writeBytecode(Arg* argEach, Args* context) {
|
|||||||
|
|
||||||
static int32_t __foreach_handler_writeIndex(Arg* argEach, Args* context) {
|
static int32_t __foreach_handler_writeIndex(Arg* argEach, Args* context) {
|
||||||
FILE* out_file = args_getPtr(context, "out_file");
|
FILE* out_file = args_getPtr(context, "out_file");
|
||||||
if (arg_getType(argEach) == ARG_TYPE_OBJECT) {
|
if (argType_isObject(arg_getType(argEach))) {
|
||||||
PikaObj* module_obj = arg_getPtr(argEach);
|
PikaObj* module_obj = arg_getPtr(argEach);
|
||||||
uint32_t bytecode_size = obj_getBytesSize(module_obj, "buff");
|
uint32_t bytecode_size = obj_getBytesSize(module_obj, "buff");
|
||||||
char buff[LIB_INFO_BLOCK_SIZE - sizeof(uint32_t)] = {0};
|
char buff[LIB_INFO_BLOCK_SIZE - sizeof(uint32_t)] = {0};
|
||||||
@ -221,7 +221,7 @@ static int32_t __foreach_handler_writeIndex(Arg* argEach, Args* context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t __foreach_handler_getModuleNum(Arg* argEach, Args* context) {
|
static int32_t __foreach_handler_getModuleNum(Arg* argEach, Args* context) {
|
||||||
if (arg_getType(argEach) == ARG_TYPE_OBJECT) {
|
if (argType_isObject(arg_getType(argEach))) {
|
||||||
args_setInt(context, "module_num",
|
args_setInt(context, "module_num",
|
||||||
args_getInt(context, "module_num") + 1);
|
args_getInt(context, "module_num") + 1);
|
||||||
}
|
}
|
||||||
@ -347,8 +347,7 @@ int Lib_loadLibraryFileToArray(char* origin_file_name, char* out_folder) {
|
|||||||
char* array_name = strsGetLastToken(&buffs, origin_file_name, '/');
|
char* array_name = strsGetLastToken(&buffs, origin_file_name, '/');
|
||||||
array_name = strsReplace(&buffs, array_name, ".", "_");
|
array_name = strsReplace(&buffs, array_name, ".", "_");
|
||||||
__platform_printf(" loading %s[]...\n", array_name);
|
__platform_printf(" loading %s[]...\n", array_name);
|
||||||
pika_fputs("#include \"PikaPlatform.h\"\n",
|
pika_fputs("#include \"PikaPlatform.h\"\n", fp);
|
||||||
fp);
|
|
||||||
pika_fputs("/* warning: auto generated file, please do not modify */\n",
|
pika_fputs("/* warning: auto generated file, please do not modify */\n",
|
||||||
fp);
|
fp);
|
||||||
pika_fputs("PIKA_BYTECODE_ALIGN const unsigned char ", fp);
|
pika_fputs("PIKA_BYTECODE_ALIGN const unsigned char ", fp);
|
||||||
@ -485,7 +484,7 @@ exit:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t __foreach_handler_printStates(Arg* argEach, Args* context) {
|
int32_t __foreach_handler_printStates(Arg* argEach, Args* context) {
|
||||||
if (arg_getType(argEach) == ARG_TYPE_OBJECT) {
|
if (argType_isObject(arg_getType(argEach))) {
|
||||||
PikaObj* module_obj = arg_getPtr(argEach);
|
PikaObj* module_obj = arg_getPtr(argEach);
|
||||||
__platform_printf("%s: %s\r\n", obj_getStr(module_obj, "name"),
|
__platform_printf("%s: %s\r\n", obj_getStr(module_obj, "name"),
|
||||||
obj_getStr(module_obj, "state"));
|
obj_getStr(module_obj, "state"));
|
||||||
@ -498,7 +497,7 @@ void pikaMaker_printStates(PikaMaker* self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t __foreach_handler_getFirstNocompiled(Arg* argEach, Args* context) {
|
int32_t __foreach_handler_getFirstNocompiled(Arg* argEach, Args* context) {
|
||||||
if (arg_getType(argEach) == ARG_TYPE_OBJECT) {
|
if (argType_isObject(arg_getType(argEach))) {
|
||||||
PikaObj* module_obj = arg_getPtr(argEach);
|
PikaObj* module_obj = arg_getPtr(argEach);
|
||||||
char* state = obj_getStr(module_obj, "state");
|
char* state = obj_getStr(module_obj, "state");
|
||||||
if (args_isArgExist(context, "res")) {
|
if (args_isArgExist(context, "res")) {
|
||||||
@ -544,7 +543,7 @@ void pikaMaker_compileModuleWithDepends(PikaMaker* self, char* module_name) {
|
|||||||
|
|
||||||
int32_t __foreach_handler_linkCompiledModules(Arg* argEach, Args* context) {
|
int32_t __foreach_handler_linkCompiledModules(Arg* argEach, Args* context) {
|
||||||
Args buffs = {0};
|
Args buffs = {0};
|
||||||
if (arg_getType(argEach) == ARG_TYPE_OBJECT) {
|
if (argType_isObject(arg_getType(argEach))) {
|
||||||
LibObj* lib = args_getPtr(context, "__lib");
|
LibObj* lib = args_getPtr(context, "__lib");
|
||||||
PikaMaker* maker = args_getPtr(context, "__maker");
|
PikaMaker* maker = args_getPtr(context, "__maker");
|
||||||
PikaObj* module_obj = arg_getPtr(argEach);
|
PikaObj* module_obj = arg_getPtr(argEach);
|
||||||
|
@ -429,7 +429,7 @@ static PikaObj* __obj_getObjDirect(PikaObj* self, char* name) {
|
|||||||
return __obj_initSubObj(self, name);
|
return __obj_initSubObj(self, name);
|
||||||
}
|
}
|
||||||
/* found Objcet */
|
/* found Objcet */
|
||||||
if (type == ARG_TYPE_OBJECT || type == ARG_TYPE_OBJECT_NEW) {
|
if (argType_isObject(type)) {
|
||||||
return args_getPtr(self->list, name);
|
return args_getPtr(self->list, name);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -385,3 +385,10 @@ uint8_t* arg_getContent(Arg* self) {
|
|||||||
void arg_setNext(Arg* self, Arg* next) {
|
void arg_setNext(Arg* self, Arg* next) {
|
||||||
self->next = next;
|
self->next = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t argType_isObject(ArgType type) {
|
||||||
|
if (ARG_TYPE_OBJECT == type || ARG_TYPE_OBJECT_NEW == type) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@ -116,5 +116,6 @@ void arg_deinitHeap(Arg* self);
|
|||||||
Arg* arg_setBytes(Arg* self, char* name, uint8_t* src, size_t size);
|
Arg* arg_setBytes(Arg* self, char* name, uint8_t* src, size_t size);
|
||||||
void arg_printBytes(Arg* self);
|
void arg_printBytes(Arg* self);
|
||||||
Arg* arg_loadFile(Arg* self, char* filename);
|
Arg* arg_loadFile(Arg* self, char* filename);
|
||||||
|
uint8_t argType_isObject(ArgType type);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -434,7 +434,7 @@ char* args_print(Args* self, char* name) {
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == ARG_TYPE_OBJECT) {
|
if (argType_isObject(type)) {
|
||||||
void* val = args_getPtr(self, name);
|
void* val = args_getPtr(self, name);
|
||||||
res = getPrintStringFromPtr(self, name, val);
|
res = getPrintStringFromPtr(self, name, val);
|
||||||
goto exit;
|
goto exit;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user