File indexing completed on 2024-02-25 05:56:30

0001 /* generated by rust_qt_binding_generator */
0002 #include "test_objects_rust.h"
0003 
0004 namespace {
0005 
0006     typedef void (*qstring_set)(QString* val, const char* utf8, int nbytes);
0007     void set_qstring(QString* val, const char* utf8, int nbytes) {
0008         *val = QString::fromUtf8(utf8, nbytes);
0009     }
0010     inline void innerObjectDescriptionChanged(InnerObject* o)
0011     {
0012         Q_EMIT o->descriptionChanged();
0013     }
0014 }
0015 extern "C" {
0016     Group::Private* group_new(Group*, Person*, InnerObject*, void (*)(InnerObject*));
0017     void group_free(Group::Private*);
0018     Person::Private* group_person_get(const Group::Private*);
0019 };
0020 
0021 extern "C" {
0022     InnerObject::Private* inner_object_new(InnerObject*, void (*)(InnerObject*));
0023     void inner_object_free(InnerObject::Private*);
0024     void inner_object_description_get(const InnerObject::Private*, QString*, qstring_set);
0025     void inner_object_description_set(InnerObject::Private*, const ushort *str, int len);
0026 };
0027 
0028 extern "C" {
0029     Person::Private* person_new(Person*, InnerObject*, void (*)(InnerObject*));
0030     void person_free(Person::Private*);
0031     InnerObject::Private* person_object_get(const Person::Private*);
0032 };
0033 
0034 Group::Group(bool /*owned*/, QObject *parent):
0035     QObject(parent),
0036     m_person(new Person(false, this)),
0037     m_d(nullptr),
0038     m_ownsPrivate(false)
0039 {
0040 }
0041 
0042 Group::Group(QObject *parent):
0043     QObject(parent),
0044     m_person(new Person(false, this)),
0045     m_d(group_new(this, m_person, m_person->m_object,
0046         innerObjectDescriptionChanged)),
0047     m_ownsPrivate(true)
0048 {
0049     m_person->m_d = group_person_get(m_d);
0050     m_person->m_object->m_d = person_object_get(m_person->m_d);
0051 }
0052 
0053 Group::~Group() {
0054     if (m_ownsPrivate) {
0055         group_free(m_d);
0056     }
0057 }
0058 const Person* Group::person() const
0059 {
0060     return m_person;
0061 }
0062 Person* Group::person()
0063 {
0064     return m_person;
0065 }
0066 InnerObject::InnerObject(bool /*owned*/, QObject *parent):
0067     QObject(parent),
0068     m_d(nullptr),
0069     m_ownsPrivate(false)
0070 {
0071 }
0072 
0073 InnerObject::InnerObject(QObject *parent):
0074     QObject(parent),
0075     m_d(inner_object_new(this,
0076         innerObjectDescriptionChanged)),
0077     m_ownsPrivate(true)
0078 {
0079 }
0080 
0081 InnerObject::~InnerObject() {
0082     if (m_ownsPrivate) {
0083         inner_object_free(m_d);
0084     }
0085 }
0086 QString InnerObject::description() const
0087 {
0088     QString v;
0089     inner_object_description_get(m_d, &v, set_qstring);
0090     return v;
0091 }
0092 void InnerObject::setDescription(const QString& v) {
0093     inner_object_description_set(m_d, reinterpret_cast<const ushort*>(v.data()), v.size());
0094 }
0095 Person::Person(bool /*owned*/, QObject *parent):
0096     QObject(parent),
0097     m_object(new InnerObject(false, this)),
0098     m_d(nullptr),
0099     m_ownsPrivate(false)
0100 {
0101 }
0102 
0103 Person::Person(QObject *parent):
0104     QObject(parent),
0105     m_object(new InnerObject(false, this)),
0106     m_d(person_new(this, m_object,
0107         innerObjectDescriptionChanged)),
0108     m_ownsPrivate(true)
0109 {
0110     m_object->m_d = person_object_get(m_d);
0111 }
0112 
0113 Person::~Person() {
0114     if (m_ownsPrivate) {
0115         person_free(m_d);
0116     }
0117 }
0118 const InnerObject* Person::object() const
0119 {
0120     return m_object;
0121 }
0122 InnerObject* Person::object()
0123 {
0124     return m_object;
0125 }