llgo/ssa: pyCall; demo: _pydemo/callpy

This commit is contained in:
xushiwei
2024-05-11 23:38:21 +08:00
parent a2d7a8c978
commit 94a7ee024a
12 changed files with 214 additions and 25 deletions

View File

@@ -36,7 +36,7 @@ type Object struct {
func BuildValue(format *c.Char, __llgo_va_list ...any) *Object
// llgo:link (*Object).DecRef C.Py_DecRef
func (o *Object) DecRef() { panic("unreachable") }
func (o *Object) DecRef() {}
// -----------------------------------------------------------------------------
@@ -44,10 +44,10 @@ func (o *Object) DecRef() { panic("unreachable") }
// or nil on failure. This is the equivalent of the Python expression o.attrName.
//
// llgo:link (*Object).GetAttr C.PyObject_GetAttr
func (o *Object) GetAttr(attrName *Object) *Object { panic("unreachable") }
func (o *Object) GetAttr(attrName *Object) *Object { return nil }
// llgo:link (*Object).GetAttrString C.PyObject_GetAttrString
func (o *Object) GetAttrString(attrName *c.Char) *Object { panic("unreachable") }
func (o *Object) GetAttrString(attrName *c.Char) *Object { return nil }
// -----------------------------------------------------------------------------
@@ -55,7 +55,7 @@ func (o *Object) GetAttrString(attrName *c.Char) *Object { panic("unreachable")
// 0 otherwise. This function always succeeds.
//
// llgo:link (*Object).Callable C.PyCallable_Check
func (o *Object) Callable() int { panic("unreachable") }
func (o *Object) Callable() c.Int { return 0 }
// Call a callable Python object o, with arguments given by the tuple args, and
// named arguments given by the dictionary kwargs.
@@ -69,7 +69,7 @@ func (o *Object) Callable() int { panic("unreachable") }
// This is the equivalent of the Python expression: o(*args, **kwargs).
//
// llgo:link (*Object).Call C.PyObject_Call
func (o *Object) Call(args, kwargs *Object) *Object { panic("unreachable") }
func (o *Object) Call(args, kwargs *Object) *Object { return nil }
// Call a callable Python object callable without any arguments. It is the most
// efficient way to call a callable Python object without any argument.
@@ -78,7 +78,7 @@ func (o *Object) Call(args, kwargs *Object) *Object { panic("unreachable") }
// on failure.
//
// llgo:link (*Object).CallNoArgs C.PyObject_CallNoArgs
func (o *Object) CallNoArgs() *Object { panic("unreachable") }
func (o *Object) CallNoArgs() *Object { return nil }
// Call a callable Python object callable with exactly 1 positional argument arg
// and no keyword arguments.
@@ -87,7 +87,7 @@ func (o *Object) CallNoArgs() *Object { panic("unreachable") }
// on failure.
//
// llgo:link (*Object).CallOneArg C.PyObject_CallOneArg
func (o *Object) CallOneArg(arg *Object) *Object { panic("unreachable") }
func (o *Object) CallOneArg(arg *Object) *Object { return nil }
// Call a callable Python object o, with arguments given by the tuple args. If no
// arguments are needed, then args can be nil.
@@ -98,7 +98,7 @@ func (o *Object) CallOneArg(arg *Object) *Object { panic("unreachable") }
// This is the equivalent of the Python expression: o(*args).
//
// llgo:link (*Object).CallObject C.PyObject_CallObject
func (o *Object) CallObject(callable, args *Object) *Object { panic("unreachable") }
func (o *Object) CallObject(callable, args *Object) *Object { return nil }
// Call a callable Python object o, with a variable number of C arguments. The C
// arguments are described using a py.BuildValue style format string. The format
@@ -113,7 +113,7 @@ func (o *Object) CallObject(callable, args *Object) *Object { panic("unreachable
// faster alternative.
//
// llgo:link (*Object).CallFunction C.PyObject_CallFunction
func (o *Object) CallFunction(format *c.Char, __llgo_va_list ...any) *Object { panic("unreachable") }
func (o *Object) CallFunction(format *c.Char, __llgo_va_list ...any) *Object { return nil }
// Call a callable Python object o, with a variable number of PyObject* arguments.
// The arguments are provided as a variable number of parameters followed by nil.
@@ -124,7 +124,7 @@ func (o *Object) CallFunction(format *c.Char, __llgo_va_list ...any) *Object { p
// This is the equivalent of the Python expression: o(arg1, arg2, ...).
//
// llgo:link (*Object).CallFunctionObjArgs C.PyObject_CallFunctionObjArgs
func (o *Object) CallFunctionObjArgs(__llgo_va_list ...any) *Object { panic("unreachable") }
func (o *Object) CallFunctionObjArgs(__llgo_va_list ...any) *Object { return nil }
// llgo:link (*Object).CallMethod C.PyObject_CallMethod
func (o *Object) CallMethod(name *c.Char, format *c.Char, __llgo_va_list ...any) *Object {
@@ -132,27 +132,27 @@ func (o *Object) CallMethod(name *c.Char, format *c.Char, __llgo_va_list ...any)
}
// llgo:link (*Object).CallMethodObjArgs C.PyObject_CallMethodObjArgs
func (o *Object) CallMethodObjArgs(name *Object, __llgo_va_list ...any) *Object { panic("unreachable") }
func (o *Object) CallMethodObjArgs(name *Object, __llgo_va_list ...any) *Object { return nil }
// llgo:link (*Object).CallMethodNoArgs C.PyObject_CallMethodNoArgs
func (o *Object) CallMethodNoArgs(name *Object) *Object { panic("unreachable") }
func (o *Object) CallMethodNoArgs(name *Object) *Object { return nil }
// llgo:link (*Object).CallMethodOneArg C.PyObject_CallMethodOneArg
func (o *Object) CallMethodOneArg(name, arg *Object) *Object { panic("unreachable") }
func (o *Object) CallMethodOneArg(name, arg *Object) *Object { return nil }
// llgo:link (*Object).Vectorcall C.PyObject_Vectorcall
func (o *Object) Vectorcall(args **Object, nargs uintptr, kwnames *Object) *Object {
panic("unreachable")
return nil
}
// llgo:link (*Object).VectorcallDict C.PyObject_VectorcallDict
func (o *Object) VectorcallDict(args **Object, nargs uintptr, kwdict *Object) *Object {
panic("unreachable")
return nil
}
// llgo:link (*Object).VectorcallMethod C.PyObject_VectorcallMethod
func (o *Object) VectorcallMethod(name *Object, args **Object, nargs uintptr, kwnames *Object) *Object {
panic("unreachable")
return nil
}
// -----------------------------------------------------------------------------