2024-08-25 04:08:24 +00:00
|
|
|
#include <QMetaObject>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QSharedMemory>
|
|
|
|
#include <QString>
|
2024-08-29 07:01:51 +00:00
|
|
|
#include <QByteArray>
|
|
|
|
#include <cstring>
|
|
|
|
#include "qsharedmemory.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
#include "gen_qsharedmemory.h"
|
2024-08-25 04:08:24 +00:00
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
extern void miqt_exec_callback(void* cb, int argc, void* argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
QSharedMemory* QSharedMemory_new() {
|
|
|
|
return new QSharedMemory();
|
|
|
|
}
|
|
|
|
|
|
|
|
QSharedMemory* QSharedMemory_new2(const char* key, size_t key_Strlen) {
|
|
|
|
QString key_QString = QString::fromUtf8(key, key_Strlen);
|
|
|
|
return new QSharedMemory(key_QString);
|
|
|
|
}
|
|
|
|
|
|
|
|
QSharedMemory* QSharedMemory_new3(QObject* parent) {
|
|
|
|
return new QSharedMemory(parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
QSharedMemory* QSharedMemory_new4(const char* key, size_t key_Strlen, QObject* parent) {
|
|
|
|
QString key_QString = QString::fromUtf8(key, key_Strlen);
|
|
|
|
return new QSharedMemory(key_QString, parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
QMetaObject* QSharedMemory_MetaObject(QSharedMemory* self) {
|
2024-08-29 07:01:51 +00:00
|
|
|
return (QMetaObject*) const_cast<const QSharedMemory*>(self)->metaObject();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QSharedMemory_Tr(const char* s, char** _out, int* _out_Strlen) {
|
2024-08-25 04:08:24 +00:00
|
|
|
QString ret = QSharedMemory::tr(s);
|
|
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
|
|
QByteArray b = ret.toUtf8();
|
|
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
|
|
memcpy(*_out, b.data(), b.length());
|
|
|
|
*_out_Strlen = b.length();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QSharedMemory_TrUtf8(const char* s, char** _out, int* _out_Strlen) {
|
2024-08-25 04:08:24 +00:00
|
|
|
QString ret = QSharedMemory::trUtf8(s);
|
|
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
|
|
QByteArray b = ret.toUtf8();
|
|
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
|
|
memcpy(*_out, b.data(), b.length());
|
|
|
|
*_out_Strlen = b.length();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QSharedMemory_SetKey(QSharedMemory* self, const char* key, size_t key_Strlen) {
|
|
|
|
QString key_QString = QString::fromUtf8(key, key_Strlen);
|
|
|
|
self->setKey(key_QString);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QSharedMemory_Key(QSharedMemory* self, char** _out, int* _out_Strlen) {
|
2024-08-29 07:01:51 +00:00
|
|
|
QString ret = const_cast<const QSharedMemory*>(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
|
|
|
|
QByteArray b = ret.toUtf8();
|
|
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
|
|
memcpy(*_out, b.data(), b.length());
|
|
|
|
*_out_Strlen = b.length();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QSharedMemory_SetNativeKey(QSharedMemory* self, const char* key, size_t key_Strlen) {
|
|
|
|
QString key_QString = QString::fromUtf8(key, key_Strlen);
|
|
|
|
self->setNativeKey(key_QString);
|
|
|
|
}
|
|
|
|
|
|
|
|
void QSharedMemory_NativeKey(QSharedMemory* self, char** _out, int* _out_Strlen) {
|
2024-08-29 07:01:51 +00:00
|
|
|
QString ret = const_cast<const QSharedMemory*>(self)->nativeKey();
|
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
|
|
|
|
QByteArray b = ret.toUtf8();
|
|
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
|
|
memcpy(*_out, b.data(), b.length());
|
|
|
|
*_out_Strlen = b.length();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
bool QSharedMemory_Create(QSharedMemory* self, int size) {
|
|
|
|
return self->create(static_cast<int>(size));
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
int QSharedMemory_Size(QSharedMemory* self) {
|
2024-08-29 07:01:51 +00:00
|
|
|
return const_cast<const QSharedMemory*>(self)->size();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QSharedMemory_Attach(QSharedMemory* self) {
|
|
|
|
return self->attach();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool QSharedMemory_IsAttached(QSharedMemory* self) {
|
2024-08-29 07:01:51 +00:00
|
|
|
return const_cast<const QSharedMemory*>(self)->isAttached();
|
2024-08-25 04:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool QSharedMemory_Detach(QSharedMemory* self) {
|
|
|
|
return self->detach();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QSharedMemory_Lock(QSharedMemory* self) {
|
|
|
|
return self->lock();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QSharedMemory_Unlock(QSharedMemory* self) {
|
|
|
|
return self->unlock();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
uintptr_t QSharedMemory_Error(QSharedMemory* self) {
|
|
|
|
QSharedMemory::SharedMemoryError ret = const_cast<const QSharedMemory*>(self)->error();
|
|
|
|
return static_cast<uintptr_t>(ret);
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
void QSharedMemory_ErrorString(QSharedMemory* self, char** _out, int* _out_Strlen) {
|
2024-08-29 07:01:51 +00:00
|
|
|
QString ret = const_cast<const QSharedMemory*>(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
|
|
|
|
QByteArray b = ret.toUtf8();
|
|
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
|
|
memcpy(*_out, b.data(), b.length());
|
|
|
|
*_out_Strlen = b.length();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QSharedMemory_Tr2(const char* s, const char* c, char** _out, int* _out_Strlen) {
|
2024-08-25 04:08:24 +00:00
|
|
|
QString ret = QSharedMemory::tr(s, c);
|
|
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
|
|
QByteArray b = ret.toUtf8();
|
|
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
|
|
memcpy(*_out, b.data(), b.length());
|
|
|
|
*_out_Strlen = b.length();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QSharedMemory_Tr3(const char* s, const char* c, int n, char** _out, int* _out_Strlen) {
|
2024-08-25 04:08:24 +00:00
|
|
|
QString ret = QSharedMemory::tr(s, c, static_cast<int>(n));
|
|
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
|
|
QByteArray b = ret.toUtf8();
|
|
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
|
|
memcpy(*_out, b.data(), b.length());
|
|
|
|
*_out_Strlen = b.length();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QSharedMemory_TrUtf82(const char* s, const char* c, char** _out, int* _out_Strlen) {
|
2024-08-25 04:08:24 +00:00
|
|
|
QString ret = QSharedMemory::trUtf8(s, c);
|
|
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
|
|
QByteArray b = ret.toUtf8();
|
|
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
|
|
memcpy(*_out, b.data(), b.length());
|
|
|
|
*_out_Strlen = b.length();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
void QSharedMemory_TrUtf83(const char* s, const char* c, int n, char** _out, int* _out_Strlen) {
|
2024-08-25 04:08:24 +00:00
|
|
|
QString ret = QSharedMemory::trUtf8(s, c, static_cast<int>(n));
|
|
|
|
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
|
|
|
|
QByteArray b = ret.toUtf8();
|
|
|
|
*_out = static_cast<char*>(malloc(b.length()));
|
|
|
|
memcpy(*_out, b.data(), b.length());
|
|
|
|
*_out_Strlen = b.length();
|
|
|
|
}
|
|
|
|
|
2024-08-29 07:01:51 +00:00
|
|
|
bool QSharedMemory_Create2(QSharedMemory* self, int size, uintptr_t mode) {
|
|
|
|
return self->create(static_cast<int>(size), static_cast<QSharedMemory::AccessMode>(mode));
|
|
|
|
}
|
|
|
|
|
|
|
|
bool QSharedMemory_Attach1(QSharedMemory* self, uintptr_t mode) {
|
|
|
|
return self->attach(static_cast<QSharedMemory::AccessMode>(mode));
|
|
|
|
}
|
|
|
|
|
2024-08-25 04:08:24 +00:00
|
|
|
void QSharedMemory_Delete(QSharedMemory* self) {
|
|
|
|
delete self;
|
|
|
|
}
|
|
|
|
|