genbindings: panic when trying to override methods on non-subclass

This commit is contained in:
mappu 2024-12-07 14:18:47 +13:00
parent 138883fb2d
commit 5271f8d4a1

View File

@ -1028,6 +1028,9 @@ import "C"
goCbType += `) ` + m.ReturnType.renderReturnTypeGo(&gfs)
ret.WriteString(`func (this *` + goClassName + `) On` + m.SafeMethodName() + `(slot ` + goCbType + `) {
if ! this.isSubclass {
panic("miqt: can only override virtual methods for directly constructed types")
}
C.` + goClassName + `_override_virtual_` + m.SafeMethodName() + `(unsafe.Pointer(this.h), C.intptr_t(cgo.NewHandle(slot)) )
}