Make sure that the optional types in the bindings are POD types

master
Jos van den Oever 2018-05-13 13:10:59 +02:00
parent 848b472c3f
commit 12cebe88bb
4 changed files with 8 additions and 13 deletions

View File

@ -14,18 +14,7 @@ namespace {
return QVariant();
}
};
struct option_QString {
public:
QString value;
bool some;
operator QVariant() const {
if (some) {
return QVariant::fromValue(value);
}
return QVariant();
}
};
static_assert(std::is_pod<option_quintptr>::value, "option_quintptr must be a POD type.");
struct option_quint64 {
public:
@ -38,6 +27,7 @@ namespace {
return QVariant();
}
};
static_assert(std::is_pod<option_quint64>::value, "option_quint64 must be a POD type.");
typedef void (*qstring_set)(QString* val, const char* utf8, int nbytes);
void set_qstring(QString* val, const char* utf8, int nbytes) {

View File

@ -958,7 +958,8 @@ void writeCpp(const Configuration& conf) {
namespace {
)").arg(conf.hFile.fileName());
for (auto option: conf.optionalTypes()) {
cpp << QString(R"(
if (option != "QString") {
cpp << QString(R"(
struct option_%1 {
public:
%1 value;
@ -970,7 +971,9 @@ namespace {
return QVariant();
}
};
static_assert(std::is_pod<option_%1>::value, "option_%1 must be a POD type.");
)").arg(option);
}
}
if (conf.types().contains("QString")) {
cpp << R"(

View File

@ -14,6 +14,7 @@ namespace {
return QVariant();
}
};
static_assert(std::is_pod<option_quintptr>::value, "option_quintptr must be a POD type.");
typedef void (*qstring_set)(QString* val, const char* utf8, int nbytes);
void set_qstring(QString* val, const char* utf8, int nbytes) {

View File

@ -14,6 +14,7 @@ namespace {
return QVariant();
}
};
static_assert(std::is_pod<option_quintptr>::value, "option_quintptr must be a POD type.");
typedef void (*qstring_set)(QString* val, const char* utf8, int nbytes);
void set_qstring(QString* val, const char* utf8, int nbytes) {