github.com/goplus/llgo@v0.8.3/py/bytes.go (about) 1 /* 2 * Copyright (c) 2024 The GoPlus Authors (goplus.org). All rights reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package py 18 19 /* 20 21 import ( 22 _ "unsafe" 23 24 "github.com/goplus/llgo/c" 25 ) 26 27 // https://docs.python.org/3/c-api/bytes.html 28 29 // String returns a new bytes object from a C string. 30 // 31 //go:linkname FromCStr C.PyBytes_FromString 32 func FromCStr(s *c.Char) *Object 33 34 // FromString returns a new bytes object from a Go string. 35 func FromString(s string) *Object { 36 return stringFromStringAndSize(c.GoStringData(s), uintptr(len(s))) 37 } 38 39 //go:linkname stringFromStringAndSize C.PyBytes_FromStringAndSize 40 func stringFromStringAndSize(s *c.Char, size uintptr) *Object 41 42 // CStr returns the content of a bytes object as a C string. 43 // 44 // llgo:link (*Object).CStr C.PyBytes_AsString 45 func (o *Object) CStr() *c.Char { return nil } 46 47 // llgo:link (*Object).Strlen C.PyBytes_Size 48 func (o *Object) Strlen() uintptr { return 0 } 49 50 */