Merge pull request #22 from enochc/master

changed QMetaType::Type T to int to allow registration of custom QMet…
This commit is contained in:
Roman Isaikin
2016-05-31 11:44:56 +03:00
4 changed files with 6 additions and 6 deletions

View File

@ -28,7 +28,7 @@ QByteArray MsgPack::pack(const QVariant &variant)
return arr;
}
bool MsgPack::registerPacker(QMetaType::Type qType, qint8 msgpackType, MsgPack::pack_user_f packer)
bool MsgPack::registerPacker(int qType, qint8 msgpackType, MsgPack::pack_user_f packer)
{
return MsgPackPrivate::register_packer(qType, msgpackType, packer);
}

View File

@ -13,7 +13,7 @@ namespace MsgPack
MSGPACK_EXPORT bool registerUnpacker(qint8 msgpackType, unpack_user_f unpacker);
MSGPACK_EXPORT QByteArray pack(const QVariant &variant);
MSGPACK_EXPORT bool registerPacker(QMetaType::Type qType, qint8 msgpackType, pack_user_f packer);
MSGPACK_EXPORT bool registerPacker(int qType, qint8 msgpackType, pack_user_f packer);
MSGPACK_EXPORT qint8 msgpackType(int qType);
MSGPACK_EXPORT bool registerType(QMetaType::Type qType, quint8 msgpackType);

View File

@ -11,7 +11,7 @@
#include <QReadLocker>
#include <QWriteLocker>
QHash<QMetaType::Type, MsgPackPrivate::packer_t> MsgPackPrivate::user_packers;
QHash<int, MsgPackPrivate::packer_t> MsgPackPrivate::user_packers;
bool MsgPackPrivate::compatibilityMode = false;
QReadWriteLock MsgPackPrivate::packers_lock;
@ -319,7 +319,7 @@ quint8 *MsgPackPrivate::pack_map(const QVariantMap &map, quint8 *p, bool wr, QVe
return p;
}
bool MsgPackPrivate::register_packer(QMetaType::Type q_type, qint8 msgpack_type, MsgPack::pack_user_f packer)
bool MsgPackPrivate::register_packer(int q_type, qint8 msgpack_type, MsgPack::pack_user_f packer)
{
QWriteLocker locker(&packers_lock);
if (user_packers.contains(q_type)) {

View File

@ -19,9 +19,9 @@ typedef struct {
MsgPack::pack_user_f packer;
qint8 type;
} packer_t;
bool register_packer(QMetaType::Type q_type, qint8 msgpack_type, MsgPack::pack_user_f packer);
bool register_packer(int q_type, qint8 msgpack_type, MsgPack::pack_user_f packer);
qint8 msgpack_type(QMetaType::Type q_type);
extern QHash<QMetaType::Type, packer_t> user_packers;
extern QHash<int, packer_t> user_packers;
extern QReadWriteLock packers_lock;
extern bool compatibilityMode;