genbindings/clang: implicit ctors/dtors always have public visibility

This commit is contained in:
mappu 2024-08-25 12:48:19 +12:00
parent 03a47e4da4
commit fc62d963ea
2 changed files with 14 additions and 2 deletions

View File

@ -233,7 +233,12 @@ nextMethod:
// These seem to have no useful content
case "CXXConstructorDecl":
if !visibility {
if isImplicit, ok := node["isImplicit"].(bool); ok && isImplicit {
// This is an implicit ctor. Therefore the class is constructable
// even if we're currently in a `private:` block.
} else if !visibility {
continue // Skip private/protected
}
@ -288,6 +293,13 @@ nextMethod:
// However if this destructor is private or deleted, we should
// not bind it
if isImplicit, ok := node["isImplicit"].(bool); ok && isImplicit {
// This is an implicit dtor. Therefore the class is deleteable
// even if we're currently in a `private:` block.
ret.CanDelete = true
continue
}
if !visibility {
ret.CanDelete = false
continue

View File

@ -385,7 +385,7 @@ import "C"
// Construct our Go type based on this inner CABI type
shouldReturn = "ret := "
if m.ReturnType.Pointer || m.ReturnType.ParameterType == "QSize" { // FIXME QSize has a deleted destructor, so we can't delete our heap copy with a finalizer(!!)
if m.ReturnType.Pointer {
gfs.imports["unsafe"] = struct{}{}
afterword = "return new" + m.ReturnType.ParameterType + "_U(unsafe.Pointer(ret))"