43 lines
1.2 KiB
C
Raw Normal View History

2021-12-13 23:28:58 +08:00
#include "PikaStdData_Dict.h"
2022-01-06 10:56:14 +08:00
#include "BaseObj.h"
2022-01-06 11:13:43 +08:00
#include "PikaObj.h"
#include "PikaStdLib_SysObj.h"
2021-12-13 23:28:58 +08:00
Arg* PikaStdData_Dict_get(PikaObj* self, char* key) {
2022-01-06 10:56:14 +08:00
PikaObj* pyload = obj_getObj(self, "pyload", 0);
return arg_copy(obj_getArg(pyload, key));
2021-12-13 23:28:58 +08:00
}
2022-01-06 10:56:14 +08:00
void PikaStdData_Dict___init__(PikaObj* self) {
obj_newObj(self, "pyload", "", New_TinyObj);
}
2021-12-13 23:28:58 +08:00
void PikaStdData_Dict_set(PikaObj* self, Arg* arg, char* key) {
2022-01-06 10:56:14 +08:00
PikaObj* pyload = obj_getObj(self, "pyload", 0);
obj_setArg(pyload, key, arg);
2021-12-13 23:28:58 +08:00
}
void PikaStdData_Dict_remove(PikaObj* self, char* key) {
2022-01-06 10:56:14 +08:00
PikaObj* pyload = obj_getObj(self, "pyload", 0);
2022-01-06 11:13:43 +08:00
obj_removeArg(pyload, key);
2021-12-24 22:44:56 +08:00
}
2022-01-06 11:13:43 +08:00
Arg* PikaStdData_Dict___iter__(PikaObj* self) {
2022-01-06 10:56:14 +08:00
obj_setInt(self, "__iter_i", 0);
return arg_setPtr(NULL, "", TYPE_POINTER, self);
2021-12-24 22:44:56 +08:00
}
2022-01-06 11:13:43 +08:00
Arg* PikaStdData_Dict___next__(PikaObj* self) {
int __iter_i = args_getInt(self->list, "__iter_i");
PikaObj* pyload = obj_getObj(self, "pyload", 0);
Arg* res = arg_copy(args_getArg_index(pyload->list, __iter_i));
if (TYPE_POINTER == arg_getType(res)) {
arg_deinit(res);
return arg_setNull(NULL);
}
if (NULL == res) {
return arg_setNull(NULL);
}
args_setInt(self->list, "__iter_i", __iter_i + 1);
return res;
2021-12-13 23:28:58 +08:00
}