miqt/qt/gen_qmutex.go

322 lines
6.8 KiB
Go
Raw Normal View History

package qt
/*
#include "gen_qmutex.h"
#include <stdlib.h>
*/
import "C"
import (
"runtime"
"unsafe"
)
2024-09-04 06:54:22 +00:00
type QMutex__RecursionMode int
const (
2024-09-20 07:13:26 +00:00
QMutex__NonRecursive QMutex__RecursionMode = 0
QMutex__Recursive QMutex__RecursionMode = 1
2024-09-04 06:54:22 +00:00
)
type QBasicMutex struct {
2024-11-19 06:29:06 +00:00
h *C.QBasicMutex
isSubclass bool
}
func (this *QBasicMutex) cPointer() *C.QBasicMutex {
if this == nil {
return nil
}
return this.h
}
func (this *QBasicMutex) UnsafePointer() unsafe.Pointer {
if this == nil {
return nil
}
return unsafe.Pointer(this.h)
}
2024-11-19 06:29:06 +00:00
// newQBasicMutex constructs the type using only CGO pointers.
func newQBasicMutex(h *C.QBasicMutex) *QBasicMutex {
2024-09-01 02:23:55 +00:00
if h == nil {
return nil
}
2024-12-07 04:15:57 +00:00
return &QBasicMutex{h: h}
}
2024-11-19 06:29:06 +00:00
// UnsafeNewQBasicMutex constructs the type using only unsafe pointers.
func UnsafeNewQBasicMutex(h unsafe.Pointer) *QBasicMutex {
2024-12-07 04:15:57 +00:00
return newQBasicMutex((*C.QBasicMutex)(h))
}
// NewQBasicMutex constructs a new QBasicMutex object.
func NewQBasicMutex() *QBasicMutex {
2024-11-19 06:29:06 +00:00
2024-12-07 04:15:57 +00:00
ret := newQBasicMutex(C.QBasicMutex_new())
2024-11-19 06:29:06 +00:00
ret.isSubclass = true
return ret
}
func (this *QBasicMutex) Lock() {
C.QBasicMutex_Lock(this.h)
}
func (this *QBasicMutex) Unlock() {
C.QBasicMutex_Unlock(this.h)
}
func (this *QBasicMutex) TryLock() bool {
return (bool)(C.QBasicMutex_TryLock(this.h))
}
func (this *QBasicMutex) TryLock2() bool {
return (bool)(C.QBasicMutex_TryLock2(this.h))
}
func (this *QBasicMutex) IsRecursive() bool {
return (bool)(C.QBasicMutex_IsRecursive(this.h))
}
func (this *QBasicMutex) IsRecursive2() bool {
return (bool)(C.QBasicMutex_IsRecursive2(this.h))
}
// Delete this object from C++ memory.
func (this *QBasicMutex) Delete() {
2024-11-19 06:29:06 +00:00
C.QBasicMutex_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 *QBasicMutex) GoGC() {
runtime.SetFinalizer(this, func(this *QBasicMutex) {
this.Delete()
runtime.KeepAlive(this.h)
})
}
type QMutex struct {
2024-11-19 06:29:06 +00:00
h *C.QMutex
isSubclass bool
*QBasicMutex
}
func (this *QMutex) cPointer() *C.QMutex {
if this == nil {
return nil
}
return this.h
}
func (this *QMutex) UnsafePointer() unsafe.Pointer {
if this == nil {
return nil
}
return unsafe.Pointer(this.h)
}
2024-11-19 06:29:06 +00:00
// newQMutex constructs the type using only CGO pointers.
2024-12-07 04:15:57 +00:00
func newQMutex(h *C.QMutex) *QMutex {
2024-09-01 02:23:55 +00:00
if h == nil {
return nil
}
2024-12-07 04:15:57 +00:00
var outptr_QBasicMutex *C.QBasicMutex = nil
C.QMutex_virtbase(h, &outptr_QBasicMutex)
2024-11-19 06:29:06 +00:00
return &QMutex{h: h,
2024-12-07 04:15:57 +00:00
QBasicMutex: newQBasicMutex(outptr_QBasicMutex)}
}
2024-11-19 06:29:06 +00:00
// UnsafeNewQMutex constructs the type using only unsafe pointers.
2024-12-07 04:15:57 +00:00
func UnsafeNewQMutex(h unsafe.Pointer) *QMutex {
return newQMutex((*C.QMutex)(h))
}
// NewQMutex constructs a new QMutex object.
func NewQMutex() *QMutex {
2024-11-19 06:29:06 +00:00
2024-12-07 04:15:57 +00:00
ret := newQMutex(C.QMutex_new())
2024-11-19 06:29:06 +00:00
ret.isSubclass = true
return ret
}
2024-08-29 07:01:51 +00:00
// NewQMutex2 constructs a new QMutex object.
2024-09-04 06:54:22 +00:00
func NewQMutex2(mode QMutex__RecursionMode) *QMutex {
2024-11-19 06:29:06 +00:00
2024-12-07 04:15:57 +00:00
ret := newQMutex(C.QMutex_new2((C.int)(mode)))
2024-11-19 06:29:06 +00:00
ret.isSubclass = true
return ret
2024-08-29 07:01:51 +00:00
}
func (this *QMutex) Lock() {
C.QMutex_Lock(this.h)
}
func (this *QMutex) TryLock() bool {
return (bool)(C.QMutex_TryLock(this.h))
}
func (this *QMutex) Unlock() {
C.QMutex_Unlock(this.h)
}
func (this *QMutex) TryLock2() bool {
return (bool)(C.QMutex_TryLock2(this.h))
}
func (this *QMutex) IsRecursive() bool {
return (bool)(C.QMutex_IsRecursive(this.h))
}
func (this *QMutex) TryLock1(timeout int) bool {
return (bool)(C.QMutex_TryLock1(this.h, (C.int)(timeout)))
}
// Delete this object from C++ memory.
func (this *QMutex) Delete() {
2024-11-19 06:29:06 +00:00
C.QMutex_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 *QMutex) GoGC() {
runtime.SetFinalizer(this, func(this *QMutex) {
this.Delete()
runtime.KeepAlive(this.h)
})
}
type QRecursiveMutex struct {
2024-11-19 06:29:06 +00:00
h *C.QRecursiveMutex
isSubclass bool
}
func (this *QRecursiveMutex) cPointer() *C.QRecursiveMutex {
if this == nil {
return nil
}
return this.h
}
func (this *QRecursiveMutex) UnsafePointer() unsafe.Pointer {
if this == nil {
return nil
}
return unsafe.Pointer(this.h)
}
2024-11-19 06:29:06 +00:00
// newQRecursiveMutex constructs the type using only CGO pointers.
func newQRecursiveMutex(h *C.QRecursiveMutex) *QRecursiveMutex {
2024-09-01 02:23:55 +00:00
if h == nil {
return nil
}
2024-12-07 04:15:57 +00:00
return &QRecursiveMutex{h: h}
}
2024-11-19 06:29:06 +00:00
// UnsafeNewQRecursiveMutex constructs the type using only unsafe pointers.
func UnsafeNewQRecursiveMutex(h unsafe.Pointer) *QRecursiveMutex {
2024-12-07 04:15:57 +00:00
return newQRecursiveMutex((*C.QRecursiveMutex)(h))
}
// NewQRecursiveMutex constructs a new QRecursiveMutex object.
func NewQRecursiveMutex() *QRecursiveMutex {
2024-11-19 06:29:06 +00:00
2024-12-07 04:15:57 +00:00
ret := newQRecursiveMutex(C.QRecursiveMutex_new())
2024-11-19 06:29:06 +00:00
ret.isSubclass = true
return ret
}
// Delete this object from C++ memory.
func (this *QRecursiveMutex) Delete() {
2024-11-19 06:29:06 +00:00
C.QRecursiveMutex_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 *QRecursiveMutex) GoGC() {
runtime.SetFinalizer(this, func(this *QRecursiveMutex) {
this.Delete()
runtime.KeepAlive(this.h)
})
}
type QMutexLocker struct {
2024-11-19 06:29:06 +00:00
h *C.QMutexLocker
isSubclass bool
}
func (this *QMutexLocker) cPointer() *C.QMutexLocker {
if this == nil {
return nil
}
return this.h
}
func (this *QMutexLocker) UnsafePointer() unsafe.Pointer {
if this == nil {
return nil
}
return unsafe.Pointer(this.h)
}
2024-11-19 06:29:06 +00:00
// newQMutexLocker constructs the type using only CGO pointers.
func newQMutexLocker(h *C.QMutexLocker) *QMutexLocker {
2024-09-01 02:23:55 +00:00
if h == nil {
return nil
}
2024-12-07 04:15:57 +00:00
return &QMutexLocker{h: h}
}
2024-11-19 06:29:06 +00:00
// UnsafeNewQMutexLocker constructs the type using only unsafe pointers.
func UnsafeNewQMutexLocker(h unsafe.Pointer) *QMutexLocker {
2024-12-07 04:15:57 +00:00
return newQMutexLocker((*C.QMutexLocker)(h))
}
// NewQMutexLocker constructs a new QMutexLocker object.
func NewQMutexLocker(m *QBasicMutex) *QMutexLocker {
2024-11-19 06:29:06 +00:00
2024-12-07 04:15:57 +00:00
ret := newQMutexLocker(C.QMutexLocker_new(m.cPointer()))
2024-11-19 06:29:06 +00:00
ret.isSubclass = true
return ret
}
// NewQMutexLocker2 constructs a new QMutexLocker object.
func NewQMutexLocker2(m *QRecursiveMutex) *QMutexLocker {
2024-11-19 06:29:06 +00:00
2024-12-07 04:15:57 +00:00
ret := newQMutexLocker(C.QMutexLocker_new2(m.cPointer()))
2024-11-19 06:29:06 +00:00
ret.isSubclass = true
return ret
}
func (this *QMutexLocker) Unlock() {
C.QMutexLocker_Unlock(this.h)
}
func (this *QMutexLocker) Relock() {
C.QMutexLocker_Relock(this.h)
}
func (this *QMutexLocker) Mutex() *QMutex {
2024-12-07 04:15:57 +00:00
return newQMutex(C.QMutexLocker_Mutex(this.h))
}
// Delete this object from C++ memory.
func (this *QMutexLocker) Delete() {
2024-11-19 06:29:06 +00:00
C.QMutexLocker_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 *QMutexLocker) GoGC() {
runtime.SetFinalizer(this, func(this *QMutexLocker) {
this.Delete()
runtime.KeepAlive(this.h)
})
}