Browse Source

Migrate to explicit type for fixed integers

- Create transparent class to hack rtti and QMetaType system
- Migrate all fixed integers to transparent class definition
Alexey Edelev 6 years ago
parent
commit
1a4e39a44a
4 changed files with 114 additions and 156 deletions
  1. 60 100
      src/protobuf/protobufobject.cpp
  2. 24 42
      src/protobuf/protobufobject_p.h
  3. 20 4
      src/protobuf/qtprotobuftypes.h
  4. 10 10
      tests/simpletest.cpp

+ 60 - 100
src/protobuf/protobufobject.cpp

@@ -41,30 +41,6 @@ namespace {
 
     static const char *sint64ListTypeNameP = "qtprotobuf::sint64List";
     static const char *sint64ListTypeName = "sint64List";
-
-    static const char *fint32TypeNameP = "qtprotobuf::fint32";
-    static const char *fint32TypeName = "fint32";
-
-    static const char *fint64TypeNameP = "qtprotobuf::fint64";
-    static const char *fint64TypeName = "fint64";
-
-    static const char *sfint32TypeNameP = "qtprotobuf::sfint32";
-    static const char *sfint32TypeName = "sfint32";
-
-    static const char *sfint64TypeNameP = "qtprotobuf::sfint64";
-    static const char *sfint64TypeName = "sfint64";
-
-    static const char *fint32ListTypeNameP = "qtprotobuf::fint32List";
-    static const char *fint32ListTypeName = "fint32List";
-
-    static const char *fint64ListTypeNameP = "qtprotobuf::fint64List";
-    static const char *fint64ListTypeName = "fint64List";
-
-    static const char *sfint32ListTypeNameP = "qtprotobuf::sfint32List";
-    static const char *sfint32ListTypeName = "sfint32List";
-
-    static const char *sfint64ListTypeNameP = "qtprotobuf::sfint64List";
-    static const char *sfint64ListTypeName = "sfint64List";
 }
 
 QByteArray ProtobufObjectPrivate::serializeValue(const QVariant &propertyValue, int fieldIndex, const QMetaProperty &metaProperty)
