github.com/goplus/llgo@v0.8.3/py/object.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 import ( 20 _ "unsafe" 21 22 "github.com/goplus/llgo/c" 23 ) 24 25 // https://docs.python.org/3/c-api/object.html 26 27 // Object represents a Python object. 28 type Object struct { 29 Unused [8]byte 30 } 31 32 // llgo:link (*Object).DecRef C.Py_DecRef 33 func (o *Object) DecRef() {} 34 35 // llgo:link (*Object).Type C.PyObject_Type 36 func (o *Object) Type() *Object { return nil } 37 38 // Compute a string representation of object o. Returns the string representation on 39 // success, nil on failure. This is the equivalent of the Python expression str(o). 40 // Called by the str() built-in function and, therefore, by the print() function. 41 // 42 // llgo:link (*Object).Str C.PyObject_Str 43 func (o *Object) Str() *Object { return nil } 44 45 // Returns 1 if the object o is considered to be true, and 0 otherwise. This is equivalent 46 // to the Python expression not not o. On failure, return -1. 47 // 48 // llgo:link (*Object).IsTrue C.PyObject_IsTrue 49 func (o *Object) IsTrue() c.Int { return -1 } 50 51 // Returns 0 if the object o is considered to be true, and 1 otherwise. This is equivalent 52 // to the Python expression not o. On failure, return -1. 53 // 54 // llgo:link (*Object).NotTrue C.PyObject_Not 55 func (o *Object) NotTrue() c.Int { return -1 } 56 57 // ----------------------------------------------------------------------------- 58 59 // Retrieve an attribute named attrName from object o. Returns the attribute value on success, 60 // or nil on failure. This is the equivalent of the Python expression o.attrName. 61 // 62 // llgo:link (*Object).GetAttr C.PyObject_GetAttr 63 func (o *Object) GetAttr(attrName *Object) *Object { return nil } 64 65 // llgo:link (*Object).GetAttrString C.PyObject_GetAttrString 66 func (o *Object) GetAttrString(attrName *c.Char) *Object { return nil } 67 68 // -----------------------------------------------------------------------------