diff --git a/demo/src/Bindings.cpp b/demo/src/Bindings.cpp index 0fa12db..4585441 100644 --- a/demo/src/Bindings.cpp +++ b/demo/src/Bindings.cpp @@ -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::value, "option_quintptr must be a POD type."); struct option_quint64 { public: @@ -38,6 +27,7 @@ namespace { return QVariant(); } }; + static_assert(std::is_pod::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) { diff --git a/src/cpp.cpp b/src/cpp.cpp index 8522da3..841e4e1 100644 --- a/src/cpp.cpp +++ b/src/cpp.cpp @@ -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::value, "option_%1 must be a POD type."); )").arg(option); + } } if (conf.types().contains("QString")) { cpp << R"( diff --git a/tests/test_list_rust.cpp b/tests/test_list_rust.cpp index df22d67..65181fb 100644 --- a/tests/test_list_rust.cpp +++ b/tests/test_list_rust.cpp @@ -14,6 +14,7 @@ namespace { return QVariant(); } }; + static_assert(std::is_pod::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) { diff --git a/tests/test_tree_rust.cpp b/tests/test_tree_rust.cpp index 390c7d0..a823173 100644 --- a/tests/test_tree_rust.cpp +++ b/tests/test_tree_rust.cpp @@ -14,6 +14,7 @@ namespace { return QVariant(); } }; + static_assert(std::is_pod::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) {