@@ -81,10 +57,6 @@ QByteArray ProtobufObjectPrivate::serializeValue(const QVariant &propertyValue,
         if (typeName == sint32TypeNameP
                 || typeName == sint32TypeName) {
             result.append(serializeVarintZigZag(propertyValue.toInt()));
-        } else if (typeName == sfint32TypeNameP
-                   || typeName == sfint32TypeName) {
-            type = Fixed32;
-            result.append(serializeFixed(propertyValue.toInt()));
         } else {
             result.append(serializeVarint(propertyValue.toLongLong()));
         }
@@ -97,10 +69,6 @@ QByteArray ProtobufObjectPrivate::serializeValue(const QVariant &propertyValue,
         if (typeName == sint64TypeNameP
                 || typeName == sint64TypeName) {
             result.append(serializeVarintZigZag(propertyValue.toLongLong()));
-        } else if (typeName == sfint64TypeNameP
-                   || typeName == sfint64TypeName) {
-            type = Fixed64;
-            result.append(serializeFixed(propertyValue.toLongLong()));
         } else {
             result.append(serializeVarint(propertyValue.toLongLong()));
         }
@@ -137,32 +105,19 @@ QByteArray ProtobufObjectPrivate::serializeValue(const QVariant &propertyValue,
             type = Varint;
             result.append(serializeVarint(propertyValue.toLongLong()));
         } else {
-            type = LengthDelimited;
-            result.append(serializeUserType(propertyValue, fieldIndex, typeName));
+            result.append(serializeUserType(propertyValue, fieldIndex, typeName, type));
         }
         break;
     case QMetaType::UInt:
-        if (typeName == fint32TypeNameP
-                || typeName == fint32TypeName) {
-            type = Fixed32;
-            result.append(serializeFixed(propertyValue.toUInt()));
-        } else {
-            type = Varint;
-            result.append(serializeVarint(propertyValue.toUInt()));
-        }
+        type = Varint;
+        result.append(serializeVarint(propertyValue.toUInt()));
         if (0 == result.size()) {
             fieldIndex = NotUsedFieldIndex;
         }
         break;
     case QMetaType::ULongLong:
-        if (typeName == fint64TypeNameP
-                || typeName == fint64TypeName) {
-            type = Fixed64;
-            result.append(serializeFixed(propertyValue.toULongLong()));
-        } else {
-            type = Varint;
-            result.append(serializeVarint(propertyValue.toULongLong()));
-        }
+        type = Varint;
+        result.append(serializeVarint(propertyValue.toULongLong()));
         if (0 == result.size()) {
             fieldIndex = NotUsedFieldIndex;
         }
@@ -184,9 +139,11 @@ QByteArray ProtobufObjectPrivate::serializeValue(const QVariant &propertyValue,
     return result;
 }
 
-QByteArray ProtobufObjectPrivate::serializeUserType(const QVariant &propertyValue, int &fieldIndex, const QLatin1Literal &typeName)
+QByteArray ProtobufObjectPrivate::serializeUserType(const QVariant &propertyValue, int &fieldIndex, const QLatin1Literal &typeName, WireTypes &type)
 {
+
     qProtoDebug() << __func__ << "propertyValue" << propertyValue << "fieldIndex" << fieldIndex;
+    type = LengthDelimited;
     int userType = propertyValue.userType();
 
     //First looking type serializer in registred serializers
@@ -195,24 +152,45 @@ QByteArray ProtobufObjectPrivate::serializeUserType(const QVariant &propertyValu
         return (it->second).serializer(propertyValue, fieldIndex);
     }
 
-    //Check if it's special list
+    //Check if it's special type
+    if (userType == qMetaTypeId<fint32>()) {
+        type = Fixed32;
+        return serializeFixed(propertyValue.value<fint32>());
+    }
+    if (userType == qMetaTypeId<fint64>()) {
+        type = Fixed64;
+        return serializeFixed(propertyValue.value<fint64>());
+    }
+    if (userType == qMetaTypeId<sfint32>()) {
+        type = Fixed32;
+        return serializeFixed(propertyValue.value<sfint32>());
+    }
+    if (userType == qMetaTypeId<sfint64>()) {
+        type = Fixed64;
+        return serializeFixed(propertyValue.value<sfint64>());
+    }
+    if (userType == qMetaTypeId<fint32List>()) {
+        return serializeListType(propertyValue.value<fint32List>(), fieldIndex);
+    }
+    if (userType == qMetaTypeId<fint64List>()) {
+        return serializeListType(propertyValue.value<fint64List>(), fieldIndex);
+    }
+    if (userType == qMetaTypeId<sfint32List>()) {
+        return serializeListType(propertyValue.value<sfint32List>(), fieldIndex);
+    }
+    if (userType == qMetaTypeId<sfint64List>()) {
+        return serializeListType(propertyValue.value<sfint64List>(), fieldIndex);
+    }
+
     if (userType == qMetaTypeId<int32List>()) {
         if (typeName == sint32ListTypeNameP
                 || typeName == sint32ListTypeName) {
             return serializeListTypeZigZag(propertyValue.value<sint32List>(), fieldIndex);
         }
-        if (typeName == sfint32ListTypeNameP
-                || typeName == sfint32ListTypeName) {
-            return serializeFixedListType(propertyValue.value<sfint32List>(), fieldIndex);
-        }
         return serializeListType(propertyValue.value<int32List>(), fieldIndex);
     }
 
     if (userType == qMetaTypeId<uint32List>()) {
-        if (typeName == fint32ListTypeNameP
-                || typeName == fint32ListTypeName) {
-            return serializeFixedListType(propertyValue.value<fint32List>(), fieldIndex);
-        }
         return serializeListType(propertyValue.value<uint32List>(), fieldIndex);
     }
 
@@ -221,18 +199,10 @@ QByteArray ProtobufObjectPrivate::serializeUserType(const QVariant &propertyValu
                 || typeName == sint64ListTypeName) {
             return serializeListTypeZigZag(propertyValue.value<sint64List>(), fieldIndex);
         }
-        if (typeName == sfint64ListTypeNameP
-                || typeName == sfint64ListTypeName) {
-            return serializeFixedListType(propertyValue.value<sfint64List>(), fieldIndex);
-        }
         return serializeListType(propertyValue.value<int64List>(), fieldIndex);
     }
 
     if (userType == qMetaTypeId<uint64List>()) {
-        if (typeName == fint64ListTypeNameP
-                || typeName == fint64ListTypeName) {
-            return serializeFixedListType(propertyValue.value<fint64List>(), fieldIndex);
-        }
         return serializeListType(propertyValue.value<uint64List>(), fieldIndex);
     }
 
@@ -255,18 +225,10 @@ void ProtobufObjectPrivate::deserializeProperty(WireTypes wireType, const QMetaP
     int type = metaProperty.type();
     switch (type) {
     case QMetaType::UInt:
-        if (wireType == Fixed32) {
-            newPropertyValue = deserializeFixed<fint32>(it);
-        } else {
-            newPropertyValue = deserializeVarint<uint32>(it);
-        }
+        newPropertyValue = deserializeVarint<uint32>(it);
         break;
     case QMetaType::ULongLong:
-        if (wireType == Fixed64) {
-            newPropertyValue = deserializeFixed<fint64>(it);
-        } else {
-            newPropertyValue = deserializeVarint<uint64>(it);
-        }
+        newPropertyValue = deserializeVarint<uint64>(it);
         break;
     case QMetaType::Float:
         newPropertyValue = deserializeFixed<float>(it);
@@ -275,9 +237,7 @@ void ProtobufObjectPrivate::deserializeProperty(WireTypes wireType, const QMetaP
         newPropertyValue = deserializeFixed<double>(it);
         break;
     case QMetaType::Int:
-        if (wireType == Fixed32) {
-            newPropertyValue = deserializeFixed<sfint32>(it);
-        } else if (typeName == sint32TypeNameP
+        if (typeName == sint32TypeNameP
                    || typeName == sint32TypeName) {
             newPropertyValue = deserializeVarintZigZag<sint32>(it);
         } else {
@@ -341,13 +301,26 @@ void ProtobufObjectPrivate::deserializeUserType(const QMetaProperty &metaType, Q
         return;
     }
 
-    if (userType == qMetaTypeId<int32List>()) {
+    if (userType == qMetaTypeId<fint32>()) {
+        newValue = deserializeFixed<fint32>(it);
+    } else if (userType == qMetaTypeId<fint64>()) {
+        newValue = deserializeFixed<fint64>(it);
+    } else if (userType == qMetaTypeId<sfint32>()) {
+        newValue = deserializeFixed<sfint32>(it);
+    } else if (userType == qMetaTypeId<sfint64>()) {
+        newValue = deserializeFixed<sfint64>(it);
+    } else if (userType == qMetaTypeId<fint32List>()) {
+        newValue = deserializeListType<fint32>(it);
+    } else if (userType == qMetaTypeId<fint64List>()) {
+        newValue = deserializeListType<fint64>(it);
+    } else if(userType == qMetaTypeId<sfint32List>()) {
+        newValue = deserializeListType<sfint32>(it);
+    } else if(userType == qMetaTypeId<sfint64List>()) {
+        newValue = deserializeListType<sfint64>(it);
+    } else if (userType == qMetaTypeId<int32List>()) {
         if (typeName == sint32ListTypeNameP
                 || typeName == sint32ListTypeName) {
             newValue = deserializeVarintListTypeZigZag<int32>(it);
-        } else if (typeName == sfint32ListTypeNameP
-                   || typeName == sfint32ListTypeName) {
-            newValue = deserializeListType<sfint32>(it);
         } else {
             newValue = deserializeVarintListType<int32>(it);
         }
@@ -355,26 +328,13 @@ void ProtobufObjectPrivate::deserializeUserType(const QMetaProperty &metaType, Q
         if (typeName == sint64ListTypeNameP
                 || typeName == sint64ListTypeName) {
             newValue = deserializeVarintListTypeZigZag<int64>(it);
-        } else if (typeName == sfint64ListTypeNameP
-                   || typeName == sfint64ListTypeName) {
-            newValue = deserializeListType<sfint64>(it);
         } else {
             newValue = deserializeVarintListType<int64>(it);
         }
     } else if (userType == qMetaTypeId<uint32List>()) {
-        if (typeName == fint32ListTypeNameP
-                           || typeName == fint32ListTypeName) {
-            newValue = deserializeListType<fint32>(it);
-        } else {
-            newValue = deserializeVarintListType<uint32>(it);
-        }
+        newValue = deserializeVarintListType<uint32>(it);
     } else if (userType == qMetaTypeId<uint64List>()) {
-        if (typeName == fint64ListTypeNameP
-                           || typeName == fint64ListTypeName) {
-            newValue = deserializeListType<fint64>(it);
-        } else {
-            newValue = deserializeVarintListType<uint64>(it);
-        }
+        newValue = deserializeVarintListType<uint64>(it);
     } else if (userType == qMetaTypeId<FloatList>()) {
         newValue = deserializeListType<float>(it);
     } else if (userType == qMetaTypeId<DoubleList>()) {

+ 24 - 42
src/protobuf/protobufobject_p.h

@@ -73,7 +73,7 @@ public:
     inline static bool decodeHeaderByte(unsigned char typeByte, int &fieldIndex, WireTypes &wireType);
 
     static QByteArray serializeValue(const QVariant &propertyValue, int fieldIndex, const QMetaProperty &metaProperty);
-    static QByteArray serializeUserType(const QVariant &propertyValue, int &fieldIndex, const QLatin1Literal &typeName);
+    static QByteArray serializeUserType(const QVariant &propertyValue, int &fieldIndex, const QLatin1Literal &typeName, WireTypes &type);
 
     void deserializeProperty(WireTypes wireType, const QMetaProperty &metaProperty, QByteArray::const_iterator &it);
     void deserializeUserType(const QMetaProperty &metaType, QByteArray::const_iterator &it, QVariant &newValue);
@@ -95,27 +95,6 @@ public:
         return result;
     }
 
-    template<typename V,
-             typename std::enable_if_t<std::is_integral<V>::value, int> = 0>
-    static QByteArray serializeListType(const QList<V> &listValue, int &outFieldIndex) {
-        qProtoDebug() << __func__ << "listValue.count" << listValue.count() << "outFiledIndex" << outFieldIndex;
-
-        if (listValue.count() <= 0) {
-            outFieldIndex = NotUsedFieldIndex;
-            return QByteArray();
-        }
-
-        QByteArray serializedList;
-        std::function<QByteArray(V)> serializer;
-        serializer = ProtobufObjectPrivate::serializeVarint<V>;
-        for (auto &value : listValue) {
-            serializedList.append(serializer(value));
-        }
-        //If internal field type is not LengthDelimited, exact amount of fields to be specified
-        serializedList.prepend(serializeVarintZero(static_cast<unsigned int>(serializedList.size())));
-        return serializedList;
-    }
-
     template<typename V,
              typename std::enable_if_t<std::is_signed<V>::value, int> = 0>
     static QByteArray serializeListTypeZigZag(const QList<V> &listValue, int &outFieldIndex) {
@@ -136,7 +115,7 @@ public:
     }
 
     template<typename V,
-             typename std::enable_if_t<std::is_floating_point<V>::value, int> = 0>
+             typename std::enable_if_t<std::is_integral<V>::value, int> = 0>
     static QByteArray serializeListType(const QList<V> &listValue, int &outFieldIndex) {
         qProtoDebug() << __func__ << "listValue.count" << listValue.count() << "outFiledIndex" << outFieldIndex;
 
@@ -144,9 +123,12 @@ public:
             outFieldIndex = NotUsedFieldIndex;
             return QByteArray();
         }
+
         QByteArray serializedList;
+        std::function<QByteArray(V)> serializer;
+        serializer = ProtobufObjectPrivate::serializeVarint<V>;
         for (auto &value : listValue) {
-            serializedList.append(serializeFixed(value));
+            serializedList.append(serializer(value));
         }
         //If internal field type is not LengthDelimited, exact amount of fields to be specified
         serializedList.prepend(serializeVarintZero(static_cast<unsigned int>(serializedList.size())));
@@ -154,11 +136,12 @@ public:
     }
 
     template<typename V,
-             typename std::enable_if_t<std::is_same<V, unsigned int>::value
-                                       || std::is_same<V, qulonglong>::value
-                                       || std::is_same<V, int>::value
-                                       || std::is_same<V, qlonglong>::value, int> = 0>
-    static QByteArray serializeFixedListType(const QList<V> &listValue, int &outFieldIndex) {
+             typename std::enable_if_t<std::is_floating_point<V>::value
+                                       || std::is_same<V, fint32>::value
+                                       || std::is_same<V, fint64>::value
+                                       || std::is_same<V, sfint32>::value
+                                       || std::is_same<V, sfint64>::value, int> = 0>
+    static QByteArray serializeListType(const QList<V> &listValue, int &outFieldIndex) {
         qProtoDebug() << __func__ << "listValue.count" << listValue.count() << "outFiledIndex" << outFieldIndex;
 
         if (listValue.count() <= 0) {
@@ -220,10 +203,10 @@ public:
 
     template <typename V,
               typename std::enable_if_t<std::is_floating_point<V>::value
-                                        || std::is_same<V, unsigned int>::value
-                                        || std::is_same<V, qulonglong>::value
-                                        || std::is_same<V, int>::value
-                                        || std::is_same<V, qlonglong>::value, int> = 0>
+                                        || std::is_same<V, fint32>::value
+                                        || std::is_same<V, fint64>::value
+                                        || std::is_same<V, sfint32>::value
+                                        || std::is_same<V, sfint64>::value, int> = 0>
     static QByteArray serializeFixed(V value) {
         qProtoDebug() << __func__ << "value" << value;
 
@@ -296,13 +279,12 @@ public:
     //###########################################################################
     //                           Deserialization helpers
     //###########################################################################
-
     template <typename V,
               typename std::enable_if_t<std::is_floating_point<V>::value
-                                        || std::is_same<V, int>::value
-                                        || std::is_same<V, qlonglong>::value
-                                        || std::is_same<V, unsigned int>::value
-                                        || std::is_same<V, qulonglong>::value, int> = 0>
+                                        || std::is_same<V, fint32>::value
+                                        || std::is_same<V, fint64>::value
+                                        || std::is_same<V, sfint32>::value
+                                        || std::is_same<V, sfint64>::value, int> = 0>
     QVariant deserializeFixed(QByteArray::const_iterator &it) {
         qProtoDebug() << __func__ << "currentByte:" << QString::number((*it), 16);
 
@@ -387,10 +369,10 @@ public:
 
     template <typename V,
               typename std::enable_if_t<std::is_floating_point<V>::value
-                                        || std::is_same<V, unsigned int>::value
-                                        || std::is_same<V, qulonglong>::value
-                                        || std::is_same<V, int>::value
-                                        || std::is_same<V, qlonglong>::value, int> = 0>
+                                        || std::is_same<V, sfint32>::value
+                                        || std::is_same<V, sfint64>::value
+                                        || std::is_same<V, fint32>::value
+                                        || std::is_same<V, fint64>::value, int> = 0>
     QVariant deserializeListType(QByteArray::const_iterator &it) {
         qProtoDebug() << __func__ << "currentByte:" << QString::number((*it), 16);
 

+ 20 - 4
src/protobuf/qtprotobuftypes.h

@@ -29,6 +29,14 @@
 #include <QList>
 #include <QMetaType>
 
+template<typename T>
+struct transparent {
+    transparent(T t = T()) : _t(t){}
+    T _t;
+    operator T&(){ return _t; }
+    operator T() const { return _t; }
+};
+
 namespace qtprotobuf {
 using int32 = int;
 using int64 = qlonglong;
@@ -36,10 +44,10 @@ using uint32 = unsigned int;
 using uint64 = qulonglong;
 using sint32 = int;
 using sint64 = qlonglong;
-using fint32 = unsigned int;
-using fint64 = qulonglong;
-using sfint32 = int;
-using sfint64 = qlonglong;
+using fint32 = transparent<uint32_t>;
+using fint64 = transparent<uint64_t>;
+using sfint32 = transparent<int32_t>;
+using sfint64 = transparent<int64_t>;
 
 using int32List = QList<int32>;
 using int64List = QList<int64>;
@@ -60,11 +68,19 @@ Q_DECLARE_METATYPE(qtprotobuf::int32)
 Q_DECLARE_METATYPE(qtprotobuf::int64)
 Q_DECLARE_METATYPE(qtprotobuf::uint32)
 Q_DECLARE_METATYPE(qtprotobuf::uint64)
+Q_DECLARE_METATYPE(qtprotobuf::fint32)
+Q_DECLARE_METATYPE(qtprotobuf::fint64)
+Q_DECLARE_METATYPE(qtprotobuf::sfint32)
+Q_DECLARE_METATYPE(qtprotobuf::sfint64)
 
 Q_DECLARE_METATYPE(qtprotobuf::int32List)
 Q_DECLARE_METATYPE(qtprotobuf::int64List)
 Q_DECLARE_METATYPE(qtprotobuf::uint32List)
 Q_DECLARE_METATYPE(qtprotobuf::uint64List)
+Q_DECLARE_METATYPE(qtprotobuf::fint32List)
+Q_DECLARE_METATYPE(qtprotobuf::fint64List)
+Q_DECLARE_METATYPE(qtprotobuf::sfint32List)
+Q_DECLARE_METATYPE(qtprotobuf::sfint64List)
 
 Q_DECLARE_METATYPE(qtprotobuf::FloatList)
 Q_DECLARE_METATYPE(qtprotobuf::DoubleList)

+ 10 - 10
tests/simpletest.cpp

@@ -177,10 +177,10 @@ TEST_F(SimpleTest, SimpleFixedInt32MessageTest)
     const char* propertyName = "testFieldFixedInt32";
     SimpleFixedInt32Message test;
     int propertyNumber = SimpleFixedInt32Message::propertyOrdering.at(1); //See simpletest.proto
-    ASSERT_EQ(SimpleFixedInt32Message::staticMetaObject.property(propertyNumber).type(), qMetaTypeId<fint32>());
+    ASSERT_EQ(SimpleFixedInt32Message::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<fint32>());
     ASSERT_STREQ(SimpleFixedInt32Message::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::fint32");
     ASSERT_STREQ(SimpleFixedInt32Message::staticMetaObject.property(propertyNumber).name(), propertyName);
-    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue(1)));
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<fint32>(1)));
     ASSERT_EQ(test.property(propertyName).value<fint32>(), 1);
     ASSERT_EQ(test.testFieldFixedInt32(), 1);
 }
@@ -190,10 +190,10 @@ TEST_F(SimpleTest, SimpleFixedInt64MessageTest)
     const char* propertyName = "testFieldFixedInt64";
     SimpleFixedInt64Message test;
     int propertyNumber = SimpleFixedInt64Message::propertyOrdering.at(1); //See simpletest.proto
-    ASSERT_EQ(SimpleFixedInt64Message::staticMetaObject.property(propertyNumber).type(), qMetaTypeId<fint64>());
+    ASSERT_EQ(SimpleFixedInt64Message::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<fint64>());
     ASSERT_STREQ(SimpleFixedInt64Message::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::fint64");
     ASSERT_STREQ(SimpleFixedInt64Message::staticMetaObject.property(propertyNumber).name(), propertyName);
-    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue(1)));
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<fint64>(1)));
     ASSERT_EQ(test.property(propertyName).value<fint64>(), 1);
     ASSERT_EQ(test.testFieldFixedInt64(), 1);
 }
@@ -203,11 +203,11 @@ TEST_F(SimpleTest, SimpleSFixedInt32MessageTest)
     const char* propertyName = "testFieldFixedInt32";
     SimpleSFixedInt32Message test;
     int propertyNumber = SimpleSFixedInt32Message::propertyOrdering.at(1); //See simpletest.proto
-    ASSERT_EQ(SimpleSFixedInt32Message::staticMetaObject.property(propertyNumber).type(), qMetaTypeId<sfint32>());
+    ASSERT_EQ(SimpleSFixedInt32Message::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<sfint32>());
     ASSERT_STREQ(SimpleSFixedInt32Message::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::sfint32");
     ASSERT_STREQ(SimpleSFixedInt32Message::staticMetaObject.property(propertyNumber).name(), propertyName);
-    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue(1)));
-    ASSERT_EQ(test.property(propertyName).value<fint32>(), 1);
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<sfint32>(1)));
+    ASSERT_EQ(test.property(propertyName).value<sfint32>(), 1);
     ASSERT_EQ(test.testFieldFixedInt32(), 1);
 }
 
@@ -216,11 +216,11 @@ TEST_F(SimpleTest, SimpleSFixedInt64MessageTest)
     const char* propertyName = "testFieldFixedInt64";
     SimpleSFixedInt64Message test;
     int propertyNumber = SimpleSFixedInt64Message::propertyOrdering.at(1); //See simpletest.proto
-    ASSERT_EQ(SimpleSFixedInt64Message::staticMetaObject.property(propertyNumber).type(), qMetaTypeId<sfint64>());
+    ASSERT_EQ(SimpleSFixedInt64Message::staticMetaObject.property(propertyNumber).userType(), qMetaTypeId<sfint64>());
     ASSERT_STREQ(SimpleSFixedInt64Message::staticMetaObject.property(propertyNumber).typeName(), "qtprotobuf::sfint64");
     ASSERT_STREQ(SimpleSFixedInt64Message::staticMetaObject.property(propertyNumber).name(), propertyName);
-    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue(1)));
-    ASSERT_EQ(test.property(propertyName).value<fint64>(), 1);
+    ASSERT_TRUE(test.setProperty(propertyName, QVariant::fromValue<sfint64>(1)));
+    ASSERT_EQ(test.property(propertyName).value<sfint64>(), 1);
     ASSERT_EQ(test.testFieldFixedInt64(), 1);
 }