File indexing completed on 2024-04-14 15:48:45

0001 /* generated by rust_qt_binding_generator */
0002 #include "test_object_types_rust.h"
0003 
0004 namespace {
0005 
0006     struct option_bool {
0007     public:
0008         bool value;
0009         bool some;
0010         operator QVariant() const {
0011             if (some) {
0012                 return QVariant::fromValue(value);
0013             }
0014             return QVariant();
0015         }
0016     };
0017     static_assert(std::is_pod<option_bool>::value, "option_bool must be a POD type.");
0018 
0019     struct option_quint64 {
0020     public:
0021         quint64 value;
0022         bool some;
0023         operator QVariant() const {
0024             if (some) {
0025                 return QVariant::fromValue(value);
0026             }
0027             return QVariant();
0028         }
0029     };
0030     static_assert(std::is_pod<option_quint64>::value, "option_quint64 must be a POD type.");
0031 
0032     typedef void (*qstring_set)(QString* val, const char* utf8, int nbytes);
0033     void set_qstring(QString* val, const char* utf8, int nbytes) {
0034         *val = QString::fromUtf8(utf8, nbytes);
0035     }
0036 
0037     typedef void (*qbytearray_set)(QByteArray* val, const char* bytes, int nbytes);
0038     void set_qbytearray(QByteArray* v, const char* bytes, int nbytes) {
0039         if (v->isNull() && nbytes == 0) {
0040             *v = QByteArray(bytes, nbytes);
0041         } else {
0042             v->truncate(0);
0043             v->append(bytes, nbytes);
0044         }
0045     }
0046     inline void objectBooleanChanged(Object* o)
0047     {
0048         Q_EMIT o->booleanChanged();
0049     }
0050     inline void objectBytearrayChanged(Object* o)
0051     {
0052         Q_EMIT o->bytearrayChanged();
0053     }
0054     inline void objectF32Changed(Object* o)
0055     {
0056         Q_EMIT o->f32Changed();
0057     }
0058     inline void objectF64Changed(Object* o)
0059     {
0060         Q_EMIT o->f64Changed();
0061     }
0062     inline void objectI16Changed(Object* o)
0063     {
0064         Q_EMIT o->i16Changed();
0065     }
0066     inline void objectI32Changed(Object* o)
0067     {
0068         Q_EMIT o->i32Changed();
0069     }
0070     inline void objectI64Changed(Object* o)
0071     {
0072         Q_EMIT o->i64Changed();
0073     }
0074     inline void objectI8Changed(Object* o)
0075     {
0076         Q_EMIT o->i8Changed();
0077     }
0078     inline void objectOptionalBooleanChanged(Object* o)
0079     {
0080         Q_EMIT o->optionalBooleanChanged();
0081     }
0082     inline void objectOptionalBytearrayChanged(Object* o)
0083     {
0084         Q_EMIT o->optionalBytearrayChanged();
0085     }
0086     inline void objectOptionalStringChanged(Object* o)
0087     {
0088         Q_EMIT o->optionalStringChanged();
0089     }
0090     inline void objectOptionalU64Changed(Object* o)
0091     {
0092         Q_EMIT o->optionalU64Changed();
0093     }
0094     inline void objectStringChanged(Object* o)
0095     {
0096         Q_EMIT o->stringChanged();
0097     }
0098     inline void objectStringByFunctionChanged(Object* o)
0099     {
0100         Q_EMIT o->stringByFunctionChanged();
0101     }
0102     inline void objectU16Changed(Object* o)
0103     {
0104         Q_EMIT o->u16Changed();
0105     }
0106     inline void objectU32Changed(Object* o)
0107     {
0108         Q_EMIT o->u32Changed();
0109     }
0110     inline void objectU64Changed(Object* o)
0111     {
0112         Q_EMIT o->u64Changed();
0113     }
0114     inline void objectU8Changed(Object* o)
0115     {
0116         Q_EMIT o->u8Changed();
0117     }
0118 }
0119 extern "C" {
0120     Object::Private* object_new(Object*, void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*), void (*)(Object*));
0121     void object_free(Object::Private*);
0122     bool object_boolean_get(const Object::Private*);
0123     void object_boolean_set(Object::Private*, bool);
0124     void object_bytearray_get(const Object::Private*, QByteArray*, qbytearray_set);
0125     void object_bytearray_set(Object::Private*, const char* bytes, int len);
0126     float object_f32_get(const Object::Private*);
0127     void object_f32_set(Object::Private*, float);
0128     double object_f64_get(const Object::Private*);
0129     void object_f64_set(Object::Private*, double);
0130     qint16 object_i16_get(const Object::Private*);
0131     void object_i16_set(Object::Private*, qint16);
0132     qint32 object_i32_get(const Object::Private*);
0133     void object_i32_set(Object::Private*, qint32);
0134     qint64 object_i64_get(const Object::Private*);
0135     void object_i64_set(Object::Private*, qint64);
0136     qint8 object_i8_get(const Object::Private*);
0137     void object_i8_set(Object::Private*, qint8);
0138     option_bool object_optional_boolean_get(const Object::Private*);
0139     void object_optional_boolean_set(Object::Private*, bool);
0140     void object_optional_boolean_set_none(Object::Private*);
0141     void object_optional_bytearray_get(const Object::Private*, QByteArray*, qbytearray_set);
0142     void object_optional_bytearray_set(Object::Private*, const char* bytes, int len);
0143     void object_optional_bytearray_set_none(Object::Private*);
0144     void object_optional_string_get(const Object::Private*, QString*, qstring_set);
0145     void object_optional_string_set(Object::Private*, const ushort *str, int len);
0146     void object_optional_string_set_none(Object::Private*);
0147     option_quint64 object_optional_u64_get(const Object::Private*);
0148     void object_optional_u64_set(Object::Private*, quint64);
0149     void object_optional_u64_set_none(Object::Private*);
0150     void object_string_get(const Object::Private*, QString*, qstring_set);
0151     void object_string_set(Object::Private*, const ushort *str, int len);
0152     void object_string_by_function_get(const Object::Private*, QString*, qstring_set);
0153     void object_string_by_function_set(Object::Private*, const ushort *str, int len);
0154     quint16 object_u16_get(const Object::Private*);
0155     void object_u16_set(Object::Private*, quint16);
0156     quint32 object_u32_get(const Object::Private*);
0157     void object_u32_set(Object::Private*, quint32);
0158     quint64 object_u64_get(const Object::Private*);
0159     void object_u64_set(Object::Private*, quint64);
0160     quint8 object_u8_get(const Object::Private*);
0161     void object_u8_set(Object::Private*, quint8);
0162 };
0163 
0164 Object::Object(bool /*owned*/, QObject *parent):
0165     QObject(parent),
0166     m_d(nullptr),
0167     m_ownsPrivate(false)
0168 {
0169 }
0170 
0171 Object::Object(QObject *parent):
0172     QObject(parent),
0173     m_d(object_new(this,
0174         objectBooleanChanged,
0175         objectBytearrayChanged,
0176         objectF32Changed,
0177         objectF64Changed,
0178         objectI16Changed,
0179         objectI32Changed,
0180         objectI64Changed,
0181         objectI8Changed,
0182         objectOptionalBooleanChanged,
0183         objectOptionalBytearrayChanged,
0184         objectOptionalStringChanged,
0185         objectOptionalU64Changed,
0186         objectStringChanged,
0187         objectStringByFunctionChanged,
0188         objectU16Changed,
0189         objectU32Changed,
0190         objectU64Changed,
0191         objectU8Changed)),
0192     m_ownsPrivate(true)
0193 {
0194 }
0195 
0196 Object::~Object() {
0197     if (m_ownsPrivate) {
0198         object_free(m_d);
0199     }
0200 }
0201 bool Object::boolean() const
0202 {
0203     return object_boolean_get(m_d);
0204 }
0205 void Object::setBoolean(bool v) {
0206     object_boolean_set(m_d, v);
0207 }
0208 QByteArray Object::bytearray() const
0209 {
0210     QByteArray v;
0211     object_bytearray_get(m_d, &v, set_qbytearray);
0212     return v;
0213 }
0214 void Object::setBytearray(const QByteArray& v) {
0215     object_bytearray_set(m_d, v.data(), v.size());
0216 }
0217 float Object::f32() const
0218 {
0219     return object_f32_get(m_d);
0220 }
0221 void Object::setF32(float v) {
0222     object_f32_set(m_d, v);
0223 }
0224 double Object::f64() const
0225 {
0226     return object_f64_get(m_d);
0227 }
0228 void Object::setF64(double v) {
0229     object_f64_set(m_d, v);
0230 }
0231 qint16 Object::i16() const
0232 {
0233     return object_i16_get(m_d);
0234 }
0235 void Object::setI16(qint16 v) {
0236     object_i16_set(m_d, v);
0237 }
0238 qint32 Object::i32() const
0239 {
0240     return object_i32_get(m_d);
0241 }
0242 void Object::setI32(qint32 v) {
0243     object_i32_set(m_d, v);
0244 }
0245 qint64 Object::i64() const
0246 {
0247     return object_i64_get(m_d);
0248 }
0249 void Object::setI64(qint64 v) {
0250     object_i64_set(m_d, v);
0251 }
0252 qint8 Object::i8() const
0253 {
0254     return object_i8_get(m_d);
0255 }
0256 void Object::setI8(qint8 v) {
0257     object_i8_set(m_d, v);
0258 }
0259 QVariant Object::optionalBoolean() const
0260 {
0261     QVariant v;
0262     auto r = object_optional_boolean_get(m_d);
0263     if (r.some) {
0264         v.setValue(r.value);
0265     }
0266     return r;
0267 }
0268 void Object::setOptionalBoolean(const QVariant& v) {
0269     if (v.isNull() || !v.canConvert<bool>()) {
0270         object_optional_boolean_set_none(m_d);
0271     } else {
0272         object_optional_boolean_set(m_d, v.value<bool>());
0273     }
0274 }
0275 QByteArray Object::optionalBytearray() const
0276 {
0277     QByteArray v;
0278     object_optional_bytearray_get(m_d, &v, set_qbytearray);
0279     return v;
0280 }
0281 void Object::setOptionalBytearray(const QByteArray& v) {
0282     if (v.isNull()) {
0283         object_optional_bytearray_set_none(m_d);
0284     } else {
0285     object_optional_bytearray_set(m_d, v.data(), v.size());
0286     }
0287 }
0288 QString Object::optionalString() const
0289 {
0290     QString v;
0291     object_optional_string_get(m_d, &v, set_qstring);
0292     return v;
0293 }
0294 void Object::setOptionalString(const QString& v) {
0295     if (v.isNull()) {
0296         object_optional_string_set_none(m_d);
0297     } else {
0298     object_optional_string_set(m_d, reinterpret_cast<const ushort*>(v.data()), v.size());
0299     }
0300 }
0301 QVariant Object::optionalU64() const
0302 {
0303     QVariant v;
0304     auto r = object_optional_u64_get(m_d);
0305     if (r.some) {
0306         v.setValue(r.value);
0307     }
0308     return r;
0309 }
0310 void Object::setOptionalU64(const QVariant& v) {
0311     if (v.isNull() || !v.canConvert<quint64>()) {
0312         object_optional_u64_set_none(m_d);
0313     } else {
0314         object_optional_u64_set(m_d, v.value<quint64>());
0315     }
0316 }
0317 QString Object::string() const
0318 {
0319     QString v;
0320     object_string_get(m_d, &v, set_qstring);
0321     return v;
0322 }
0323 void Object::setString(const QString& v) {
0324     object_string_set(m_d, reinterpret_cast<const ushort*>(v.data()), v.size());
0325 }
0326 QString Object::stringByFunction() const
0327 {
0328     QString v;
0329     object_string_by_function_get(m_d, &v, set_qstring);
0330     return v;
0331 }
0332 void Object::setStringByFunction(const QString& v) {
0333     object_string_by_function_set(m_d, reinterpret_cast<const ushort*>(v.data()), v.size());
0334 }
0335 quint16 Object::u16() const
0336 {
0337     return object_u16_get(m_d);
0338 }
0339 void Object::setU16(quint16 v) {
0340     object_u16_set(m_d, v);
0341 }
0342 quint32 Object::u32() const
0343 {
0344     return object_u32_get(m_d);
0345 }
0346 void Object::setU32(quint32 v) {
0347     object_u32_set(m_d, v);
0348 }
0349 quint64 Object::u64() const
0350 {
0351     return object_u64_get(m_d);
0352 }
0353 void Object::setU64(quint64 v) {
0354     object_u64_set(m_d, v);
0355 }
0356 quint8 Object::u8() const
0357 {
0358     return object_u8_get(m_d);
0359 }
0360 void Object::setU8(quint8 v) {
0361     object_u8_set(m_d, v);
0362 }