File tree Expand file tree Collapse file tree 3 files changed +9
-18
lines changed
Expand file tree Collapse file tree 3 files changed +9
-18
lines changed Original file line number Diff line number Diff line change 11package gp
22
3- /*
4- #include <Python.h>
5- */
63import "C"
7- import (
8- "unsafe"
9- )
104
115type 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}
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ func BytesFromStr(s string) Bytes {
2222
2323func 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}
Original file line number Diff line number Diff line change @@ -15,15 +15,15 @@ func newStr(obj *PyObject) Str {
1515}
1616
1717func 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
2323func (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
2929func (s Str ) Len () int {
You can’t perform that action at this time.
0 commit comments