Esempio n. 1
0
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);
}
Esempio n. 2
0
cxAny cxActionRootMakeElement(cxConstChars temp,xmlTextReaderPtr reader)
{
    cxEngine engine = cxEngineInstance();
    cxAny action = NULL;
    if(ELEMENT_IS_TYPE(cxMove)){
        action = CX_CREATE(cxMove);
    }else if(ELEMENT_IS_TYPE(cxScale)){
        action = CX_CREATE(cxScale);
    }else if(ELEMENT_IS_TYPE(cxRotate)){
        action = CX_CREATE(cxRotate);
    }else if(ELEMENT_IS_TYPE(cxJump)){
        action = CX_CREATE(cxJump);
    }else if(ELEMENT_IS_TYPE(cxFade)){
        action = CX_CREATE(cxFade);
    }else if(ELEMENT_IS_TYPE(cxTint)){
        action = CX_CREATE(cxTint);
    }else if(ELEMENT_IS_TYPE(cxTimer)){
        action = CX_CREATE(cxTimer);
    }else if(ELEMENT_IS_TYPE(cxActionSet)){
        action = CX_CREATE(cxActionSet);
    }else if(ELEMENT_IS_TYPE(cxAnimate)){
        action = CX_CREATE(cxAnimate);
    }else if(ELEMENT_IS_TYPE(cxSpline)){
        action = CX_CREATE(cxSpline);
    }else if(ELEMENT_IS_TYPE(cxRunParticle)){
        action = CX_CREATE(cxRunParticle);
    }else if(ELEMENT_IS_TYPE(cxParabola)){
        action = CX_CREATE(cxParabola);
    }else{
        action = CX_METHOD_FIRE(NULL, engine->MakeAction, temp, reader);
    }
    return action;
}
Esempio n. 3
0
void cxActionReset(cxAny pav)
{
    cxAction this = pav;
    this->isFirst = false;
    this->isExit = false;
    this->index = -1;
    this->split = -1;
    this->durationElapsed = 0;
    this->delayElapsed = 0;
    CX_EVENT_RELEASE(this->onSplit);
    CX_EVENT_RELEASE(this->onStart);
    CX_EVENT_RELEASE(this->onStop);
    CX_EVENT_RELEASE(this->onStep);
    CX_METHOD_FIRE(NULL, this->Reset, this);
}
Esempio n. 4
0
cxAny cxActionRootGet(cxConstChars src)
{
    cxUrlPath path = cxUrlPathParse(src);
    CX_RETURN(path == NULL, NULL);
    cxActionRoot this = cxActionRootCreate(path->path);
    CX_RETURN(this == NULL, NULL);
    cxString code = cxHashGet(this->codes, (path->count == 1) ? cxHashStrKey(path->path) : cxHashStrKey(path->key));
    CX_RETURN(code == NULL, NULL);
    //create by code
    xmlTextReaderPtr reader = cxXMLReaderForString(code, NULL, NULL);
    cxReaderAttrInfo *info = cxReaderAttrInfoMake(reader, this, NULL);
    while(xmlTextReaderRead(reader)){
        CX_CONTINUE(xmlTextReaderNodeType(reader) != XML_READER_TYPE_ELEMENT);
        cxConstChars temp = cxXMLReadElementName(reader);
        info->object = CX_METHOD_FIRE(NULL, this->Make,temp,reader);
        CX_CONTINUE(info->object == NULL);
        //save root
        cxObjectSetRoot(info->object, this);
        cxObjectReadAttrRun(info);
    }
    return info->object;
}
Esempio n. 5
0
cxBool cxActionUpdate(cxAny pav,cxFloat dt)
{
    cxAction this = pav;
    cxBool isExit = false;
    dt = dt * this->speed;
    if(this->isPause || this->isExit){
        goto finished;
    }
    //action delay
    this->delayElapsed += dt;
    if(this->delay > 0 && this->delayElapsed < this->delay){
        goto finished;
    }
    //init event
    if(!this->isFirst){
        this->isFirst = true;
        CX_ASSERT(this->view != NULL, "action viewptr null");
        this->prevTime = 0;
        this->delayElapsed = 0;
        this->durationElapsed = this->durationInit;
        CX_METHOD_FIRE(NULL, this->Init, this);
        CX_EVENT_FIRE(this, onStart);
    }
    //for active
    if(!this->isActive){
        this->isActive = true;
        CX_METHOD_FIRE(NULL, this->Active, this);
    }
    this->durationElapsed += dt;
    cxFloat value = this->durationElapsed/CX_MAX(this->duration, FLT_EPSILON);
    cxFloat time = kmClamp(value, 0.0f, 1.0f);
    //split index event fire
    cxInt index = -1;
    if(time >= 1.0f){
        index = this->split - 1;
    }else if(this->splitDelta > 0){
        index = time / this->splitDelta;
    }
    if(this->index != index && index >= 0){
        this->index = index;
        CX_EVENT_FIRE(this,onSplit);
    }
    //wait exit
    if(this->duration < 0){
        CX_METHOD_FIRE(NULL, this->Step,this,dt,time);
        CX_EVENT_FIRE(this, onStep);
    }else if(this->duration == 0){
        isExit = CX_METHOD_FIRE(true, this->Exit, this);
    }else if(this->durationElapsed < this->duration){
        time = CX_METHOD_FIRE(time, this->Curve, this, time);
        this->delta = time - this->prevTime;
        this->prevTime = time;
        CX_METHOD_FIRE(NULL, this->Step,this,dt,time);
        CX_EVENT_FIRE(this, onStep);
    }else{
        time = CX_METHOD_FIRE(1.0f, this->Curve,this,1.0f);
        this->delta = time - this->prevTime;
        this->prevTime = 0;
        this->durationElapsed = 0.0f;
        this->delayElapsed = 0.0f;
        CX_METHOD_FIRE(NULL, this->Step,this,dt,1.0f);
        CX_EVENT_FIRE(this, onStep);
        //check exit
        isExit = CX_METHOD_FIRE(true, this->Exit,this);
        this->isActive = false;
    }
    //check action exit
finished:
    //force exit or auto exit
    if(this->isExit || isExit){
        CX_EVENT_FIRE(this, onStop);
        CX_METHOD_FIRE(NULL, this->Over,this);
    }
    return (this->isExit || isExit);
}