cpy3/dict.go

143 lines
4.4 KiB
Go
Raw Permalink Normal View History

2018-12-13 22:09:42 +00:00
/*
Unless explicitly stated otherwise all files in this repository are licensed
under the MIT License.
2018-12-13 22:09:42 +00:00
This product includes software developed at Datadog (https://www.datadoghq.com/).
Copyright 2018 Datadog, Inc.
*/
2018-12-06 20:34:27 +00:00
package python3
/*
#include "Python.h"
#include "macro.h"
*/
import "C"
import (
"unsafe"
)
2023-05-24 08:30:48 +00:00
// Dict : https://docs.python.org/3/c-api/dict.html#c.PyDict_Type
2018-12-20 22:59:29 +00:00
var Dict = togo((*C.PyObject)(unsafe.Pointer(&C.PyDict_Type)))
2018-12-06 20:34:27 +00:00
2023-05-24 08:30:48 +00:00
// PyDict_Check : https://docs.python.org/3/c-api/dict.html#c.PyDict_Check
2018-12-06 20:34:27 +00:00
func PyDict_Check(p *PyObject) bool {
return C._go_PyDict_Check(toc(p)) != 0
}
2023-05-24 08:30:48 +00:00
// PyDict_CheckExact : https://docs.python.org/3/c-api/dict.html#c.PyDict_CheckExact
2018-12-06 20:34:27 +00:00
func PyDict_CheckExact(p *PyObject) bool {
return C._go_PyDict_CheckExact(toc(p)) != 0
}
2023-05-24 08:30:48 +00:00
// PyDict_New : https://docs.python.org/3/c-api/dict.html#c.PyDict_New
2018-12-06 20:34:27 +00:00
func PyDict_New() *PyObject {
return togo(C.PyDict_New())
}
2023-05-24 08:30:48 +00:00
// PyDictProxy_New : https://docs.python.org/3/c-api/dict.html#c.PyDictProxy_New
2018-12-06 20:34:27 +00:00
func PyDictProxy_New(mapping *PyObject) *PyObject {
return togo(C.PyDictProxy_New(toc(mapping)))
}
2023-05-24 08:30:48 +00:00
// PyDict_Clear : https://docs.python.org/3/c-api/dict.html#c.PyDict_Clear
2018-12-06 20:34:27 +00:00
func PyDict_Clear(p *PyObject) {
C.PyDict_Clear(toc(p))
}
2023-05-24 08:30:48 +00:00
// PyDict_Contains : https://docs.python.org/3/c-api/dict.html#c.PyDict_Contains
2018-12-06 20:34:27 +00:00
func PyDict_Contains(p, key *PyObject) int {
return int(C.PyDict_Contains(toc(p), toc(key)))
}
2023-05-24 08:30:48 +00:00
// PyDict_Copy : https://docs.python.org/3/c-api/dict.html#c.PyDict_Copy
2018-12-06 20:34:27 +00:00
func PyDict_Copy(p *PyObject) *PyObject {
return togo(C.PyDict_Copy(toc(p)))
}
2023-05-24 08:30:48 +00:00
// PyDict_SetItem : https://docs.python.org/3/c-api/dict.html#c.PyDict_SetItem
2018-12-06 20:34:27 +00:00
func PyDict_SetItem(p, key, val *PyObject) int {
return int(C.PyDict_SetItem(toc(p), toc(key), toc(val)))
}
2023-05-24 08:30:48 +00:00
// PyDict_SetItemString : https://docs.python.org/3/c-api/dict.html#c.PyDict_SetItemString
2018-12-06 20:34:27 +00:00
func PyDict_SetItemString(p *PyObject, key string, val *PyObject) int {
ckey := C.CString(key)
defer C.free(unsafe.Pointer(ckey))
return int(C.PyDict_SetItemString(toc(p), ckey, toc(val)))
}
2023-05-24 08:30:48 +00:00
// PyDict_DelItem : https://docs.python.org/3/c-api/dict.html#c.PyDict_DelItem
2018-12-06 20:34:27 +00:00
func PyDict_DelItem(p, key *PyObject) int {
return int(C.PyDict_DelItem(toc(p), toc(key)))
}
2023-05-24 08:30:48 +00:00
// PyDict_DelItemString : https://docs.python.org/3/c-api/dict.html#c.PyDict_DelItemString
2018-12-06 20:34:27 +00:00
func PyDict_DelItemString(p *PyObject, key string) int {
ckey := C.CString(key)
defer C.free(unsafe.Pointer(ckey))
return int(C.PyDict_DelItemString(toc(p), ckey))
}
2023-05-24 08:30:48 +00:00
// PyDict_GetItem : https://docs.python.org/3/c-api/dict.html#c.PyDict_GetItem
2018-12-06 20:34:27 +00:00
func PyDict_GetItem(p, key *PyObject) *PyObject {
return togo(C.PyDict_GetItem(toc(p), toc(key)))
}
2023-05-24 08:30:48 +00:00
// PyDict_GetItemWithError : https://docs.python.org/3/c-api/dict.html#c.PyDict_GetItemWithError
2018-12-06 20:34:27 +00:00
func PyDict_GetItemWithError(p, key *PyObject) *PyObject {
return togo(C.PyDict_GetItemWithError(toc(p), toc(key)))
}
2023-05-24 08:30:48 +00:00
// PyDict_GetItemString : https://docs.python.org/3/c-api/dict.html#c.PyDict_GetItemString
2018-12-06 20:34:27 +00:00
func PyDict_GetItemString(p *PyObject, key string) *PyObject {
ckey := C.CString(key)
defer C.free(unsafe.Pointer(ckey))
return togo(C.PyDict_GetItemString(toc(p), ckey))
}
2023-05-24 08:30:48 +00:00
// PyDict_SetDefault : https://docs.python.org/3/c-api/dict.html#c.PyDict_SetDefault
2018-12-06 20:34:27 +00:00
func PyDict_SetDefault(p, key, pyDefault *PyObject) *PyObject {
return togo(C.PyDict_SetDefault(toc(p), toc(key), toc(pyDefault)))
}
2023-05-24 08:30:48 +00:00
// PyDict_Items : https://docs.python.org/3/c-api/dict.html#c.PyDict_Items
2018-12-06 20:34:27 +00:00
func PyDict_Items(p *PyObject) *PyObject {
return togo(C.PyDict_Items(toc(p)))
}
2023-05-24 08:30:48 +00:00
// PyDict_Keys : https://docs.python.org/3/c-api/dict.html#c.PyDict_Keys
2018-12-06 20:34:27 +00:00
func PyDict_Keys(p *PyObject) *PyObject {
return togo(C.PyDict_Keys(toc(p)))
}
2023-05-24 08:30:48 +00:00
// PyDict_Values : https://docs.python.org/3/c-api/dict.html#c.PyDict_Values
2018-12-06 20:34:27 +00:00
func PyDict_Values(p *PyObject) *PyObject {
return togo(C.PyDict_Values(toc(p)))
}
2023-05-24 08:30:48 +00:00
// PyDict_Size : https://docs.python.org/3/c-api/dict.html#c.PyDict_Size
2018-12-06 20:34:27 +00:00
func PyDict_Size(p *PyObject) int {
return int(C.PyDict_Size(toc(p)))
}
2023-05-24 08:30:48 +00:00
// PyDict_Next : https://docs.python.org/3/c-api/dict.html#c.PyDict_Next
2018-12-12 23:46:20 +00:00
func PyDict_Next(p *PyObject, ppos *int, pkey, pvalue **PyObject) bool {
cpos := C.Py_ssize_t(*ppos)
2018-12-12 23:46:20 +00:00
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
}
2018-12-06 20:34:27 +00:00
//PyDict_ClearFreeList : https://docs.python.org/3/c-api/dict.html#c.PyDict_ClearFreeList
2023-05-24 08:30:48 +00:00
//func PyDict_ClearFreeList() int {
// return int(C.PyDict_ClearFreeList())
//}