From a6de78a63f92ac6be41857f2528baa76012a7a60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Calixte?= Date: Wed, 12 Dec 2018 18:46:20 -0500 Subject: [PATCH] Add PyDict_Next --- dict.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dict.go b/dict.go index c158107..abcb0ba 100644 --- a/dict.go +++ b/dict.go @@ -122,6 +122,21 @@ func PyDict_Size(p *PyObject) int { return int(C.PyDict_Size(toc(p))) } +//PyDict_Next : https://docs.python.org/3/c-api/dict.html#c.PyDict_Next +func PyDict_Next(p *PyObject, ppos *int, pkey, pvalue **PyObject) bool { + cpos := C.long(*ppos) + ckey := toc(*pkey) + cvalue := toc(*pvalue) + + res := C.PyDict_Next(toc(p), &cpos, &ckey, &cvalue) != 0 + + *ppos = int(cpos) + *pkey = togo(ckey) + *pvalue = togo(cvalue) + + return res +} + //PyDict_ClearFreeList : https://docs.python.org/3/c-api/dict.html#c.PyDict_ClearFreeList func PyDict_ClearFreeList() int { return int(C.PyDict_ClearFreeList())