2018-12-13 22:09:42 +00:00
|
|
|
/*
|
|
|
|
Unless explicitly stated otherwise all files in this repository are licensed
|
|
|
|
under the $license_for_repo License.
|
|
|
|
This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
|
|
Copyright 2018 Datadog, Inc.
|
|
|
|
*/
|
|
|
|
|
2018-12-06 17:26:11 +00:00
|
|
|
package python3
|
|
|
|
|
|
|
|
/*
|
|
|
|
#include "Python.h"
|
|
|
|
#include "macro.h"
|
|
|
|
*/
|
|
|
|
import "C"
|
|
|
|
import "unsafe"
|
|
|
|
|
|
|
|
//ByteArray : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Type
|
2018-12-20 22:59:29 +00:00
|
|
|
var ByteArray = togo((*C.PyObject)(unsafe.Pointer(&C.PyByteArray_Type)))
|
2018-12-06 17:26:11 +00:00
|
|
|
|
|
|
|
//PyByteArray_Check : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Check
|
|
|
|
func PyByteArray_Check(o *PyObject) bool {
|
|
|
|
return C._go_PyByteArray_Check(toc(o)) != 0
|
|
|
|
}
|
|
|
|
|
|
|
|
//PyByteArray_CheckExact : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_CheckExact
|
|
|
|
func PyByteArray_CheckExact(o *PyObject) bool {
|
|
|
|
return C._go_PyByteArray_CheckExact(toc(o)) != 0
|
|
|
|
}
|
|
|
|
|
|
|
|
//PyByteArray_FromObject : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_FromObject
|
|
|
|
func PyByteArray_FromObject(o *PyObject) *PyObject {
|
|
|
|
return togo(C.PyByteArray_FromObject(toc(o)))
|
|
|
|
}
|
|
|
|
|
|
|
|
//PyByteArray_FromStringAndSize : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_FromStringAndSize
|
|
|
|
func PyByteArray_FromStringAndSize(str string) *PyObject {
|
|
|
|
cstr := C.CString(str)
|
|
|
|
defer C.free(unsafe.Pointer(cstr))
|
|
|
|
|
|
|
|
return togo(C.PyByteArray_FromStringAndSize(cstr, C.Py_ssize_t(len(str))))
|
|
|
|
}
|
|
|
|
|
|
|
|
//PyByteArray_Concat : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Concat
|
|
|
|
func PyByteArray_Concat(a, b *PyObject) *PyObject {
|
|
|
|
return togo(C.PyByteArray_Concat(toc(a), toc(b)))
|
|
|
|
}
|
|
|
|
|
|
|
|
//PyByteArray_Size : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Size
|
|
|
|
func PyByteArray_Size(o *PyObject) int {
|
|
|
|
return int(C.PyByteArray_Size(toc(o)))
|
|
|
|
}
|
|
|
|
|
|
|
|
//PyByteArray_AsString : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_AsString
|
|
|
|
func PyByteArray_AsString(o *PyObject) string {
|
2019-07-22 19:18:28 +00:00
|
|
|
return C.GoStringN(C.PyByteArray_AsString(toc(o)), C.int(C.PyByteArray_Size(toc(o))))
|
2018-12-06 17:26:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//PyByteArray_Resize : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Resize
|
|
|
|
func PyByteArray_Resize(bytearray *PyObject, len int) {
|
|
|
|
C.PyByteArray_Resize(toc(bytearray), C.Py_ssize_t(len))
|
|
|
|
}
|