mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-19 19:10:17 +00:00
Update PyDict.c
This commit is contained in:
parent
50db32f36e
commit
e4a900dd88
@ -651,10 +651,18 @@ bool dict_items__next__(int argc, py_Ref argv) {
|
||||
return StopIteration();
|
||||
}
|
||||
|
||||
bool dict_items__len__(int argc, py_Ref argv) {
|
||||
PY_CHECK_ARGC(1);
|
||||
DictIterator* iter = py_touserdata(py_arg(0));
|
||||
py_newint(py_retval(), iter->dict->length);
|
||||
return true;
|
||||
}
|
||||
|
||||
py_Type pk_dict_items__register() {
|
||||
py_Type type = pk_newtype("dict_iterator", tp_object, NULL, NULL, false, true);
|
||||
py_bindmagic(type, __iter__, pk_wrapper__self);
|
||||
py_bindmagic(type, __next__, dict_items__next__);
|
||||
py_bindmagic(type, __len__, dict_items__len__);
|
||||
return type;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user