Skip to content

Commit 77585b4

Browse files
committed
export less C types
1 parent f04f781 commit 77585b4

File tree

3 files changed

+9
-18
lines changed

3 files changed

+9
-18
lines changed

adap_go.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,22 @@
11
package gp
22

3-
/*
4-
#include <Python.h>
5-
*/
63
import "C"
7-
import (
8-
"unsafe"
9-
)
104

115
type Char = C.char
12-
type WChar = C.wchar_t
13-
type Int = C.int
14-
type Pointer = unsafe.Pointer
156

167
//go:inline
17-
func AllocCStr(s string) *C.char {
8+
func AllocCStr(s string) *Char {
189
return C.CString(s)
1910
}
2011

21-
func AllocCStrDontFree(s string) *C.char {
12+
func AllocCStrDontFree(s string) *Char {
2213
return C.CString(s)
2314
}
2415

25-
func GoString(s *C.char) string {
26-
return C.GoString((*C.char)(s))
16+
func GoString(s *Char) string {
17+
return C.GoString((*Char)(s))
2718
}
2819

29-
func GoStringN(s *C.char, n int) string {
30-
return C.GoStringN((*C.char)(s), C.int(n))
20+
func GoStringN(s *Char, n int) string {
21+
return C.GoStringN(s, C.int(n))
3122
}

bytes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func BytesFromStr(s string) Bytes {
2222

2323
func MakeBytes(bytes []byte) Bytes {
2424
ptr := C.CBytes(bytes)
25-
o := C.PyBytes_FromStringAndSize((*C.char)(ptr), C.Py_ssize_t(len(bytes)))
25+
o := C.PyBytes_FromStringAndSize((*Char)(ptr), C.Py_ssize_t(len(bytes)))
2626
C.free(unsafe.Pointer(ptr))
2727
return newBytes(o)
2828
}

unicode.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ func newStr(obj *PyObject) Str {
1515
}
1616

1717
func MakeStr(s string) Str {
18-
ptr := (*C.char)(unsafe.Pointer(unsafe.StringData(s)))
18+
ptr := (*Char)(unsafe.Pointer(unsafe.StringData(s)))
1919
length := C.long(len(s))
2020
return newStr(C.PyUnicode_FromStringAndSize(ptr, length))
2121
}
2222

2323
func (s Str) String() string {
2424
var l C.long
2525
buf := C.PyUnicode_AsUTF8AndSize(s.obj, &l)
26-
return GoStringN((*C.char)(buf), int(l))
26+
return GoStringN((*Char)(buf), int(l))
2727
}
2828

2929
func (s Str) Len() int {

0 commit comments

Comments
 (0)