2022-01-06 11:14:12 +08:00
|
|
|
#include "BaseObj.h"
|
2021-12-13 22:14:59 +08:00
|
|
|
#include "PikaObj.h"
|
|
|
|
#include "PikaStdLib_SysObj.h"
|
|
|
|
|
|
|
|
Arg* PikaStdData_Dict_get(PikaObj* self, char* key) {
|
2022-04-27 22:14:56 +08:00
|
|
|
PikaObj* pyload = obj_getObj(self, "pyload");
|
2022-01-06 11:14:12 +08:00
|
|
|
return arg_copy(obj_getArg(pyload, key));
|
2021-12-13 22:14:59 +08:00
|
|
|
}
|
|
|
|
|
2022-01-06 11:14:12 +08:00
|
|
|
void PikaStdData_Dict___init__(PikaObj* self) {
|
|
|
|
obj_newObj(self, "pyload", "", New_TinyObj);
|
|
|
|
}
|
2021-12-13 22:14:59 +08:00
|
|
|
|
|
|
|
void PikaStdData_Dict_set(PikaObj* self, Arg* arg, char* key) {
|
2022-04-27 22:14:56 +08:00
|
|
|
PikaObj* pyload = obj_getObj(self, "pyload");
|
2022-01-06 11:14:12 +08:00
|
|
|
obj_setArg(pyload, key, arg);
|
2021-12-13 22:14:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PikaStdData_Dict_remove(PikaObj* self, char* key) {
|
2022-04-27 22:14:56 +08:00
|
|
|
PikaObj* pyload = obj_getObj(self, "pyload");
|
2022-01-06 11:14:12 +08:00
|
|
|
obj_removeArg(pyload, key);
|
2021-12-28 01:21:47 +08:00
|
|
|
}
|
|
|
|
|
2022-01-06 11:14:12 +08:00
|
|
|
Arg* PikaStdData_Dict___iter__(PikaObj* self) {
|
|
|
|
obj_setInt(self, "__iter_i", 0);
|
2022-04-28 00:49:40 +08:00
|
|
|
return arg_setRef(NULL, "", self);
|
2021-12-28 01:21:47 +08:00
|
|
|
}
|
2022-01-06 11:14:12 +08:00
|
|
|
|
|
|
|
Arg* PikaStdData_Dict___next__(PikaObj* self) {
|
|
|
|
int __iter_i = args_getInt(self->list, "__iter_i");
|
2022-04-27 22:14:56 +08:00
|
|
|
PikaObj* pyload = obj_getObj(self, "pyload");
|
2022-01-06 11:14:12 +08:00
|
|
|
Arg* res = arg_copy(args_getArg_index(pyload->list, __iter_i));
|
2022-04-25 15:01:58 +08:00
|
|
|
/* skip pointer */
|
|
|
|
if (ARG_TYPE_POINTER == arg_getType(res)) {
|
2022-01-06 11:14:12 +08:00
|
|
|
arg_deinit(res);
|
|
|
|
return arg_setNull(NULL);
|
|
|
|
}
|
2022-04-25 18:58:15 +08:00
|
|
|
/* skip _refcnt */
|
|
|
|
if (hash_time33("_refcnt") == arg_getNameHash(res)) {
|
|
|
|
arg_deinit(res);
|
|
|
|
return arg_setNull(NULL);
|
|
|
|
}
|
2022-01-06 11:14:12 +08:00
|
|
|
if (NULL == res) {
|
|
|
|
return arg_setNull(NULL);
|
|
|
|
}
|
|
|
|
args_setInt(self->list, "__iter_i", __iter_i + 1);
|
|
|
|
return res;
|
2022-01-13 21:57:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void PikaStdData_Dict___set__(PikaObj* self) {
|
|
|
|
PikaStdData_Dict_set(self, obj_getArg(self, "__val"),
|
|
|
|
obj_getStr(self, "__key"));
|
|
|
|
}
|
|
|
|
Arg* PikaStdData_Dict___get__(PikaObj* self) {
|
|
|
|
return PikaStdData_Dict_get(self, obj_getStr(self, "__key"));
|
|
|
|
}
|