Skip to content

Commit ab76c6f

Browse files
author
g.ph
committed
update
1 parent 8ad4d8e commit ab76c6f

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

cpy3/cpy3.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,39 @@ func Py_SetPath(path string) {
7575
func Py_SetPythonHome(home string) {
7676
py_SetPythonHome.Call(StringToUTF16Ptr(home))
7777
}
78+
79+
func Py_fopen_obj(path uintptr,mode string)uintptr{
80+
r,_,_:=_py_fopen_obj.Call(path,GoStrToCStr(mode))
81+
return r
82+
}
83+
84+
func PyUnicode_FromString(u string)uintptr{
85+
r,_,_:=pyUnicode_FromString.Call(GoStrToCStr(u))
86+
return r
87+
}
88+
func PyUnicode_GetLength(obj uintptr)uintptr{
89+
r,_,_:=pyUnicode_GetLength.Call(obj)
90+
return r
91+
}
92+
func PyLong_FromLong(l int64)uintptr{
93+
r,_,_:=pyLong_FromLong.Call(uintptr(l))
94+
return r
95+
}
96+
97+
98+
func Py_IncRef(obj uintptr){
99+
py_IncRef.Call(obj)
100+
}
101+
func Py_DecRef(obj uintptr){
102+
py_DecRef.Call(obj)
103+
}
104+
105+
106+
func PyImport_AppendInittab(name string,initfunc uintptr)int{
107+
r,_,_:=pyImport_AppendInittab.Call(GoStrToCStr(name),initfunc)
108+
return int(r)
109+
}
110+
func PyModule_Create2(PyModuleDef uintptr,apiver int)uintptr{
111+
r,_,_:=pyModule_Create2.Call(PyModuleDef, uintptr(apiver))
112+
return r
113+
}

cpy3/importfuncs.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ var (
2222
pyRun_SimpleString = libpython3.NewProc("PyRun_SimpleString")
2323
py_SetPath = libpython3.NewProc("Py_SetPath")
2424
py_SetPythonHome = libpython3.NewProc("Py_SetPythonHome")
25+
_py_fopen_obj = libpython3.NewProc("_Py_fopen_obj")
26+
27+
28+
29+
pyImport_AppendInittab = libpython3.NewProc("PyImport_AppendInittab")
30+
pyModule_Create2 = libpython3.NewProc("PyModule_Create2")
31+
32+
33+
34+
35+
36+
py_IncRef = libpython3.NewProc("Py_IncRef")
37+
py_DecRef = libpython3.NewProc("Py_DecRef")
38+
39+
pyUnicode_FromString = libpython3.NewProc("PyUnicode_FromString")
40+
pyUnicode_GetLength = libpython3.NewProc("PyUnicode_GetLength")
41+
pyLong_FromLong = libpython3.NewProc("PyLong_FromLong")
2542
)
2643
var kernel32dll = syscall.NewLazyDLL("kernel32.dll")
2744
var (

0 commit comments

Comments
 (0)