예제 #1
0
파일: pack_p.cpp 프로젝트: SGbo/qmsgpack
quint8 *MsgPackPrivate::pack(const QVariant &v, quint8 *p, bool wr, QVector<QByteArray> &user_data)
{
    QMetaType::Type t = (QMetaType::Type)v.type();
    if (v.isNull() && !v.isValid())
        p = pack_nil(p, wr);
    else if (t == QMetaType::Int)
        p = pack_int(v.toInt(), p, wr);
    else if (t == QMetaType::UInt)
        p = pack_uint(v.toUInt(), p, wr);
    else if (t == QMetaType::Bool)
        p = pack_bool(v, p, wr);
    else if (t == QMetaType::QString)
        p = pack_string(v.toString(), p, wr);
    else if (t == QMetaType::QVariantList)
        p = pack_array(v.toList(), p, wr, user_data);
    else if (t == QMetaType::QStringList)
        p = pack_stringlist(v.toStringList(), p, wr);
    else if (t == QMetaType::LongLong)
        p = pack_longlong(v.toLongLong(), p, wr);
    else if (t == QMetaType::ULongLong)
        p = pack_ulonglong(v.toULongLong(), p, wr);
    else if (t == QMetaType::Double)
        p = pack_double(v.toDouble(), p, wr);
    else if (t == QMetaType::Float)
        p = pack_float(v.toFloat(), p, wr);
    else if (t == QMetaType::QByteArray)
        p = pack_bin(v.toByteArray(), p, wr);
    else if (t == QMetaType::QVariantMap)
        p = pack_map(v.toMap(), p, wr, user_data);
    else {
        if (t == QMetaType::User)
            t = (QMetaType::Type)v.userType();
        QReadLocker locker(&packers_lock);
        bool has_packer = user_packers.contains(t);
        if (has_packer)
            has_packer &= user_packers[t].packer != 0;
        locker.unlock();
        if (has_packer)
            p = pack_user(v, p, wr, user_data);
        else
            qWarning() << "MsgPack::pack can't pack type:" << t;
    }

    return p;
}
예제 #2
0
extern OBJ _AJavaNull_Anull__O1(OBJ x1) /* null?,1 */
{
  int res = tst_sflag(x1, null_sflag);
  free_denotation(x1, 1);
  return pack_bool(res);
}
예제 #3
0
extern OBJ _AJavaNull_Anull_(OBJ x1) /* null? */
{
  int res = get_jobject(x1) == NULL;
  free_jobject(x1, 1);
  return pack_bool(res);
}
예제 #4
0
extern OBJ _AJavaCatch_AisJavaExcept(OBJ x1) /* isJavaExcept */
{
  return pack_bool(x1 == javabind_exception_ans);
}