From 2a60f0c00efa484b52bb1cf2918d3972d6f4f96a Mon Sep 17 00:00:00 2001 From: Hamed Masafi Date: Tue, 26 Feb 2019 18:23:57 +0330 Subject: [PATCH] wip:msvc phrase cast fix --- 3rdparty/serializer | 2 +- src/phrases/fieldphrase.h | 4 ++-- src/phrases/numericphrase.h | 36 +++++++++++++++------------- test/tst_datatypes/tst_datatypes.pro | 1 - test/tst_phrases/tst_phrases.cpp | 7 ++++++ 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/3rdparty/serializer b/3rdparty/serializer index 1d3495b..b3c550c 160000 --- a/3rdparty/serializer +++ b/3rdparty/serializer @@ -1 +1 @@ -Subproject commit 1d3495bed909392cdf128e8ef6f8b3986b2c09b5 +Subproject commit b3c550c5bb7c570b1b10492fcedf287c1915af39 diff --git a/src/phrases/fieldphrase.h b/src/phrases/fieldphrase.h index 9cb83ab..18a75e3 100644 --- a/src/phrases/fieldphrase.h +++ b/src/phrases/fieldphrase.h @@ -15,11 +15,11 @@ public: AbstractFieldPhrase(className, s) {} - AssignmentPhrase operator =(const T &other) { + AssignmentPhrase operator =(const QVariant &other) { return AssignmentPhrase(this, other); } - ConditionalPhrase operator ==(const T &other) { + ConditionalPhrase operator ==(const QVariant &other) { return ConditionalPhrase(this, PhraseData::Equal, other); } diff --git a/src/phrases/numericphrase.h b/src/phrases/numericphrase.h index 690fd54..ab9db31 100644 --- a/src/phrases/numericphrase.h +++ b/src/phrases/numericphrase.h @@ -6,14 +6,16 @@ NUT_BEGIN_NAMESPACE -#define SPECIALIZATION_NUMERIC_MEMBER(type, op, cond) \ - ConditionalPhrase operator op(const QVariant &other) \ -{ \ - return ConditionalPhrase(this, cond, other); \ - } +#define SPECIALIZATION_NUMERIC_MEMBER(type, op, cond) \ + ConditionalPhrase operator op(const QVariant &other) \ +{ \ + return ConditionalPhrase(this, cond, other); \ +} template -class FieldPhrase::value>::type> +class FieldPhrase::value || std::is_integral::value + >::type> : public AbstractFieldPhrase { public: @@ -21,17 +23,6 @@ public: AbstractFieldPhrase(className, s) {} - SPECIALIZATION_NUMERIC_MEMBER(type, <, PhraseData::Less) - SPECIALIZATION_NUMERIC_MEMBER(type, <=, PhraseData::LessEqual) - SPECIALIZATION_NUMERIC_MEMBER(type, >, PhraseData::Greater) - SPECIALIZATION_NUMERIC_MEMBER(type, >=, PhraseData::GreaterEqual) - SPECIALIZATION_NUMERIC_MEMBER(type, %, PhraseData::Mod) - - SPECIALIZATION_NUMERIC_MEMBER(type, +, PhraseData::Add) - SPECIALIZATION_NUMERIC_MEMBER(type, -, PhraseData::Minus) - SPECIALIZATION_NUMERIC_MEMBER(type, *, PhraseData::Multiple) - SPECIALIZATION_NUMERIC_MEMBER(type, /, PhraseData::Divide) - AssignmentPhrase operator =(const QVariant &other) { return AssignmentPhrase(this, other); } @@ -59,6 +50,17 @@ public: { return ConditionalPhrase(this, PhraseData::Minus, 1); } + + SPECIALIZATION_NUMERIC_MEMBER(type, <, PhraseData::Less) + SPECIALIZATION_NUMERIC_MEMBER(type, <=, PhraseData::LessEqual) + SPECIALIZATION_NUMERIC_MEMBER(type, >, PhraseData::Greater) + SPECIALIZATION_NUMERIC_MEMBER(type, >=, PhraseData::GreaterEqual) + SPECIALIZATION_NUMERIC_MEMBER(type, %, PhraseData::Mod) + + SPECIALIZATION_NUMERIC_MEMBER(type, +, PhraseData::Add) + SPECIALIZATION_NUMERIC_MEMBER(type, -, PhraseData::Minus) + SPECIALIZATION_NUMERIC_MEMBER(type, *, PhraseData::Multiple) + SPECIALIZATION_NUMERIC_MEMBER(type, /, PhraseData::Divide) }; #define SPECIALIZATION_NUMERIC_TYPE(type) \ diff --git a/test/tst_datatypes/tst_datatypes.pro b/test/tst_datatypes/tst_datatypes.pro index fb34585..48da9a6 100644 --- a/test/tst_datatypes/tst_datatypes.pro +++ b/test/tst_datatypes/tst_datatypes.pro @@ -1,5 +1,4 @@ QT += testlib sql -QT -= gui TARGET = tst_datatypes TEMPLATE = app diff --git a/test/tst_phrases/tst_phrases.cpp b/test/tst_phrases/tst_phrases.cpp index 0090f43..d9d26c0 100644 --- a/test/tst_phrases/tst_phrases.cpp +++ b/test/tst_phrases/tst_phrases.cpp @@ -27,6 +27,7 @@ void MainTest::no1() void MainTest::numeric() { FieldPhrase n("main", "int"); + FieldPhrase f("main", "float"); auto p1 = n == 1; auto p2 = n <= 1; @@ -43,6 +44,12 @@ void MainTest::numeric() auto p13 = ++n; auto p14 = n++; auto p15 = n.between(1, 2); + auto p16 = n + 1 < n + 2; + + auto p21 = p1 && p2; + auto p22 = p3 == p4; + auto p23 = f == n + 1; + } void MainTest::string()