rust-qt-binding-generator/src/structs.h

94 lines
1.8 KiB
C
Raw Normal View History

2017-08-22 04:45:34 -07:00
#include <QString>
#include <QByteArray>
#include <QList>
#include <QFileInfo>
#include <QDir>
2017-08-26 10:10:18 -07:00
#include <QTextStream>
#include <QCoreApplication>
2017-08-22 04:45:34 -07:00
enum class ObjectType {
Object,
List,
UniformTree
};
enum class BindingType {
Bool,
UChar,
2017-08-22 04:45:34 -07:00
Int,
UInt,
ULongLong,
Float,
2017-08-22 04:45:34 -07:00
QString,
2017-08-26 10:10:18 -07:00
QByteArray,
Object,
2017-08-22 04:45:34 -07:00
};
struct BindingTypeProperties {
BindingType type;
2017-08-22 04:45:34 -07:00
QString name;
QString cppSetType;
QString cSetType;
QString rustType;
QString rustTypeInit;
bool isComplex() const {
return name.startsWith("Q");
}
};
struct Property {
QString name;
BindingTypeProperties type;
bool write;
bool optional;
bool rustByValue;
2017-08-22 04:45:34 -07:00
};
struct ItemProperty {
QString name;
BindingTypeProperties type;
bool write;
bool optional;
bool rustByValue;
2017-08-22 04:45:34 -07:00
QList<QList<Qt::ItemDataRole>> roles;
};
struct Object {
QString name;
ObjectType type;
QList<Property> properties;
QList<ItemProperty> itemProperties;
int columnCount;
2017-08-26 10:10:18 -07:00
bool containsObject() {
for (auto p: properties) {
if (p.type.type == BindingType::Object) {
return true;
}
}
return false;
}
2017-08-22 04:45:34 -07:00
};
struct Configuration {
QFileInfo hFile;
QFileInfo cppFile;
QDir rustdir;
QString interfaceModule;
QString implementationModule;
QList<Object> objects;
bool overwriteImplementation;
2017-08-26 10:10:18 -07:00
const Object& findObject(const QString& name) const {
for (auto& o: objects) {
if (o.name == name) {
return o;
}
}
QTextStream err(stderr);
err << QCoreApplication::translate("main",
"Cannot find type %1.\n").arg(name);
err.flush();
exit(1);
}
2017-08-22 04:45:34 -07:00
};