miqt/qt/gen_qscopedpointer.go

66 lines
1.5 KiB
Go
Raw Normal View History

package qt
/*
#include "gen_qscopedpointer.h"
#include <stdlib.h>
*/
import "C"
import (
"runtime"
"unsafe"
)
type QScopedPointerPodDeleter struct {
2024-11-19 06:29:06 +00:00
h *C.QScopedPointerPodDeleter
isSubclass bool
}
func (this *QScopedPointerPodDeleter) cPointer() *C.QScopedPointerPodDeleter {
if this == nil {
return nil
}
return this.h
}
func (this *QScopedPointerPodDeleter) UnsafePointer() unsafe.Pointer {
if this == nil {
return nil
}
return unsafe.Pointer(this.h)
}
2024-11-19 06:29:06 +00:00
// newQScopedPointerPodDeleter constructs the type using only CGO pointers.
func newQScopedPointerPodDeleter(h *C.QScopedPointerPodDeleter) *QScopedPointerPodDeleter {
2024-09-01 02:23:55 +00:00
if h == nil {
return nil
}
2024-12-07 04:15:57 +00:00
return &QScopedPointerPodDeleter{h: h}
}
2024-11-19 06:29:06 +00:00
// UnsafeNewQScopedPointerPodDeleter constructs the type using only unsafe pointers.
func UnsafeNewQScopedPointerPodDeleter(h unsafe.Pointer) *QScopedPointerPodDeleter {
2024-12-07 04:15:57 +00:00
return newQScopedPointerPodDeleter((*C.QScopedPointerPodDeleter)(h))
}
func QScopedPointerPodDeleter_Cleanup(pointer unsafe.Pointer) {
C.QScopedPointerPodDeleter_Cleanup(pointer)
}
// Delete this object from C++ memory.
func (this *QScopedPointerPodDeleter) Delete() {
2024-11-19 06:29:06 +00:00
C.QScopedPointerPodDeleter_Delete(this.h, C.bool(this.isSubclass))
}
// GoGC adds a Go Finalizer to this pointer, so that it will be deleted
// from C++ memory once it is unreachable from Go memory.
func (this *QScopedPointerPodDeleter) GoGC() {
runtime.SetFinalizer(this, func(this *QScopedPointerPodDeleter) {
this.Delete()
runtime.KeepAlive(this.h)
})
}