2024-08-25 04:08:24 +00:00
|
|
|
#include <QString>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <cstring>
|
2024-08-25 04:08:24 +00:00
|
|
|
#include <QSystemSemaphore>
|
2024-10-16 05:07:56 +00:00
|
|
|
#include <qsystemsemaphore.h>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "gen_qsystemsemaphore.h"
|
2024-09-14 22:29:05 +00:00
|
|
|
#include "_cgo_export.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
void QSystemSemaphore_new(struct miqt_string key, QSystemSemaphore** outptr_QSystemSemaphore) {
|
2024-10-18 23:53:33 +00:00
|
|
|
QString key_QString = QString::fromUtf8(key.data, key.len);
|
2024-11-19 06:29:06 +00:00
|
|
|
QSystemSemaphore* ret = new QSystemSemaphore(key_QString);
|
|
|
|
*outptr_QSystemSemaphore = ret;
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
void QSystemSemaphore_new2(struct miqt_string key, int initialValue, QSystemSemaphore** outptr_QSystemSemaphore) {
|
2024-10-18 23:53:33 +00:00
|
|
|
QString key_QString = QString::fromUtf8(key.data, key.len);
|
2024-11-19 06:29:06 +00:00
|
|
|
QSystemSemaphore* ret = new QSystemSemaphore(key_QString, static_cast<int>(initialValue));
|
|
|
|
*outptr_QSystemSemaphore = ret;
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
void QSystemSemaphore_new3(struct miqt_string key, int initialValue, int mode, QSystemSemaphore** outptr_QSystemSemaphore) {
|
2024-10-18 23:53:33 +00:00
|
|
|
QString key_QString = QString::fromUtf8(key.data, key.len);
|
2024-11-19 06:29:06 +00:00
|
|
|
QSystemSemaphore* ret = new QSystemSemaphore(key_QString, static_cast<int>(initialValue), static_cast<QSystemSemaphore::AccessMode>(mode));
|
|
|
|
*outptr_QSystemSemaphore = ret;
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
void QSystemSemaphore_SetKey(QSystemSemaphore* self, struct miqt_string key) {
|
|
|
|
QString key_QString = QString::fromUtf8(key.data, key.len);
|
2024-08-29 07:01:51 +00:00
|
|
|
self->setKey(key_QString);
|
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
struct miqt_string QSystemSemaphore_Key(const QSystemSemaphore* self) {
|
2024-09-14 22:29:05 +00:00
|
|
|
QString _ret = self->key();
|
2024-08-25 04:08:24 +00:00
|
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
2024-09-14 22:29:05 +00:00
|
|
|
QByteArray _b = _ret.toUtf8();
|
2024-10-18 23:53:33 +00:00
|
|
|
struct miqt_string _ms;
|
|
|
|
_ms.len = _b.length();
|
|
|
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
|
|
|
memcpy(_ms.data, _b.data(), _ms.len);
|
|
|
|
return _ms;
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool QSystemSemaphore_Acquire(QSystemSemaphore* self) {
|
|
|
|
return self->acquire();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QSystemSemaphore_Release(QSystemSemaphore* self) {
|
|
|
|
return self->release();
|
|
|
|
}
|
|
|
|
|
2024-09-18 00:12:02 +00:00
|
|
|
int QSystemSemaphore_Error(const QSystemSemaphore* self) {
|
2024-09-14 22:29:05 +00:00
|
|
|
QSystemSemaphore::SystemSemaphoreError _ret = self->error();
|
2024-09-18 00:12:02 +00:00
|
|
|
return static_cast<int>(_ret);
|
2024-08-29 07:01:51 +00:00
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
struct miqt_string QSystemSemaphore_ErrorString(const QSystemSemaphore* self) {
|
2024-09-14 22:29:05 +00:00
|
|
|
QString _ret = self->errorString();
|
2024-08-25 04:08:24 +00:00
|
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
2024-09-14 22:29:05 +00:00
|
|
|
QByteArray _b = _ret.toUtf8();
|
2024-10-18 23:53:33 +00:00
|
|
|
struct miqt_string _ms;
|
|
|
|
_ms.len = _b.length();
|
|
|
|
_ms.data = static_cast<char*>(malloc(_ms.len));
|
|
|
|
memcpy(_ms.data, _b.data(), _ms.len);
|
|
|
|
return _ms;
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
void QSystemSemaphore_SetKey2(QSystemSemaphore* self, struct miqt_string key, int initialValue) {
|
|
|
|
QString key_QString = QString::fromUtf8(key.data, key.len);
|
2024-08-29 07:01:51 +00:00
|
|
|
self->setKey(key_QString, static_cast<int>(initialValue));
|
|
|
|
}
|
|
|
|
|
2024-10-18 23:53:33 +00:00
|
|
|
void QSystemSemaphore_SetKey3(QSystemSemaphore* self, struct miqt_string key, int initialValue, int mode) {
|
|
|
|
QString key_QString = QString::fromUtf8(key.data, key.len);
|
2024-08-29 07:01:51 +00:00
|
|
|
self->setKey(key_QString, static_cast<int>(initialValue), static_cast<QSystemSemaphore::AccessMode>(mode));
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
bool QSystemSemaphore_Release1(QSystemSemaphore* self, int n) {
|
|
|
|
return self->release(static_cast<int>(n));
|
|
|
|
}
|
|
|
|
|
2024-11-19 06:29:06 +00:00
|
|
|
void QSystemSemaphore_Delete(QSystemSemaphore* self, bool isSubclass) {
|
|
|
|
if (isSubclass) {
|
|
|
|
delete dynamic_cast<QSystemSemaphore*>( self );
|
|
|
|
} else {
|
|
|
|
delete self;
|
|
|
|
}
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|