Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions cl/func.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func compileFuncOrMethod(ctx *pkgCtx, obj *overloadObj, this *classCtx) {

var recv *types.Var
var typRecv *types.Named // if tryToMethod succeeded, this is the recv
var typName, typCName, clsName string
var typName, typCName string
var nameInPkg string
if this == nil {
if ctx.lang == LanguageC {
Expand All @@ -141,11 +141,6 @@ func compileFuncOrMethod(ctx *pkgCtx, obj *overloadObj, this *classCtx) {
recvCType = recvCType.Pointee()
}
typCName = trimTypeTag(clang.String(recvCType.Unqualified()))
if cls != "" {
clsName = cls
} else {
clsName = typName
}
// When the function resolves to a logical class distinct from
// the physical receiver type (for example PyList_GetItem
// resolves to List while its receiver is the base class
Expand All @@ -165,10 +160,9 @@ func compileFuncOrMethod(ctx *pkgCtx, obj *overloadObj, this *classCtx) {
typNamed := this.typNamed
recv = types.NewParam(goNodePos(ctx, fn), pkgTypes, "this", types.NewPointer(typNamed))
typName = typNamed.Obj().Name()
clsName = typName
}

fnName := ctx.funcName(name, obj.order(), clsName, typCName, this == nil, true)
fnName := ctx.funcName(name, obj.order(), typName, typCName, this == nil, true)

if recv == nil {
nameInPkg = fnName
Expand Down
8 changes: 4 additions & 4 deletions cl/logical.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func (p *pkgCtx) newLogicalType(decl clang.Cursor, goName string, base *types.Na

// genAsMethod emits the conversion method on the base class, for example
//
// func (o *Object) AsList() *List { return (*List)(unsafe.Pointer(o)) }
// func (self *Object) AsList() *List { return (*List)(unsafe.Pointer(self)) }
//
// The conversion only reinterprets the pointer; it does not call into C and does
// not check the object's real type. If a method of the same name already exists
Expand All @@ -121,7 +121,7 @@ func (p *pkgCtx) genAsMethod(decl clang.Cursor, lc *logicalClass) {
pkgTypes := pkg.Types
recvType := types.NewPointer(lc.base)
retType := types.NewPointer(lc.named)
recv := types.NewParam(goNodePos(p, decl), pkgTypes, "o", recvType)
recv := types.NewParam(goNodePos(p, decl), pkgTypes, c2goMethodRecvName, recvType)
results := types.NewTuple(types.NewParam(token.NoPos, pkgTypes, "", retType))
sig := types.NewSignatureType(recv, nil, nil, nil, results, false)

Expand All @@ -130,9 +130,9 @@ func (p *pkgCtx) genAsMethod(decl clang.Cursor, lc *logicalClass) {
p.panicf(decl, "logical class %s: genAsMethod failed - %v", lc.named.Obj().Name(), err)
}
cb := f.BodyStart(pkg)
// return (*List)(unsafe.Pointer(o))
// return (*List)(unsafe.Pointer(self))
cb.Typ(retType).
Typ(p.unsafePointer()).VarVal("o").
Typ(p.unsafePointer()).Val(recv).
Call(1).
Call(1).
Return(1).End()
Expand Down
3 changes: 2 additions & 1 deletion tool/_testc/python-3.14.8/include/pythread.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ typedef enum Py_Lock_Status {

typedef struct _Py_tss_t Py_tss_t; /* opaque */

struct PyObject {};
typedef struct PyObject {} PyObject;

// Test if an object is the True singleton, the same as "x is True" in Python.
PyAPI_FUNC(int) Py_IsTrue(PyObject *x);

PyAPI_FUNC(int) PyObject_IsTrue(PyObject *x);

PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *x, PyObject *index);
PyAPI_FUNC(void) PyList_SetItem(PyObject *x, PyObject *index, PyObject *value);

PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *x, PyObject *index);

Expand Down
12 changes: 8 additions & 4 deletions tool/_testc/python-3.14.8/pythread.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading