miqt/qt6/cbor/gen_qcborcommon.cpp
Jacek Sieka a0c6344ecd Avoid dependency on exported go header
The expected type of the callback is already known from the AST - this
change reduces dependency on cgo specifics and makes the generated C ABI
entirely cgo-independent - in particular, there is no need to include
`_cgo_export.h` any more.
2025-01-07 12:55:40 +01:00

40 lines
903 B
C++

#include <QCborError>
#include <QString>
#include <QByteArray>
#include <cstring>
#include <qcborcommon.h>
#include "gen_qcborcommon.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
} /* extern C */
#endif
int QCborError_ToQCborError__Code(const QCborError* self) {
QCborError::Code _ret = self->operator QCborError::Code();
return static_cast<int>(_ret);
}
struct miqt_string QCborError_ToString(const QCborError* self) {
QString _ret = self->toString();
// Convert QString from UTF-16 in C++ RAII memory to UTF-8 in manually-managed C memory
QByteArray _b = _ret.toUtf8();
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;
}
void QCborError_Delete(QCborError* self, bool isSubclass) {
if (isSubclass) {
delete dynamic_cast<QCborError*>( self );
} else {
delete self;
}
}