示例#1
0
文件: cxDB.c 项目: 812872970/cxEngine
cxBool cxDBOpen(cxAny db,cxString file,cxString table,cxBool rdonly)
{
    CX_ASSERT(file != NULL && table != NULL, "args error");
    cxDBEnv env = cxDBGetEnv(db);
    cxDB this = db;
    if(rdonly){
        this->flags = DB_RDONLY;
    }else{
        this->flags = DB_CREATE;
    }
    this->ret = db_create(&this->dbptr, env->env, 0);
    CX_RETURN(this->ret != 0,false);
    this->ret = CX_METHOD_FIRE(this->ret, this->OpenBefore,db);
    CX_RETURN(this->ret != 0,false);
    cxDBTxn txn = cxStackTop(env->txn);
    this->ret = this->dbptr->open(this->dbptr,cxDBTxnPtr(txn),cxStringBody(file),cxStringBody(table),this->type,this->flags,0);
    if(this->ret != 0){
        CX_ERROR("open db error %s:%s",cxStringBody(file),cxStringBody(table));
        return false;
    }
    CX_RETURN(this->ret != 0,false);
    CX_RETAIN_SWAP(this->file, file);
    CX_RETAIN_SWAP(this->table, table);
    return CX_METHOD_FIRE(true, this->OpenAfter,db);
}
示例#2
0
cxTexture cxTextureFactoryLoadText(const cxString txt,const cxString font,cxTextAttr attr)
{
    cxTextureTXT texture = CX_CREATE(cxTextureTXT);
    texture->attr = attr;
    CX_RETAIN_SWAP(texture->string, txt);
    CX_RETAIN_SWAP(texture->fontfile, font);
    cxTextureLoad((cxTexture)texture,NULL);
    return (cxTexture)texture;
}
示例#3
0
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;
}
示例#4
0
cxStream cxMp3StreamCreate(cxConstChars file)
{
    cxMp3Stream this = CX_CREATE(cxMp3Stream);
    cxString path = cxAssetsPath(file);
    CX_RETAIN_SWAP(this->path, path);
    return (cxStream)this;
}
示例#5
0
cxSpline cxSplineCreate(cxFloat time,cxAnyArray points)
{
    CX_ASSERT(points != NULL, "points null");
    cxSpline this = CX_CREATE(cxSpline);
    cxActionSetTime(this, time);
    CX_RETAIN_SWAP(this->points, points);
    return this;
}
示例#6
0
void cxSpriteSetShader(cxAny pview,cxConstChars key)
{
    CX_RETURN(key == NULL);
    cxShader shader = cxOpenGLShader(key);
    CX_RETURN(shader == NULL);
    cxSprite this = pview;
    CX_RETAIN_SWAP(this->shader, shader);
}
示例#7
0
cxStream cxFileStreamCreate(cxConstChars file,cxBool rdonly)
{
    cxStr path = cxDocumentPath(file);
    cxFileStream rv = CX_CREATE(cxFileStream);
    rv->rdonly = rdonly;
    CX_RETAIN_SWAP(rv->cxStream.path, path);
    return (cxStream)rv;
}
示例#8
0
cxTypes cxHashRootReadNumber(cxHashRoot root,cxConstChars temp,xmlTextReaderPtr reader)
{
    cxTypes types = cxNumberTypesCreate();
    cxAny obj = cxReadValues(root, temp, reader);
    if(!cxObjectIsType(obj, cxNumberTypeName)){
        return NULL;
    }
    CX_RETAIN_SWAP(types->any, obj);
    return types;
}
示例#9
0
cxTypes cxHashRootReadString(cxHashRoot root,xmlTextReaderPtr reader)
{
    cxTypes types = cxStringTypesCreate();
    cxString bytes = NULL;
    cxConstChars  src = cxXMLAttr(reader, "src");
    if(src != NULL){
        cxStream stream = cxAssetsStreamCreate(src);
        bytes = cxStreamAllBytes(stream);
    }else if(!xmlTextReaderIsEmptyElement(reader)) {
        bytes = cxXMLReadString(reader);
    }else{
        bytes = NULL;
    }
    if(bytes == NULL){
        return NULL;
    }
    CX_RETAIN_SWAP(types->any, bytes);
    return types;
}
示例#10
0
cxXMLScript cxEngineGetXMLScript(cxConstChars file)
{
    cxEngine this = cxEngineInstance();
    CX_RETURN(file == NULL,NULL);
    
    cxXMLScript script = cxHashGet(this->scripts, cxHashStrKey(file));
    if(script != NULL){
        return script;
    }
    
    script = CX_CREATE(cxXMLScript);
    cxStream stream = cxAssetsStreamCreate(file);
    CX_RETURN(stream == NULL, NULL);
    
    CX_RETAIN_SWAP(script->bytes, cxStreamAllBytes(stream));
    CX_RETURN(script->bytes == NULL, NULL);
    
    cxHashSet(this->scripts, cxHashStrKey(file), script);
    return script;
}
示例#11
0
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;
}
示例#12
0
void cxLoadingSetObject(cxAny pview,cxAny object)
{
    cxLoading this = pview;
    CX_RETAIN_SWAP(this->object, object);
}
示例#13
0
void cxViewSetArgs(cxAny pview,cxAny args)
{
    cxView this = pview;
    CX_RETAIN_SWAP(this->args, args);
}
示例#14
0
void cxEngineSetLocalized(cxString lang)
{
    cxEngine this = cxEngineInstance();
    CX_RETAIN_SWAP(this->lang, lang);
}
示例#15
0
void cxSpriteSetTexture(cxAny pview,cxTexture texture)
{
    cxSprite this = pview;
    CX_RETAIN_SWAP(this->texture, texture);
}
示例#16
0
文件: cxDB.c 项目: 812872970/cxEngine
void cxDBSetEnv(cxAny db,cxDBEnv env)
{
    cxDB this = db;
    CX_RETAIN_SWAP(this->env, env);
}