parent
8c7eedeae7
commit
7d65f97b9f
|
@ -8,6 +8,7 @@ Copyright 2018 Datadog, Inc.
|
|||
package python3
|
||||
|
||||
/*
|
||||
#cgo pkg-config: python-3.9-embed
|
||||
#include "Python.h"
|
||||
#include "macro.h"
|
||||
*/
|
||||
|
@ -17,21 +18,21 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
//python boolean constants
|
||||
// python boolean constants
|
||||
var (
|
||||
Py_False = togo(C.Py_False)
|
||||
Py_True = togo(C.Py_True)
|
||||
)
|
||||
|
||||
//Bool : https://docs.python.org/3/c-api/bool.html#c.PyBool_Type
|
||||
// Bool : https://docs.python.org/3/c-api/bool.html#c.PyBool_Type
|
||||
var Bool = togo((*C.PyObject)(unsafe.Pointer(&C.PyBool_Type)))
|
||||
|
||||
//PyBool_Check : https://docs.python.org/3/c-api/bool.html#c.PyBool_Check
|
||||
// PyBool_Check : https://docs.python.org/3/c-api/bool.html#c.PyBool_Check
|
||||
func PyBool_Check(o *PyObject) bool {
|
||||
return C._go_PyBool_Check(toc(o)) != 0
|
||||
}
|
||||
|
||||
//PyBool_FromLong : https://docs.python.org/3/c-api/bool.html#c.PyBool_FromLong
|
||||
// PyBool_FromLong : https://docs.python.org/3/c-api/bool.html#c.PyBool_FromLong
|
||||
func PyBool_FromLong(v int) *PyObject {
|
||||
return togo(C.PyBool_FromLong(C.long(v)))
|
||||
}
|
||||
|
|
|
@ -8,31 +8,32 @@ Copyright 2018 Datadog, Inc.
|
|||
package python3
|
||||
|
||||
/*
|
||||
#cgo pkg-config: python-3.9-embed
|
||||
#include "Python.h"
|
||||
#include "macro.h"
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
//ByteArray : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Type
|
||||
// ByteArray : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Type
|
||||
var ByteArray = togo((*C.PyObject)(unsafe.Pointer(&C.PyByteArray_Type)))
|
||||
|
||||
//PyByteArray_Check : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Check
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
// 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))
|
||||
|
@ -40,22 +41,22 @@ func PyByteArray_FromStringAndSize(str string) *PyObject {
|
|||
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
|
||||
// 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
|
||||
// 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
|
||||
// PyByteArray_AsString : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_AsString
|
||||
func PyByteArray_AsString(o *PyObject) string {
|
||||
return C.GoStringN(C.PyByteArray_AsString(toc(o)), C.int(C.PyByteArray_Size(toc(o))))
|
||||
}
|
||||
|
||||
//PyByteArray_Resize : https://docs.python.org/3/c-api/bytearray.html#c.PyByteArray_Resize
|
||||
// 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))
|
||||
}
|
||||
|
|
19
bytes.go
19
bytes.go
|
@ -8,26 +8,27 @@ Copyright 2018 Datadog, Inc.
|
|||
package python3
|
||||
|
||||
/*
|
||||
#cgo pkg-config: python-3.9-embed
|
||||
#include "Python.h"
|
||||
#include "macro.h"
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
//Bytes : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Type
|
||||
// Bytes : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Type
|
||||
var Bytes = togo((*C.PyObject)(unsafe.Pointer(&C.PyBytes_Type)))
|
||||
|
||||
//PyBytes_Check : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Check
|
||||
// PyBytes_Check : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Check
|
||||
func PyBytes_Check(o *PyObject) bool {
|
||||
return C._go_PyBytes_Check(toc(o)) != 0
|
||||
}
|
||||
|
||||
//PyBytes_CheckExact : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_CheckExact
|
||||
// PyBytes_CheckExact : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_CheckExact
|
||||
func PyBytes_CheckExact(o *PyObject) bool {
|
||||
return C._go_PyBytes_CheckExact(toc(o)) != 0
|
||||
}
|
||||
|
||||
//PyBytes_FromString : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_FromString
|
||||
// PyBytes_FromString : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_FromString
|
||||
func PyBytes_FromString(str string) *PyObject {
|
||||
cstr := C.CString(str)
|
||||
defer C.free(unsafe.Pointer(cstr))
|
||||
|
@ -35,29 +36,29 @@ func PyBytes_FromString(str string) *PyObject {
|
|||
return togo(C.PyBytes_FromString(cstr))
|
||||
}
|
||||
|
||||
//PyBytes_FromObject : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_FromObject
|
||||
// PyBytes_FromObject : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_FromObject
|
||||
func PyBytes_FromObject(o *PyObject) *PyObject {
|
||||
return togo(C.PyBytes_FromObject(toc(o)))
|
||||
}
|
||||
|
||||
//PyBytes_Size : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Size
|
||||
// PyBytes_Size : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Size
|
||||
func PyBytes_Size(o *PyObject) int {
|
||||
return int(C.PyBytes_Size(toc(o)))
|
||||
}
|
||||
|
||||
//PyBytes_AsString : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_AsString
|
||||
// PyBytes_AsString : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_AsString
|
||||
func PyBytes_AsString(o *PyObject) string {
|
||||
return C.GoStringN(C.PyBytes_AsString(toc(o)), C.int(C.PyBytes_Size(toc(o))))
|
||||
}
|
||||
|
||||
//PyBytes_Concat : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Concat
|
||||
// PyBytes_Concat : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_Concat
|
||||
func PyBytes_Concat(bytes, newpart *PyObject) *PyObject {
|
||||
cbytes := toc(bytes)
|
||||
C.PyBytes_Concat(&cbytes, toc(newpart))
|
||||
return togo(cbytes)
|
||||
}
|
||||
|
||||
//PyBytes_ConcatAndDel : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_ConcatAndDel
|
||||
// PyBytes_ConcatAndDel : https://docs.python.org/3/c-api/bytes.html#c.PyBytes_ConcatAndDel
|
||||
func PyBytes_ConcatAndDel(bytes, newpart *PyObject) *PyObject {
|
||||
cbytes := toc(bytes)
|
||||
C.PyBytes_ConcatAndDel(&cbytes, toc(newpart))
|
||||
|
|
12
complex.go
12
complex.go
|
@ -14,30 +14,30 @@ package python3
|
|||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
//Complex : https://docs.python.org/3/c-api/complex.html#c.PyComplex_Type
|
||||
// Complex : https://docs.python.org/3/c-api/complex.html#c.PyComplex_Type
|
||||
var Complex = togo((*C.PyObject)(unsafe.Pointer(&C.PyComplex_Type)))
|
||||
|
||||
//PyComplex_Check : https://docs.python.org/3/c-api/complex.html#c.PyComplex_Check
|
||||
// PyComplex_Check : https://docs.python.org/3/c-api/complex.html#c.PyComplex_Check
|
||||
func PyComplex_Check(p *PyObject) bool {
|
||||
return C._go_PyComplex_Check(toc(p)) != 0
|
||||
}
|
||||
|
||||
//PyComplex_CheckExact : https://docs.python.org/3/c-api/complex.html#c.PyComplex_CheckExact
|
||||
// PyComplex_CheckExact : https://docs.python.org/3/c-api/complex.html#c.PyComplex_CheckExact
|
||||
func PyComplex_CheckExact(p *PyObject) bool {
|
||||
return C._go_PyComplex_CheckExact(toc(p)) != 0
|
||||
}
|
||||
|
||||
//PyComplex_FromDoubles : https://docs.python.org/3/c-api/complex.html#c.PyComplex_FromDoubles
|
||||
// PyComplex_FromDoubles : https://docs.python.org/3/c-api/complex.html#c.PyComplex_FromDoubles
|
||||
func PyComplex_FromDoubles(real, imag float64) *PyObject {
|
||||
return togo(C.PyComplex_FromDoubles(C.double(real), C.double(imag)))
|
||||
}
|
||||
|
||||
//PyComplex_RealAsDouble : https://docs.python.org/3/c-api/complex.html#c.PyComplex_RealAsDouble
|
||||
// PyComplex_RealAsDouble : https://docs.python.org/3/c-api/complex.html#c.PyComplex_RealAsDouble
|
||||
func PyComplex_RealAsDouble(op *PyObject) float64 {
|
||||
return float64(C.PyComplex_RealAsDouble(toc(op)))
|
||||
}
|
||||
|
||||
//PyComplex_ImagAsDouble : https://docs.python.org/3/c-api/complex.html#c.PyComplex_ImagAsDouble
|
||||
// PyComplex_ImagAsDouble : https://docs.python.org/3/c-api/complex.html#c.PyComplex_ImagAsDouble
|
||||
func PyComplex_ImagAsDouble(op *PyObject) float64 {
|
||||
return float64(C.PyComplex_ImagAsDouble(toc(op)))
|
||||
}
|
||||
|
|
48
dict.go
48
dict.go
|
@ -16,79 +16,79 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
//Dict : https://docs.python.org/3/c-api/dict.html#c.PyDict_Type
|
||||
// Dict : https://docs.python.org/3/c-api/dict.html#c.PyDict_Type
|
||||
var Dict = togo((*C.PyObject)(unsafe.Pointer(&C.PyDict_Type)))
|
||||
|
||||
//PyDict_Check : https://docs.python.org/3/c-api/dict.html#c.PyDict_Check
|
||||
// PyDict_Check : https://docs.python.org/3/c-api/dict.html#c.PyDict_Check
|
||||
func PyDict_Check(p *PyObject) bool {
|
||||
return C._go_PyDict_Check(toc(p)) != 0
|
||||
}
|
||||
|
||||
//PyDict_CheckExact : https://docs.python.org/3/c-api/dict.html#c.PyDict_CheckExact
|
||||
// PyDict_CheckExact : https://docs.python.org/3/c-api/dict.html#c.PyDict_CheckExact
|
||||
func PyDict_CheckExact(p *PyObject) bool {
|
||||
return C._go_PyDict_CheckExact(toc(p)) != 0
|
||||
}
|
||||
|
||||
//PyDict_New : https://docs.python.org/3/c-api/dict.html#c.PyDict_New
|
||||
// PyDict_New : https://docs.python.org/3/c-api/dict.html#c.PyDict_New
|
||||
func PyDict_New() *PyObject {
|
||||
return togo(C.PyDict_New())
|
||||
}
|
||||
|
||||
//PyDictProxy_New : https://docs.python.org/3/c-api/dict.html#c.PyDictProxy_New
|
||||
// PyDictProxy_New : https://docs.python.org/3/c-api/dict.html#c.PyDictProxy_New
|
||||
func PyDictProxy_New(mapping *PyObject) *PyObject {
|
||||
return togo(C.PyDictProxy_New(toc(mapping)))
|
||||
}
|
||||
|
||||
//PyDict_Clear : https://docs.python.org/3/c-api/dict.html#c.PyDict_Clear
|
||||
// PyDict_Clear : https://docs.python.org/3/c-api/dict.html#c.PyDict_Clear
|
||||
func PyDict_Clear(p *PyObject) {
|
||||
C.PyDict_Clear(toc(p))
|
||||
}
|
||||
|
||||
//PyDict_Contains : https://docs.python.org/3/c-api/dict.html#c.PyDict_Contains
|
||||
// PyDict_Contains : https://docs.python.org/3/c-api/dict.html#c.PyDict_Contains
|
||||
func PyDict_Contains(p, key *PyObject) int {
|
||||
return int(C.PyDict_Contains(toc(p), toc(key)))
|
||||
}
|
||||
|
||||
//PyDict_Copy : https://docs.python.org/3/c-api/dict.html#c.PyDict_Copy
|
||||
// PyDict_Copy : https://docs.python.org/3/c-api/dict.html#c.PyDict_Copy
|
||||
func PyDict_Copy(p *PyObject) *PyObject {
|
||||
return togo(C.PyDict_Copy(toc(p)))
|
||||
}
|
||||
|
||||
//PyDict_SetItem : https://docs.python.org/3/c-api/dict.html#c.PyDict_SetItem
|
||||
// PyDict_SetItem : https://docs.python.org/3/c-api/dict.html#c.PyDict_SetItem
|
||||
func PyDict_SetItem(p, key, val *PyObject) int {
|
||||
return int(C.PyDict_SetItem(toc(p), toc(key), toc(val)))
|
||||
}
|
||||
|
||||
//PyDict_SetItemString : https://docs.python.org/3/c-api/dict.html#c.PyDict_SetItemString
|
||||
// PyDict_SetItemString : https://docs.python.org/3/c-api/dict.html#c.PyDict_SetItemString
|
||||
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)))
|
||||
}
|
||||
|
||||
//PyDict_DelItem : https://docs.python.org/3/c-api/dict.html#c.PyDict_DelItem
|
||||
// PyDict_DelItem : https://docs.python.org/3/c-api/dict.html#c.PyDict_DelItem
|
||||
func PyDict_DelItem(p, key *PyObject) int {
|
||||
return int(C.PyDict_DelItem(toc(p), toc(key)))
|
||||
}
|
||||
|
||||
//PyDict_DelItemString : https://docs.python.org/3/c-api/dict.html#c.PyDict_DelItemString
|
||||
// PyDict_DelItemString : https://docs.python.org/3/c-api/dict.html#c.PyDict_DelItemString
|
||||
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))
|
||||
}
|
||||
|
||||
//PyDict_GetItem : https://docs.python.org/3/c-api/dict.html#c.PyDict_GetItem
|
||||
// PyDict_GetItem : https://docs.python.org/3/c-api/dict.html#c.PyDict_GetItem
|
||||
func PyDict_GetItem(p, key *PyObject) *PyObject {
|
||||
return togo(C.PyDict_GetItem(toc(p), toc(key)))
|
||||
}
|
||||
|
||||
//PyDict_GetItemWithError : https://docs.python.org/3/c-api/dict.html#c.PyDict_GetItemWithError
|
||||
// PyDict_GetItemWithError : https://docs.python.org/3/c-api/dict.html#c.PyDict_GetItemWithError
|
||||
func PyDict_GetItemWithError(p, key *PyObject) *PyObject {
|
||||
return togo(C.PyDict_GetItemWithError(toc(p), toc(key)))
|
||||
}
|
||||
|
||||
//PyDict_GetItemString : https://docs.python.org/3/c-api/dict.html#c.PyDict_GetItemString
|
||||
// PyDict_GetItemString : https://docs.python.org/3/c-api/dict.html#c.PyDict_GetItemString
|
||||
func PyDict_GetItemString(p *PyObject, key string) *PyObject {
|
||||
ckey := C.CString(key)
|
||||
defer C.free(unsafe.Pointer(ckey))
|
||||
|
@ -96,32 +96,32 @@ func PyDict_GetItemString(p *PyObject, key string) *PyObject {
|
|||
return togo(C.PyDict_GetItemString(toc(p), ckey))
|
||||
}
|
||||
|
||||
//PyDict_SetDefault : https://docs.python.org/3/c-api/dict.html#c.PyDict_SetDefault
|
||||
// PyDict_SetDefault : https://docs.python.org/3/c-api/dict.html#c.PyDict_SetDefault
|
||||
func PyDict_SetDefault(p, key, pyDefault *PyObject) *PyObject {
|
||||
return togo(C.PyDict_SetDefault(toc(p), toc(key), toc(pyDefault)))
|
||||
}
|
||||
|
||||
//PyDict_Items : https://docs.python.org/3/c-api/dict.html#c.PyDict_Items
|
||||
// PyDict_Items : https://docs.python.org/3/c-api/dict.html#c.PyDict_Items
|
||||
func PyDict_Items(p *PyObject) *PyObject {
|
||||
return togo(C.PyDict_Items(toc(p)))
|
||||
}
|
||||
|
||||
//PyDict_Keys : https://docs.python.org/3/c-api/dict.html#c.PyDict_Keys
|
||||
// PyDict_Keys : https://docs.python.org/3/c-api/dict.html#c.PyDict_Keys
|
||||
func PyDict_Keys(p *PyObject) *PyObject {
|
||||
return togo(C.PyDict_Keys(toc(p)))
|
||||
}
|
||||
|
||||
//PyDict_Values : https://docs.python.org/3/c-api/dict.html#c.PyDict_Values
|
||||
// PyDict_Values : https://docs.python.org/3/c-api/dict.html#c.PyDict_Values
|
||||
func PyDict_Values(p *PyObject) *PyObject {
|
||||
return togo(C.PyDict_Values(toc(p)))
|
||||
}
|
||||
|
||||
//PyDict_Size : https://docs.python.org/3/c-api/dict.html#c.PyDict_Size
|
||||
// PyDict_Size : https://docs.python.org/3/c-api/dict.html#c.PyDict_Size
|
||||
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
|
||||
// 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.Py_ssize_t(*ppos)
|
||||
ckey := toc(*pkey)
|
||||
|
@ -137,6 +137,6 @@ func PyDict_Next(p *PyObject, ppos *int, pkey, pvalue **PyObject) bool {
|
|||
}
|
||||
|
||||
//PyDict_ClearFreeList : https://docs.python.org/3/c-api/dict.html#c.PyDict_ClearFreeList
|
||||
func PyDict_ClearFreeList() int {
|
||||
return int(C.PyDict_ClearFreeList())
|
||||
}
|
||||
//func PyDict_ClearFreeList() int {
|
||||
// return int(C.PyDict_ClearFreeList())
|
||||
//}
|
||||
|
|
24
float.go
24
float.go
|
@ -14,50 +14,50 @@ package python3
|
|||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
//Float : https://docs.python.org/3/c-api/float.html#c.PyFloat_Type
|
||||
// Float : https://docs.python.org/3/c-api/float.html#c.PyFloat_Type
|
||||
var Float = togo((*C.PyObject)(unsafe.Pointer(&C.PyFloat_Type)))
|
||||
|
||||
//PyFloat_Check : https://docs.python.org/3/c-api/float.html#c.PyFloat_Check
|
||||
// PyFloat_Check : https://docs.python.org/3/c-api/float.html#c.PyFloat_Check
|
||||
func PyFloat_Check(p *PyObject) bool {
|
||||
return C._go_PyFloat_Check(toc(p)) != 0
|
||||
}
|
||||
|
||||
//PyFloat_CheckExact : https://docs.python.org/3/c-api/float.html#c.PyFloat_CheckExact
|
||||
// PyFloat_CheckExact : https://docs.python.org/3/c-api/float.html#c.PyFloat_CheckExact
|
||||
func PyFloat_CheckExact(p *PyObject) bool {
|
||||
return C._go_PyFloat_CheckExact(toc(p)) != 0
|
||||
}
|
||||
|
||||
//PyFloat_FromDouble : https://docs.python.org/3/c-api/float.html#c.PyFloat_FromDouble
|
||||
// PyFloat_FromDouble : https://docs.python.org/3/c-api/float.html#c.PyFloat_FromDouble
|
||||
func PyFloat_FromDouble(v float64) *PyObject {
|
||||
return togo(C.PyFloat_FromDouble(C.double(v)))
|
||||
}
|
||||
|
||||
//PyFloat_FromString : https://docs.python.org/3/c-api/float.html#c.PyFloat_FromString
|
||||
// PyFloat_FromString : https://docs.python.org/3/c-api/float.html#c.PyFloat_FromString
|
||||
func PyFloat_FromString(str *PyObject) *PyObject {
|
||||
return togo(C.PyFloat_FromString(toc(str)))
|
||||
}
|
||||
|
||||
//PyFloat_AsDouble : https://docs.python.org/3/c-api/float.html#c.PyFloat_AsDouble
|
||||
// PyFloat_AsDouble : https://docs.python.org/3/c-api/float.html#c.PyFloat_AsDouble
|
||||
func PyFloat_AsDouble(obj *PyObject) float64 {
|
||||
return float64(C.PyFloat_AsDouble(toc(obj)))
|
||||
}
|
||||
|
||||
//PyFloat_GetInfo : https://docs.python.org/3/c-api/float.html#c.PyFloat_GetInfo
|
||||
// PyFloat_GetInfo : https://docs.python.org/3/c-api/float.html#c.PyFloat_GetInfo
|
||||
func PyFloat_GetInfo() *PyObject {
|
||||
return togo(C.PyFloat_GetInfo())
|
||||
}
|
||||
|
||||
//PyFloat_GetMax : https://docs.python.org/3/c-api/float.html#c.PyFloat_GetMax
|
||||
// PyFloat_GetMax : https://docs.python.org/3/c-api/float.html#c.PyFloat_GetMax
|
||||
func PyFloat_GetMax() float64 {
|
||||
return float64(C.PyFloat_GetMax())
|
||||
}
|
||||
|
||||
//PyFloat_GetMin : https://docs.python.org/3/c-api/float.html#c.PyFloat_GetMin
|
||||
// PyFloat_GetMin : https://docs.python.org/3/c-api/float.html#c.PyFloat_GetMin
|
||||
func PyFloat_GetMin() float64 {
|
||||
return float64(C.PyFloat_GetMin())
|
||||
}
|
||||
|
||||
//PyFloat_ClearFreeList : https://docs.python.org/3/c-api/float.html#c.PyFloat_ClearFreeList
|
||||
func PyFloat_ClearFreeList() int {
|
||||
return int(C.PyFloat_ClearFreeList())
|
||||
}
|
||||
//func PyFloat_ClearFreeList() int {
|
||||
// return int(C.PyFloat_ClearFreeList())
|
||||
//}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
module git.stein-ivar.net/steino/cpy3
|
||||
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/go-python/cpy3 v0.2.0
|
||||
github.com/stretchr/testify v1.2.2
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
)
|
|
@ -0,0 +1,8 @@
|
|||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/go-python/cpy3 v0.2.0 h1:IQ8v6KOTGSvejROZ8BPCfVW4rSMOKfpVwDi6sKYuu1w=
|
||||
github.com/go-python/cpy3 v0.2.0/go.mod h1:W7F8SGWQv11501PYSj9d+NSv8U0/vWYa+FcMxBu4eqo=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
30
list.go
30
list.go
|
@ -14,75 +14,77 @@ package python3
|
|||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
//List : https://docs.python.org/3/c-api/list.html#c.PyList_Type
|
||||
// List : https://docs.python.org/3/c-api/list.html#c.PyList_Type
|
||||
var List = togo((*C.PyObject)(unsafe.Pointer(&C.PyList_Type)))
|
||||
|
||||
//PyList_Check : https://docs.python.org/3/c-api/list.html#c.PyList_Check
|
||||
// PyList_Check : https://docs.python.org/3/c-api/list.html#c.PyList_Check
|
||||
func PyList_Check(p *PyObject) bool {
|
||||
return C._go_PyList_Check(toc(p)) != 0
|
||||
}
|
||||
|
||||
//PyList_CheckExact : https://docs.python.org/3/c-api/list.html#c.PyList_CheckExact
|
||||
// PyList_CheckExact : https://docs.python.org/3/c-api/list.html#c.PyList_CheckExact
|
||||
func PyList_CheckExact(p *PyObject) bool {
|
||||
return C._go_PyList_CheckExact(toc(p)) != 0
|
||||
}
|
||||
|
||||
//PyList_New : https://docs.python.org/3/c-api/list.html#c.PyList_New
|
||||
// PyList_New : https://docs.python.org/3/c-api/list.html#c.PyList_New
|
||||
func PyList_New(len int) *PyObject {
|
||||
return togo(C.PyList_New(C.Py_ssize_t(len)))
|
||||
}
|
||||
|
||||
//PyList_Size : https://docs.python.org/3/c-api/list.html#c.PyList_Size
|
||||
// PyList_Size : https://docs.python.org/3/c-api/list.html#c.PyList_Size
|
||||
func PyList_Size(p *PyObject) int {
|
||||
return int(C.PyList_Size(toc(p)))
|
||||
}
|
||||
|
||||
//PyList_GetItem : https://docs.python.org/3/c-api/list.html#c.PyList_GetItem
|
||||
// PyList_GetItem : https://docs.python.org/3/c-api/list.html#c.PyList_GetItem
|
||||
func PyList_GetItem(p *PyObject, pos int) *PyObject {
|
||||
return togo(C.PyList_GetItem(toc(p), C.Py_ssize_t(pos)))
|
||||
}
|
||||
|
||||
//PyList_SetItem : https://docs.python.org/3/c-api/list.html#c.PyList_SetItem
|
||||
// PyList_SetItem : https://docs.python.org/3/c-api/list.html#c.PyList_SetItem
|
||||
func PyList_SetItem(p *PyObject, pos int, o *PyObject) int {
|
||||
return int(C.PyList_SetItem(toc(p), C.Py_ssize_t(pos), toc(o)))
|
||||
}
|
||||
|
||||
//PyList_Insert : https://docs.python.org/3/c-api/list.html#c.PyList_Insert
|
||||
// PyList_Insert : https://docs.python.org/3/c-api/list.html#c.PyList_Insert
|
||||
func PyList_Insert(p *PyObject, index int, item *PyObject) int {
|
||||
return int(C.PyList_Insert(toc(p), C.Py_ssize_t(index), toc(item)))
|
||||
}
|
||||
|
||||
//PyList_Append : https://docs.python.org/3/c-api/list.html#c.PyList_Append
|
||||
// PyList_Append : https://docs.python.org/3/c-api/list.html#c.PyList_Append
|
||||
func PyList_Append(p, item *PyObject) int {
|
||||
return int(C.PyList_Append(toc(p), toc(item)))
|
||||
}
|
||||
|
||||
//PyList_GetSlice : https://docs.python.org/3/c-api/list.html#c.PyList_GetSlice
|
||||
// PyList_GetSlice : https://docs.python.org/3/c-api/list.html#c.PyList_GetSlice
|
||||
func PyList_GetSlice(p *PyObject, low, high int) *PyObject {
|
||||
return togo(C.PyList_GetSlice(toc(p), C.Py_ssize_t(low), C.Py_ssize_t(high)))
|
||||
}
|
||||
|
||||
//PyList_SetSlice : https://docs.python.org/3/c-api/list.html#c.PyList_SetSlice
|
||||
// PyList_SetSlice : https://docs.python.org/3/c-api/list.html#c.PyList_SetSlice
|
||||
func PyList_SetSlice(p *PyObject, low, high int, itemlist *PyObject) int {
|
||||
return int(C.PyList_SetSlice(toc(p), C.Py_ssize_t(low), C.Py_ssize_t(high), toc(itemlist)))
|
||||
}
|
||||
|
||||
//PyList_Sort : https://docs.python.org/3/c-api/list.html#c.PyList_Sort
|
||||
// PyList_Sort : https://docs.python.org/3/c-api/list.html#c.PyList_Sort
|
||||
func PyList_Sort(list *PyObject) int {
|
||||
return int(C.PyList_Sort(toc(list)))
|
||||
}
|
||||
|
||||
//PyList_Reverse : https://docs.python.org/3/c-api/list.html#c.PyList_Reverse
|
||||
// PyList_Reverse : https://docs.python.org/3/c-api/list.html#c.PyList_Reverse
|
||||
func PyList_Reverse(list *PyObject) int {
|
||||
return int(C.PyList_Reverse(toc(list)))
|
||||
}
|
||||
|
||||
//PyList_AsTuple : https://docs.python.org/3/c-api/list.html#c.PyList_AsTuple
|
||||
// PyList_AsTuple : https://docs.python.org/3/c-api/list.html#c.PyList_AsTuple
|
||||
func PyList_AsTuple(list *PyObject) *PyObject {
|
||||
return togo(C.PyList_AsTuple(toc(list)))
|
||||
}
|
||||
|
||||
//PyList_ClearFreeList : https://docs.python.org/3/c-api/list.html#c.PyList_ClearFreeList
|
||||
/*
|
||||
func PyList_ClearFreeList() int {
|
||||
return int(C.PyList_ClearFreeList())
|
||||
}
|
||||
*/
|
||||
|
|
15
sys.go
15
sys.go
|
@ -8,6 +8,7 @@ Copyright 2018 Datadog, Inc.
|
|||
package python3
|
||||
|
||||
/*
|
||||
#cgo pkg-config: python-3.9-embed
|
||||
#include "Python.h"
|
||||
*/
|
||||
import "C"
|
||||
|
@ -16,7 +17,7 @@ import (
|
|||
"unsafe"
|
||||
)
|
||||
|
||||
//PySys_GetObject : https://docs.python.org/3/c-api/sys.html#c.PySys_GetObject
|
||||
// PySys_GetObject : https://docs.python.org/3/c-api/sys.html#c.PySys_GetObject
|
||||
func PySys_GetObject(name string) *PyObject {
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
|
@ -24,7 +25,7 @@ func PySys_GetObject(name string) *PyObject {
|
|||
return togo(C.PySys_GetObject(cname))
|
||||
}
|
||||
|
||||
//PySys_SetObject : https://docs.python.org/3/c-api/sys.html#c.PySys_SetObject
|
||||
// PySys_SetObject : https://docs.python.org/3/c-api/sys.html#c.PySys_SetObject
|
||||
func PySys_SetObject(name string, v *PyObject) int {
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
|
@ -32,12 +33,12 @@ func PySys_SetObject(name string, v *PyObject) int {
|
|||
return int(C.PySys_SetObject(cname, toc(v)))
|
||||
}
|
||||
|
||||
//PySys_ResetWarnOptions : https://docs.python.org/3/c-api/sys.html#c.PySys_ResetWarnOptions
|
||||
// PySys_ResetWarnOptions : https://docs.python.org/3/c-api/sys.html#c.PySys_ResetWarnOptions
|
||||
func PySys_ResetWarnOptions() {
|
||||
C.PySys_ResetWarnOptions()
|
||||
}
|
||||
|
||||
//PySys_AddWarnOption : https://docs.python.org/3/c-api/sys.html#c.PySys_AddWarnOption
|
||||
// PySys_AddWarnOption : https://docs.python.org/3/c-api/sys.html#c.PySys_AddWarnOption
|
||||
func PySys_AddWarnOption(s string) error {
|
||||
cs := C.CString(s)
|
||||
defer C.free(unsafe.Pointer(cs))
|
||||
|
@ -53,7 +54,7 @@ func PySys_AddWarnOption(s string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
//PySys_SetPath : https://docs.python.org/3/c-api/sys.html#c.PySys_SetPath
|
||||
// PySys_SetPath : https://docs.python.org/3/c-api/sys.html#c.PySys_SetPath
|
||||
func PySys_SetPath(path string) error {
|
||||
cpath := C.CString(path)
|
||||
defer C.free(unsafe.Pointer(cpath))
|
||||
|
@ -69,7 +70,7 @@ func PySys_SetPath(path string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
//PySys_AddXOption : https://docs.python.org/3/c-api/sys.html#c.PySys_AddXOption
|
||||
// PySys_AddXOption : https://docs.python.org/3/c-api/sys.html#c.PySys_AddXOption
|
||||
func PySys_AddXOption(s string) error {
|
||||
cs := C.CString(s)
|
||||
defer C.free(unsafe.Pointer(cs))
|
||||
|
@ -85,7 +86,7 @@ func PySys_AddXOption(s string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
//PySys_GetXOptions : https://docs.python.org/3/c-api/sys.html#c.PySys_GetXOptions
|
||||
// PySys_GetXOptions : https://docs.python.org/3/c-api/sys.html#c.PySys_GetXOptions
|
||||
func PySys_GetXOptions() *PyObject {
|
||||
return togo(C.PySys_GetXOptions())
|
||||
}
|
||||
|
|
28
thread.go
28
thread.go
|
@ -12,63 +12,67 @@ package python3
|
|||
*/
|
||||
import "C"
|
||||
|
||||
//PyThreadState : https://docs.python.org/3/c-api/init.html#c.PyThreadState
|
||||
// PyThreadState : https://docs.python.org/3/c-api/init.html#c.PyThreadState
|
||||
type PyThreadState C.PyThreadState
|
||||
|
||||
//PyGILState is an opaque “handle” to the thread state when PyGILState_Ensure() was called, and must be passed to PyGILState_Release() to ensure Python is left in the same state
|
||||
// PyGILState is an opaque “handle” to the thread state when PyGILState_Ensure() was called, and must be passed to PyGILState_Release() to ensure Python is left in the same state
|
||||
type PyGILState C.PyGILState_STATE
|
||||
|
||||
//PyEval_InitThreads : https://docs.python.org/3/c-api/init.html#c.PyEval_InitThreads
|
||||
/*
|
||||
func PyEval_InitThreads() {
|
||||
C.PyEval_InitThreads()
|
||||
}
|
||||
*/
|
||||
|
||||
//PyEval_ThreadsInitialized : https://docs.python.org/3/c-api/init.html#c.PyEval_ThreadsInitialized
|
||||
// PyEval_ThreadsInitialized : https://docs.python.org/3/c-api/init.html#c.PyEval_ThreadsInitialized
|
||||
func PyEval_ThreadsInitialized() bool {
|
||||
return C.PyEval_ThreadsInitialized() != 0
|
||||
}
|
||||
|
||||
//PyEval_SaveThread : https://docs.python.org/3/c-api/init.html#c.PyEval_SaveThread
|
||||
// PyEval_SaveThread : https://docs.python.org/3/c-api/init.html#c.PyEval_SaveThread
|
||||
func PyEval_SaveThread() *PyThreadState {
|
||||
return (*PyThreadState)(C.PyEval_SaveThread())
|
||||
}
|
||||
|
||||
//PyEval_RestoreThread : https://docs.python.org/3/c-api/init.html#c.PyEval_RestoreThread
|
||||
// PyEval_RestoreThread : https://docs.python.org/3/c-api/init.html#c.PyEval_RestoreThread
|
||||
func PyEval_RestoreThread(tstate *PyThreadState) {
|
||||
C.PyEval_RestoreThread((*C.PyThreadState)(tstate))
|
||||
}
|
||||
|
||||
//PyThreadState_Get : https://docs.python.org/3/c-api/init.html#c.PyThreadState_Get
|
||||
// PyThreadState_Get : https://docs.python.org/3/c-api/init.html#c.PyThreadState_Get
|
||||
func PyThreadState_Get() *PyThreadState {
|
||||
return (*PyThreadState)(C.PyThreadState_Get())
|
||||
}
|
||||
|
||||
//PyThreadState_Swap : https://docs.python.org/3/c-api/init.html#c.PyThreadState_Swap
|
||||
// PyThreadState_Swap : https://docs.python.org/3/c-api/init.html#c.PyThreadState_Swap
|
||||
func PyThreadState_Swap(tstate *PyThreadState) *PyThreadState {
|
||||
return (*PyThreadState)(C.PyThreadState_Swap((*C.PyThreadState)(tstate)))
|
||||
}
|
||||
|
||||
//PyEval_ReInitThreads : https://docs.python.org/3/c-api/init.html#c.PyEval_ReInitThreads
|
||||
// PyEval_ReInitThreads : https://docs.python.org/3/c-api/init.html#c.PyEval_ReInitThreads
|
||||
/*
|
||||
func PyEval_ReInitThreads() {
|
||||
C.PyEval_ReInitThreads()
|
||||
}
|
||||
*/
|
||||
|
||||
//PyGILState_Ensure : https://docs.python.org/3/c-api/init.html#c.PyGILState_Ensure
|
||||
// PyGILState_Ensure : https://docs.python.org/3/c-api/init.html#c.PyGILState_Ensure
|
||||
func PyGILState_Ensure() PyGILState {
|
||||
return PyGILState(C.PyGILState_Ensure())
|
||||
}
|
||||
|
||||
//PyGILState_Release : https://docs.python.org/3/c-api/init.html#c.PyGILState_Release
|
||||
// PyGILState_Release : https://docs.python.org/3/c-api/init.html#c.PyGILState_Release
|
||||
func PyGILState_Release(state PyGILState) {
|
||||
C.PyGILState_Release(C.PyGILState_STATE(state))
|
||||
}
|
||||
|
||||
//PyGILState_GetThisThreadState : https://docs.python.org/3/c-api/init.html#c.PyGILState_GetThisThreadState
|
||||
// PyGILState_GetThisThreadState : https://docs.python.org/3/c-api/init.html#c.PyGILState_GetThisThreadState
|
||||
func PyGILState_GetThisThreadState() *PyThreadState {
|
||||
return (*PyThreadState)(C.PyGILState_GetThisThreadState())
|
||||
}
|
||||
|
||||
//PyGILState_Check : https://docs.python.org/3/c-api/init.html#c.PyGILState_Check
|
||||
// PyGILState_Check : https://docs.python.org/3/c-api/init.html#c.PyGILState_Check
|
||||
func PyGILState_Check() bool {
|
||||
return C.PyGILState_Check() == 1
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue