Bläddra i källkod

Change naming and signatures of protobuf functions

Alexey Edelev 5 år sedan
förälder
incheckning
8fc98c0850

+ 6 - 6
src/protobuf/qprotobufobject_p.cpp

@@ -71,7 +71,7 @@ void ProtobufObjectPrivate::registerSerializers()
     wrapSerializer<QByteArrayList>(ProtobufObjectPrivate::serializeListType<QByteArray>, ProtobufObjectPrivate::deserializeList<QByteArray>, LengthDelimited);
 }
 
-QByteArray ProtobufObjectPrivate::serializeValue(const QVariant &propertyValue, int fieldIndex, const QMetaProperty &metaProperty)
+QByteArray ProtobufObjectPrivate::serializeProperty(const QVariant &propertyValue, int fieldIndex, const QMetaProperty &metaProperty)
 {
     qProtoDebug() << __func__ << "propertyValue" << propertyValue << "fieldIndex" << fieldIndex
                   << "typeName" << metaProperty.typeName() << static_cast<QMetaType::Type>(propertyValue.type());
@@ -103,7 +103,7 @@ QByteArray ProtobufObjectPrivate::serializeUserType(const QVariant &propertyValu
     return serializer.serializer(propertyValue, fieldIndex);
 }
 
-void ProtobufObjectPrivate::deserializeProperty(QObject *object, WireTypes wireType, const QMetaProperty &metaProperty, SelfcheckIterator &it)
+void ProtobufObjectPrivate::deserializeProperty(QObject *object, const QMetaProperty &metaProperty, SelfcheckIterator &it, WireTypes wireType)
 {
     qProtoDebug() << __func__ << " wireType: " << wireType << " metaProperty: " << metaProperty.typeName()
                   << "currentByte:" << QString::number((*it), 16);
@@ -135,11 +135,11 @@ void ProtobufObjectPrivate::deserializeProperty(QObject *object, WireTypes wireT
     metaProperty.write(object, newPropertyValue);
 }
 
-void ProtobufObjectPrivate::deserializeUserType(const QMetaProperty &metaType, SelfcheckIterator& it, QVariant &newValue)
+void ProtobufObjectPrivate::deserializeUserType(const QMetaProperty &metaProperty, SelfcheckIterator& it, QVariant &out)
 {
-    qProtoDebug() << __func__ << "userType" << metaType.userType() << "typeName" << metaType.typeName()
+    qProtoDebug() << __func__ << "userType" << metaProperty.userType() << "typeName" << metaProperty.typeName()
                   << "currentByte:" << QString::number((*it), 16);
-    int userType = metaType.userType();
+    int userType = metaProperty.userType();
     auto deserializer = serializers.at(userType).deserializer;//Throws exception if not found
-    deserializer(it, newValue);
+    deserializer(it, out);
 }

+ 5 - 5
src/protobuf/qprotobufobject_p.h

@@ -132,11 +132,11 @@ public:
     static QByteArray encodeHeader(int fieldIndex, WireTypes wireType);
     static bool decodeHeader(SelfcheckIterator &it, int &fieldIndex, WireTypes &wireType);
 
-    static QByteArray serializeValue(const QVariant &propertyValue, int fieldIndex, const QMetaProperty &metaProperty);
+    static QByteArray serializeProperty(const QVariant &propertyValue, int fieldIndex, const QMetaProperty &metaProperty);
     static QByteArray serializeUserType(const QVariant &propertyValue, int &fieldIndex, WireTypes &type);
 
-    static void deserializeProperty(QObject *object, WireTypes wireType, const QMetaProperty &metaProperty, SelfcheckIterator &it);
-    static void deserializeUserType(const QMetaProperty &metaType, SelfcheckIterator &it, QVariant &newValue);
+    static void deserializeProperty(QObject *object, const QMetaProperty &metaProperty, SelfcheckIterator &it, WireTypes wireType);
+    static void deserializeUserType(const QMetaProperty &metaProperty, SelfcheckIterator &it, QVariant &out);
 
     //###########################################################################
     //                           Serialization helpers
@@ -676,7 +676,7 @@ public:
             QMetaProperty metaProperty = T::staticMetaObject.property(propertyIndex);
             const char *propertyName = metaProperty.name();
             const QVariant &propertyValue = object->property(propertyName);
-            result.append(ProtobufObjectPrivate::serializeValue(propertyValue, fieldIndex, metaProperty));
+            result.append(ProtobufObjectPrivate::serializeProperty(propertyValue, fieldIndex, metaProperty));
         }
 
         return result;
@@ -712,7 +712,7 @@ public:
             int propertyIndex = propertyNumberIt->second;
             QMetaProperty metaProperty = T::staticMetaObject.property(propertyIndex);
 
-            ProtobufObjectPrivate::deserializeProperty(object, wireType, metaProperty, it);
+            ProtobufObjectPrivate::deserializeProperty(object, metaProperty, it, wireType);
         }
     }
 

+ 8 - 8
tests/test_protobuf/serializationtest.cpp

@@ -1703,11 +1703,11 @@ TEST_F(SerializationTest, FieldIndexRangeTest)
                  "f8ffffff0f02");
 }
 
-//TEST_F(SerializationTest, DISABLE_BenchmarkTest)
-//{
-//    SimpleIntMessage msg;
-//    for (int i = INT16_MIN; i < INT16_MAX; i++) {
-//        msg.setTestFieldInt(i);
-//        msg.serialize();
-//    }
-//}
+TEST_F(SerializationTest, DISABLED_BenchmarkTest)
+{
+    SimpleIntMessage msg;
+    for (int i = INT16_MIN; i < INT16_MAX; i++) {
+        msg.setTestFieldInt(i);
+        msg.serialize();
+    }
+}