Пример #1
0
/*
 {
    "func":"timeConvert",
    "args":60
 }
 
 {
    "func":"timeConvert",
    "args":[1,3,4,5]
 }
 */
static cxConstChars jsonStrConvert(json_t *v)
{
    cxJson json = cxJsonReference(v);
    cxStr txt = cxJsonDump(json);
    cxConstChars funcName = cxJsonConstChars(json, "func");
    if(!cxConstCharsOK(funcName)){
        return cxStrBody(txt);
    }
    cxConvert convert = cxGetConvert(funcName);
    if(convert == NULL){
        return cxStrBody(txt);
    }
    CX_ASSERT(convert->func != NULL, "convert error");
    cxStr ret = NULL;
    cxJson args = cxJsonAny(json, "args");
    if(args == NULL){
        ret = ((cxStr (*)(void))convert->func)();
    }else if(cxJsonIsStr(args)){
        cxConstChars a1 = cxJsonToConstChars(args);
        ret = ((cxStr (*)(cxConstChars))convert->func)(a1);
    }else if(cxJsonIsInt(args)){
        cxInt a1 = cxJsonToInt(args, 0);
        ret = ((cxStr (*)(cxInt))convert->func)(a1);
    }else if(cxJsonIsDouble(args)){
        cxDouble a1 = cxJsonToDouble(args, 0);
        ret = ((cxStr (*)(cxDouble))convert->func)(a1);
    }else if(cxJsonIsBool(args)){
        cxBool a1 = cxJsonToBool(args, false);
        ret = ((cxStr (*)(cxBool))convert->func)(a1);
    }else{
        ret = ((cxStr (*)(cxJson))convert->func)(args);
    }
    return ret == NULL ? NULL : cxStrBody(ret);
}
Пример #2
0
CX_SETTER_DEF(cxButton, enable)
{
    this->isEnable = cxJsonToBool(value, this->isEnable);
}
Пример #3
0
CX_SETTER_DEF(cxButton, ispass)
{
    this->IsPass = cxJsonToBool(value, this->IsPass);
}