update pckage for PikaStdLib.py

This commit is contained in:
lyon 2022-01-09 00:13:02 +08:00
parent 2f8ce3768c
commit 659d92c377
2 changed files with 24 additions and 0 deletions

View File

@ -31,6 +31,9 @@ class SysObj(BaseObj):
def float(arg: any) -> float:
pass
def str(arg: any) -> str:
pass
def iter(arg: any) -> any:
pass

View File

@ -76,6 +76,27 @@ int PikaStdLib_SysObj_int(PikaObj* self, Arg* arg) {
return -999999999;
}
char* PikaStdLib_SysObj_str(PikaObj* self, Arg* arg) {
ArgType type = arg_getType(arg);
Args* buffs = New_strBuff();
char* res = NULL;
do {
if (TYPE_INT == type) {
int val = arg_getInt(arg);
res = strsFormat(buffs, 11, "%d", val);
break;
}
if (TYPE_FLOAT == type) {
float val = arg_getFloat(arg);
res = strsFormat(buffs, 11, "%f", val);
break;
}
} while (0);
obj_setStr(self, "__strtmp", res);
args_deinit(buffs);
return obj_getStr(self, "__strtmp");
}
Arg* PikaStdLib_SysObj_iter(PikaObj* self, Arg* arg) {
/* a MATE object */
if (TYPE_MATE_OBJECT == arg_getType(arg)) {