cpy3/tuple.go

54 lines
1.7 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"
2018-12-20 22:59:29 +00:00
import "unsafe"
2018-12-06 20:34:27 +00:00
//Tuple : https://docs.python.org/3/c-api/tuple.html#c.PyTuple_Type
2018-12-20 22:59:29 +00:00
var Tuple = togo((*C.PyObject)(unsafe.Pointer(&C.PyTuple_Type)))
2018-12-06 20:34:27 +00:00
//PyTuple_Check : https://docs.python.org/3/c-api/tuple.html#c.PyTuple_Check
func PyTuple_Check(p *PyObject) bool {
return C._go_PyTuple_Check(toc(p)) != 0
}
//PyTuple_CheckExact : https://docs.python.org/3/c-api/tuple.html#c.PyTuple_CheckExact
func PyTuple_CheckExact(p *PyObject) bool {
return C._go_PyTuple_CheckExact(toc(p)) != 0
}
//PyTuple_New : https://docs.python.org/3/c-api/tuple.html#c.PyTuple_New
func PyTuple_New(len int) *PyObject {
return togo(C.PyTuple_New(C.Py_ssize_t(len)))
}
//PyTuple_Size : https://docs.python.org/3/c-api/tuple.html#c.PyTuple_Size
func PyTuple_Size(p *PyObject) int {
return int(C.PyTuple_Size(toc(p)))
}
//PyTuple_GetItem : https://docs.python.org/3/c-api/tuple.html#c.PyTuple_GetItem
func PyTuple_GetItem(p *PyObject, pos int) *PyObject {
return togo(C.PyTuple_GetItem(toc(p), C.Py_ssize_t(pos)))
}
//PyTuple_GetSlice : https://docs.python.org/3/c-api/tuple.html#c.PyTuple_GetSlice
func PyTuple_GetSlice(p *PyObject, low, high int) *PyObject {
return togo(C.PyTuple_GetSlice(toc(p), C.Py_ssize_t(low), C.Py_ssize_t(high)))
}
//PyTuple_SetItem : https://docs.python.org/3/c-api/tuple.html#c.PyTuple_SetItem
2019-01-18 19:50:08 +00:00
func PyTuple_SetItem(p *PyObject, pos int, o *PyObject) int {
return int(C.PyTuple_SetItem(toc(p), C.Py_ssize_t(pos), toc(o)))
2018-12-06 20:34:27 +00:00
}