-
Notifications
You must be signed in to change notification settings - Fork 2
/
PyBool.go
37 lines (33 loc) · 686 Bytes
/
PyBool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package py3
import (
"github.com/aadog/py3-go/cpy3"
"unsafe"
)
type PyBool struct {
PyObject
}
// PyBoolFromInst
// 新建一个对象来自已经存在的对象实例指针。
//
// Create a new object from an existing object instance pointer.
func PyBoolFromInst(inst uintptr) *PyBool {
dl := new(PyBool)
dl.instance = inst
dl.ptr = unsafe.Pointer(dl.instance)
return dl
}
func PyBoolFromObj(obj *PyObject) *PyBool {
dl := new(PyBool)
dl.PyObject = *obj
return dl
}
func NewPyBoolFromLong(l int64) *PyObject {
return PyObjectFromInst(cpy3.PyBool_FromLong(l))
}
func NewPyBool(b bool) *PyObject {
l := 0
if b == true {
l = 1
}
return NewPyBoolFromLong(int64(l))
}