llpyg: todo

This commit is contained in:
xushiwei
2024-05-14 15:34:53 +08:00
parent d8bd8be57e
commit 35a73b4cde
5 changed files with 127 additions and 0 deletions

View File

@@ -22,6 +22,8 @@ import (
"github.com/goplus/llgo/c"
)
// https://docs.python.org/3/c-api/object.html
// Object represents a Python object.
type Object struct {
Unused [8]byte
@@ -30,6 +32,9 @@ type Object struct {
// llgo:link (*Object).DecRef C.Py_DecRef
func (o *Object) DecRef() {}
// llgo:link (*Object).Type C.PyObject_Type
func (o *Object) Type() *TypeObject { return nil }
// Compute a string representation of object o. Returns the string representation on
// success, nil on failure. This is the equivalent of the Python expression str(o).
// Called by the str() built-in function and, therefore, by the print() function.
@@ -37,6 +42,18 @@ func (o *Object) DecRef() {}
// llgo:link (*Object).Str C.PyObject_Str
func (o *Object) Str() *Object { return nil }
// Returns 1 if the object o is considered to be true, and 0 otherwise. This is equivalent
// to the Python expression not not o. On failure, return -1.
//
// llgo:link (*Object) IsTrue() C.PyObject_IsTrue
func (o *Object) IsTrue() c.Int { return -1 }
// Returns 0 if the object o is considered to be true, and 1 otherwise. This is equivalent
// to the Python expression not o. On failure, return -1.
//
// llgo:link (*Object) NotTrue() C.PyObject_Not
func (o *Object) NotTrue() c.Int { return -1 }
// -----------------------------------------------------------------------------
// Retrieve an attribute named attrName from object o. Returns the attribute value on success,