py.Str; py.FromCStr/FromCStrAndLen/FromGoString
This commit is contained in:
@@ -46,7 +46,7 @@ func NewFuncWithQualName(code, globals, qualname *Object) *Object
|
||||
// Return true if o is a function object (has type PyFunction_Type). The
|
||||
// parameter must not be nil. This function always succeeds.
|
||||
//
|
||||
// llgo:link (*Object).FuncCheck C.PyFunction_Check
|
||||
//- llgo:link (*Object).FuncCheck C.PyFunction_Check
|
||||
func (o *Object) FuncCheck() c.Int { return 0 }
|
||||
*/
|
||||
|
||||
|
||||
@@ -49,5 +49,5 @@ func (t *Object) TypeFlags() uint32 { return 0 }
|
||||
// llgo:link (*Object).TypeModule C.PyType_GetModule
|
||||
func (t *Object) TypeModule() *Object { return nil }
|
||||
|
||||
// llgo:link (*Object).TypeModuleByDef C.PyType_GetModuleByDef
|
||||
// -llgo:link (*Object).TypeModuleByDef C.PyType_GetModuleByDef
|
||||
// func (t *Object) TypeModuleByDef(def *ModuleDef) *Object { return nil }
|
||||
|
||||
@@ -24,6 +24,20 @@ import (
|
||||
|
||||
// https://docs.python.org/3/c-api/unicode.html
|
||||
|
||||
//go:linkname Str llgo.pystr
|
||||
func Str(s string) *Object
|
||||
|
||||
//go:linkname FromCStr C.PyUnicode_FromString
|
||||
func FromCStr(str *c.Char) *Object
|
||||
|
||||
//go:linkname FromCStrAndLen C.PyUnicode_FromStringAndSize
|
||||
func FromCStrAndLen(str *c.Char, n int) *Object
|
||||
|
||||
// FromGoString returns a new Unicode object from a Go string.
|
||||
func FromGoString(s string) *Object {
|
||||
return FromCStrAndLen(c.GoStringData(s), len(s))
|
||||
}
|
||||
|
||||
// Return a pointer to the UTF-8 encoding of the Unicode object, and store the
|
||||
// size of the encoded representation (in bytes) in size. The size argument can
|
||||
// be nil; in this case no size will be stored. The returned buffer always has
|
||||
|
||||
Reference in New Issue
Block a user