static cxInt cxDataTypes(lua_State *L) { cxConstChars url = luaL_checkstring(L, 2); cxTypes types = cxEngineTypes(url); CX_LUA_PUSH_OBJECT(types); return 1; }
static cxInt cxSpriteTexture(lua_State *L) { CX_LUA_DEF_THIS(cxReaderAttrInfo *); cxConstChars v = NULL; cxConstChars k = NULL; if(!lua_istable(L, 2)){ luaL_error(L, "args error"); return 0; } lua_getfield(L, 2, "v"); v = luaL_checkstring(L, -1); lua_pop(L, 1); lua_getfield(L, 2, "k"); k = luaL_checkstring(L, -1); lua_pop(L, 1); if(v == NULL){ luaL_error(L, "v args error"); return 0; } cxTextureAttr attr = CX_CREATE(cxTextureAttr); cxSprite sprite = cxViewRootGet(this->root, v); CX_ASSERT(sprite != NULL, "sprite is null"); CX_RETAIN_SWAP(attr->texture, sprite->texture); if(k != NULL){ attr->box = cxTextureBox(sprite->texture, k); attr->size = cxTextureSize(sprite->texture, k); } CX_LUA_PUSH_OBJECT(attr); return 1; }
static cxInt cxStreamLuaMakeFile(lua_State *L) { cxConstChars file = luaL_checkstring(L, 1); cxStream this = cxFileStreamCreate(file); CX_LUA_PUSH_OBJECT(this); return 1; }
static cxInt cxFixScaleH(lua_State *L) { cxEngine engine = cxEngineInstance(); cxNumber num = cxNumberVec2f(cxVec2fv(engine->scale.y, engine->scale.y)); CX_LUA_PUSH_OBJECT(num); return 1; }
static cxInt cxStreamLuaAllBytes(lua_State *L) { CX_LUA_DEF_THIS(cxStream); cxString bytes = cxStreamAllBytes(this); CX_LUA_PUSH_OBJECT(bytes); return 1; }
static cxInt cxJsonLuaMake(lua_State *L) { cxConstChars json = luaL_checkstring(L, 1); cxJson ret = cxJsonCreate(UTF8(json)); CX_LUA_PUSH_OBJECT(ret); return 1; }
static cxInt cxHexNumber(lua_State *L) { cxConstChars str = luaL_checkstring(L, 2); cxUInt v = cxHexToUInt(str); cxNumber num = cxNumberUInt(v); CX_LUA_PUSH_OBJECT(num); return 1; }
static cxInt cxRelativeH(lua_State *L) { cxEngine engine = cxEngineInstance(); cxFloat v = luaL_checknumber(L, 2); cxNumber num = cxNumberFloat(v * engine->winsize.h); CX_LUA_PUSH_OBJECT(num); return 1; }
static cxInt cxLocalizedText(lua_State *L) { cxConstChars url = luaL_checkstring(L, 2); CX_ASSERT(url != NULL, "args error"); cxString text = cxEngineLocalizedText(url); CX_LUA_PUSH_OBJECT(text); return 1; }
static cxInt cxViewLuaCreateTimer(lua_State *L) { CX_LUA_DEF_THIS(cxView); cxFloat time = luaL_checknumber(L, 2); cxInt repeat = luaL_checkinteger(L, 3); cxAny timer = cxViewAppendTimer(this, time, repeat); CX_LUA_PUSH_OBJECT(timer); return 1; }
static cxInt cxDataString(lua_State *L) { cxConstChars url = luaL_checkstring(L, 2); cxTypes types = cxEngineTypes(url); if(types == NULL || !cxObjectIsType(types->any, cxStringTypeName)){ lua_pushnil(L); }else{ CX_LUA_PUSH_OBJECT(types->any); } return 1; }
static cxInt cxStreamLuaRead(lua_State *L) { CX_LUA_DEF_THIS(cxStream); cxInt size = cxLuaIntValue(L, 2, 0); if(size <= 0){ luaL_error(L, "size args error"); return 0; } cxPointer buffer = allocator->malloc(size); cxInt bytes = cxStreamRead(this, buffer, size); cxString rv = cxStringAttach(buffer, bytes); CX_LUA_PUSH_OBJECT(rv); return 1; }
static cxInt cxViewMulripleW(lua_State *L) { CX_LUA_DEF_THIS(cxReaderAttrInfo *); cxConstChars v = NULL; cxFloat n = 0; if(!lua_istable(L, 2)){ luaL_error(L, "args error"); return 0; } lua_getfield(L, 2, "v"); v = luaL_checkstring(L, -1); lua_pop(L, 1); lua_getfield(L, 2, "n"); n = luaL_checknumber(L, -1); lua_pop(L, 1); cxView view = cxViewRootGet(this->root, v); CX_ASSERT(view != NULL, "view is null"); cxNumber num = cxNumberFloat(view->size.w * n); CX_LUA_PUSH_OBJECT(num); return 1; }
static cxInt cxLoadTexture(lua_State *L) { cxTextureAttr rv = CX_CREATE(cxTextureAttr); cxConstChars str = luaL_checkstring(L, 2); cxUrlPath path = cxUrlPathParse(str); if(path->count == 0){ lua_pushnil(L); return 1; } cxTexture texture = NULL; if(path->count > 0){ texture = cxTextureFactoryLoadFile(path->path); rv->size = texture->size; CX_RETAIN_SWAP(rv->texture, texture); } if(path->count > 1 && texture != NULL){ rv->box = cxTextureBox(texture, path->key); rv->size = cxTextureSize(texture, path->key); } CX_LUA_PUSH_OBJECT(rv); return 1; }
static cxInt cxLoadingLuaGetObject(lua_State *L) { CX_LUA_DEF_THIS(cxLoading); CX_LUA_PUSH_OBJECT(this->object); return 1; }
static cxInt cxIsIOS(lua_State *L) { cxNumber num = cxNumberBool(CX_TARGET_PLATFORM == CX_PLATFORM_IOS); CX_LUA_PUSH_OBJECT(num); return 1; }
static cxInt cxStreamLuaMakeMemory(lua_State *L) { cxStream this = cxMemStreamCreateWithText(NULL); CX_LUA_PUSH_OBJECT(this); return 1; }
static cxInt cxIsAndroid(lua_State *L) { cxNumber num = cxNumberBool(CX_TARGET_PLATFORM == CX_PLATFORM_ANDROID); CX_LUA_PUSH_OBJECT(num); return 1; }