mirror of
https://gitee.com/Lyon1998/pikapython.git
synced 2025-01-15 17:02:53 +08:00
update PikaStdData, support for_in_dict
This commit is contained in:
parent
939ae72bef
commit
233949e9f7
@ -1,24 +1,43 @@
|
||||
#include "PikaStdData_Dict.h"
|
||||
#include "BaseObj.h"
|
||||
#include "PikaObj.h"
|
||||
#include "PikaStdLib_SysObj.h"
|
||||
#include "PikaStdData_Dict.h"
|
||||
|
||||
Arg* PikaStdData_Dict_get(PikaObj* self, char* key) {
|
||||
return arg_copy(obj_getArg(self, key));
|
||||
PikaObj* pyload = obj_getObj(self, "pyload", 0);
|
||||
return arg_copy(obj_getArg(pyload, key));
|
||||
}
|
||||
|
||||
void PikaStdData_Dict___init__(PikaObj* self) {}
|
||||
void PikaStdData_Dict___init__(PikaObj* self) {
|
||||
obj_newObj(self, "pyload", "", New_TinyObj);
|
||||
}
|
||||
|
||||
void PikaStdData_Dict_set(PikaObj* self, Arg* arg, char* key) {
|
||||
obj_setArg(self, key, arg);
|
||||
PikaObj* pyload = obj_getObj(self, "pyload", 0);
|
||||
obj_setArg(pyload, key, arg);
|
||||
}
|
||||
|
||||
void PikaStdData_Dict_remove(PikaObj* self, char* key) {
|
||||
PikaStdLib_SysObj_remove(self, key);
|
||||
PikaObj* pyload = obj_getObj(self, "pyload", 0);
|
||||
obj_removeArg(pyload, key);
|
||||
}
|
||||
|
||||
Arg * PikaStdData_Dict___iter__(PikaObj *self){
|
||||
return NULL;
|
||||
Arg* PikaStdData_Dict___iter__(PikaObj* self) {
|
||||
obj_setInt(self, "__iter_i", 0);
|
||||
return arg_setPtr(NULL, "", TYPE_POINTER, self);
|
||||
}
|
||||
Arg * PikaStdData_Dict___next__(PikaObj *self){
|
||||
return NULL;
|
||||
|
||||
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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user