예제 #1
0
/*******************************BuiltinPtr********************************/
string TarsAnalyzer::tostrBuiltin(const BuiltinPtr &pPtr)
{
    string s;

    switch(pPtr->kind())
    {
    case Builtin::KindBool:
        s = " bool ";
        break;
    case Builtin::KindByte:
        s = " char ";
        break;
    case Builtin::KindShort:
    //为了兼容java无unsigned, 编结码时把tars问件中 unsigned char 对应到short
    //c++中需要还原回来
        s = (pPtr->isUnsigned()?"uchar":" short ");
        break;
    case Builtin::KindInt:
        s = (pPtr->isUnsigned()?"ushort":" int ");
        break;
    case Builtin::KindLong:
        s =  (pPtr->isUnsigned()?"uint":" int64 ");
        break;
    case Builtin::KindFloat:
        s = " float ";
        break;
    case Builtin::KindDouble:
        s = " double ";
        break;
    case Builtin::KindString:
        if(pPtr->isArray())
            s = "char[]"; //char a [8];
        else
            s = " string ";//string a;
        break;
    case Builtin::KindVector:
        s = " vector ";
        break;
    case Builtin::KindMap:
        s = " map ";
        break;
    default:
        cout << getTab() << " _cur:" << _cur << " _last_pos:" << _last_pos << endl;
        exit(-1);
        break;
    }

    return s;
}
예제 #2
0
파일: jce2php.cpp 프로젝트: daliniu/mobile
string Jce2Php::tostrBuiltin(const BuiltinPtr &pPtr) const
{
    string s;

    switch(pPtr->kind())
    {
    case Builtin::KindBool:
        s = "c_char";
        break;
    case Builtin::KindByte:
        s = (pPtr->isUnsigned()?"c_short":"c_char");
        break;
    case Builtin::KindShort:
        s = (pPtr->isUnsigned()?"c_short":"c_short");
        break;
    case Builtin::KindInt:
        s = (pPtr->isUnsigned()?"c_int":"c_int");
        break;
    case Builtin::KindLong:
        s =  "c_int64";
        break;
    case Builtin::KindFloat:
        s = "c_float";
        break;
    case Builtin::KindDouble:
        s = "c_double";
        break;
    case Builtin::KindString:
        s = "c_string";
        break;
    case Builtin::KindVector:
        s = "c_vector";
        break;
    case Builtin::KindMap:
        s = "c_map";
        break;
    default:
        assert(false);
        break;
    }

    return s;
}