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,
|
2017-08-23 16:55:37 -07:00
|
|
|
UChar,
|
2017-08-22 04:45:34 -07:00
|
|
|
Int,
|
|
|
|
UInt,
|
|
|
|
ULongLong,
|
2017-08-23 16:55:37 -07:00
|
|
|
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 {
|
2017-08-25 06:42:56 -07:00
|
|
|
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;
|
2017-08-30 12:58:01 -07:00
|
|
|
bool rustByValue;
|
2017-08-22 04:45:34 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ItemProperty {
|
|
|
|
QString name;
|
|
|
|
BindingTypeProperties type;
|
|
|
|
bool write;
|
|
|
|
bool optional;
|
2017-08-30 12:58:01 -07:00
|
|
|
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
|
|
|
};
|
|
|
|
|