/* { "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); }
CX_SETTER_DEF(cxSprite, texture) { cxConstChars texture = NULL; cxBool uts = true; if(cxJsonIsString(value)){ texture = cxJsonToConstChars(value); }else if(cxJsonIsObject(value)){ uts = cxJsonBool(value, "uts", uts); texture = cxJsonConstChars(value, "url"); } CX_RETURN(texture == NULL); cxSpriteSetTextureURL(this, texture, uts); }
//{"r":0,"g":0,"b":0,"a":0} cxColor4f cxJsonToColor4f(cxJson json,cxColor4f dv) { CX_ASSERT_THIS(json, cxJson); this = cxJsonParseRegisterValue(this); if(cxJsonIsStr(this)){ cxConstChars color = cxJsonToConstChars(this); dv = cxCharsToColor4f(color, dv); }else if(cxJsonIsInt(this)){ cxUInt color = cxJsonToInt(this, 0xFFFFFFFF); dv.r = ((cxFloat)((color >> 24) & 0xFF)) / 255.0f; dv.g = ((cxFloat)((color >> 16) & 0xFF)) / 255.0f; dv.b = ((cxFloat)((color >> 8) & 0xFF)) / 255.0f; dv.a = ((cxFloat)(color & 0xFF)) / 255.0f; }else if(cxJsonIsDouble(this)){