AnimationTemplate::AnimationTemplate(InputPersistenceBlock &reader, uint handle) { // Objekt registrieren. AnimationTemplateRegistry::instance().registerObject(this, handle); // Objekt laden. _valid = unpersist(reader); }
static void unpersistliteraltable(int ref, UnpersistInfo *upi) { /* perms reftbl ... */ /* Preregister table for handling of cycles */ lua_newtable(upi->L); /* perms reftbl ... tbl */ registerobject(ref, upi); /* perms reftbl ... tbl */ /* Unpersist metatable */ { unpersist(upi); /* perms reftbl ... tbl mt/nil? */ if(lua_istable(upi->L, -1)) { /* perms reftbl ... tbl mt */ lua_setmetatable(upi->L, -2); /* perms reftbl ... tbl */ } else { /* perms reftbl ... tbl nil? */ lua_assert(lua_isnil(upi->L, -1)); /* perms reftbl ... tbl nil */ lua_pop(upi->L, 1); /* perms reftbl ... tbl */ } /* perms reftbl ... tbl */ } while(1) { /* perms reftbl ... tbl */ unpersist(upi); /* perms reftbl ... tbl key/nil */ if(lua_isnil(upi->L, -1)) { /* perms reftbl ... tbl nil */ lua_pop(upi->L, 1); /* perms reftbl ... tbl */ break; } /* perms reftbl ... tbl key */ unpersist(upi); /* perms reftbl ... tbl key value? */ lua_assert(!lua_isnil(upi->L, -1)); /* perms reftbl ... tbl key value */ lua_settable(upi->L, -3); /* perms reftbl ... tbl */ } }
Text::Text(InputPersistenceBlock &reader, RenderObjectPtr<RenderObject> parentPtr, uint handle) : RenderObject(parentPtr, TYPE_TEXT, handle), // Temporarily set fields prior to unpersisting actual values _modulationColor(0xffffffff), _autoWrap(false), _autoWrapThreshold(AUTO_WRAP_THRESHOLD_DEFAULT) { // Unpersist the fields _initSuccess = unpersist(reader); }
static void unpersistuserdata(int ref, UnpersistInfo *upi) { /* perms reftbl ... */ int isspecial; verify(luaZ_read(&upi->zio, &isspecial, sizeof(int)) == 0); if(isspecial) { unpersist(upi); /* perms reftbl ... spfunc? */ lua_assert(lua_isfunction(upi->L, -1)); /* perms reftbl ... spfunc */ #ifdef PLUTO_PASS_USERDATA_TO_PERSIST lua_pushlightuserdata(upi->L, &upi->zio); lua_call(upi->L, 1, 1); #else lua_call(upi->L, 0, 1); #endif /* perms reftbl ... udata? */ /* This assertion might not be necessary; it's conceivable, for * example, that the SP function might decide to return a table * with equivalent functionality. For the time being, we'll * ignore this possibility in favor of stricter and more testable * requirements. */ lua_assert(lua_isuserdata(upi->L, -1)); /* perms reftbl ... udata */ } else { int length; verify(luaZ_read(&upi->zio, &length, sizeof(int)) == 0); lua_newuserdata(upi->L, length); /* perms reftbl ... udata */ registerobject(ref, upi); verify(luaZ_read(&upi->zio, lua_touserdata(upi->L, -1), length) == 0); unpersist(upi); /* perms reftbl ... udata mt/nil? */ lua_assert(lua_istable(upi->L, -1) || lua_isnil(upi->L, -1)); /* perms reftbl ... udata mt/nil */ lua_setmetatable(upi->L, -2); /* perms reftbl ... udata */ } /* perms reftbl ... udata */ }
static void unpersistspecialtable(int ref, UnpersistInfo *upi) { /* perms reftbl ... */ unpersist(upi); /* perms reftbl ... spfunc? */ lua_assert(lua_isfunction(upi->L, -1)); /* perms reftbl ... spfunc */ lua_call(upi->L, 0, 1); /* perms reftbl ... tbl? */ lua_assert(lua_istable(upi->L, -1)); /* perms reftbl ... tbl */ }
static void unpersistpermanent(int ref, UnpersistInfo *upi) { /* perms reftbl ... */ unpersist(upi); /* perms reftbl permkey */ lua_gettable(upi->L, 1); /* perms reftbl perm? */ /* We assume currently that the substituted permanent value * shouldn't be nil. This may be a bad assumption. Real-life * experience is needed to evaluate this. */ lua_assert(!lua_isnil(upi->L, -1)); /* perms reftbl perm */ }
static void unpersistupval(int ref, UnpersistInfo *upi) { /* perms reftbl ... */ UpVal *uv; unpersist(upi); /* perms reftbl ... obj */ uv = makeupval(upi->L, -1); lua_pop(upi->L, 1); /* perms reftbl ... */ pushupval(upi->L, uv); /* perms reftbl ... upval */ boxupval(upi->L); /* perms reftbl ... func */ }
static void check_unpersistent() { char dirpath[512] = {0}; struct list_head frame_head; struct frame_info *finfo; frame_t *frame; INIT_LIST_HEAD(&frame_head); sprintf(dirpath, "%s/%s", config.datadir, QNAME); // unpersist frame CU_ASSERT(unpersist_queue_context(dirpath, &frame_head) == RET_SUCCESS); CU_ASSERT_FATAL(! list_empty(&frame_head)); finfo = list_first_entry(&frame_head, struct frame_info, list); CU_ASSERT_FATAL(finfo != NULL); // check unpersistent frame frame = finfo->frame; CU_ASSERT_FATAL(frame != NULL); CU_ASSERT(! list_empty(&frame->h_attrs)); CU_ASSERT(! list_empty(&frame->h_data)); CU_ASSERT(frame->size == 38); free_frame_info(finfo); // update sent index CU_ASSERT(update_index_sent(QNAME, frame) == RET_SUCCESS); free_frame(frame); sleep(1); INIT_LIST_HEAD(&frame_head); // unpersist again CU_ASSERT(unpersist_queue_context(dirpath, &frame_head) == RET_SUCCESS); CU_ASSERT_FATAL(list_empty(&frame_head)); CU_ASSERT(unpersist() == RET_SUCCESS); }
int daemon_initialize(newt_config *config) { /* init processing for each protocol manager */ if(stomp_init() == RET_ERROR) { perror("failed to initialize stomp bucket"); return RET_ERROR; } if(transaction_init() == RET_ERROR) { perror("failed to initialize transaction_manager"); return RET_ERROR; } if(initialize_sending_worker() == RET_ERROR) { return RET_ERROR; } if(initialize_persistent_worker(config) == RET_ERROR) { return RET_ERROR; } unpersist(); // get persistent frames and reinstate them return RET_SUCCESS; }
void pluto_unpersist(lua_State *L, lua_Chunkreader reader, void *ud) { /* We use the graciously provided ZIO (what the heck does the Z stand * for?) library so that we don't have to deal with the reader directly. * Letting the reader function decide how much data to return can be * very unpleasant. */ UnpersistInfo upi; upi.L = L; #ifdef PLUTO_DEBUG upi.level = 0; #endif luaZ_init(&upi.zio, reader, ud, ""); /* perms */ lua_newtable(L); /* perms reftbl */ unpersist(&upi); /* perms reftbl rootobj */ lua_replace(L, 2); /* perms rootobj */ }
DynamicBitmap::DynamicBitmap(InputPersistenceBlock &reader, RenderObjectPtr<RenderObject> parentPtr, uint handle) : Bitmap(parentPtr, TYPE_DYNAMICBITMAP, handle) { _initSuccess = unpersist(reader); }
Polygon::Polygon(InputPersistenceBlock &Reader) : vertexCount(0), vertices(NULL) { unpersist(Reader); }
WalkRegion::WalkRegion(InputPersistenceBlock &reader, uint handle) : Region(reader, handle) { _type = RT_WALKREGION; unpersist(reader); }
static void unpersistfunction(int ref, UnpersistInfo *upi) { /* perms reftbl ... */ LClosure *lcl; int i; lu_byte nupvalues; verify(luaZ_read(&upi->zio, &nupvalues, sizeof(lu_byte)) == 0); lcl = (LClosure*)luaF_newLclosure(upi->L, nupvalues, &upi->L->_gt); pushclosure(upi->L, (Closure*)lcl); /* perms reftbl ... func */ /* Put *some* proto in the closure, before the GC can find it */ lcl->p = makefakeproto(upi->L, nupvalues); /* Also, we need to temporarily fill the upvalues */ lua_pushnil(upi->L); /* perms reftbl ... func nil */ for(i=0; i<nupvalues; i++) { lcl->upvals[i] = makeupval(upi->L, -1); } lua_pop(upi->L, 1); /* perms reftbl ... func */ /* I can't see offhand how a function would ever get to be self- * referential, but just in case let's register it early */ registerobject(ref, upi); /* Now that it's safe, we can get the real proto */ unpersist(upi); /* perms reftbl ... func proto? */ lua_assert(lua_type(upi->L, -1) == LUA_TPROTO); /* perms reftbl ... func proto */ lcl->p = toproto(upi->L, -1); lua_pop(upi->L, 1); /* perms reftbl ... func */ for(i=0; i<nupvalues; i++) { /* perms reftbl ... func */ unpersist(upi); /* perms reftbl ... func func2 */ unboxupval(upi->L); /* perms reftbl ... func upval */ lcl->upvals[i] = toupval(upi->L, -1); lua_pop(upi->L, 1); /* perms reftbl ... func */ } /* perms reftbl ... func */ /* Finally, the fenv */ unpersist(upi); /* perms reftbl ... func fenv/nil? */ lua_assert(lua_type(upi->L, -1) == LUA_TNIL || lua_type(upi->L, -1) == LUA_TTABLE); /* perms reftbl ... func fenv/nil */ if(!lua_isnil(upi->L, -1)) { /* perms reftbl ... func fenv */ lua_setfenv(upi->L, -2); /* perms reftbl ... func */ } else { /* perms reftbl ... func nil */ lua_pop(upi->L, 1); /* perms reftbl ... func */ } /* perms reftbl ... func */ }
Region::Region(InputPersistenceBlock &reader, uint handle) : _valid(false), _type(RT_REGION) { RegionRegistry::instance().registerObject(this, handle); unpersist(reader); }
static void unpersistproto(int ref, UnpersistInfo *upi) { /* perms reftbl ... */ Proto *p; int i; int sizep, sizek; /* We have to be careful. The GC expects a lot out of protos. In * particular, we need to give the function a valid string for its * source, and valid code, even before we actually read in the real * code. */ TString *source = luaS_newlstr(upi->L, "", 0); p = luaF_newproto(upi->L); p->source = source; p->sizecode=1; p->code = luaM_newvector(upi->L, 1, Instruction); p->code[0] = CREATE_ABC(OP_RETURN, 0, 1, 0); p->maxstacksize = 2; p->sizek = 0; p->sizep = 0; pushproto(upi->L, p); /* perms reftbl ... proto */ /* We don't need to register early, since protos can never ever be * involved in cyclic references */ /* Read in constant references */ { verify(luaZ_read(&upi->zio, &sizek, sizeof(int)) == 0); luaM_reallocvector(upi->L, p->k, 0, sizek, TObject); for(i=0; i<sizek; i++) { /* perms reftbl ... proto */ unpersist(upi); /* perms reftbl ... proto k */ setobj2s(&p->k[i], getobject(upi->L, -1)); p->sizek++; lua_pop(upi->L, 1); /* perms reftbl ... proto */ } /* perms reftbl ... proto */ } /* Read in sub-proto references */ { verify(luaZ_read(&upi->zio, &sizep, sizeof(int)) == 0); luaM_reallocvector(upi->L, p->p, 0, sizep, Proto*); for(i=0; i<sizep; i++) { /* perms reftbl ... proto */ unpersist(upi); /* perms reftbl ... proto subproto */ p->p[i] = toproto(upi->L, -1); p->sizep++; lua_pop(upi->L, 1); /* perms reftbl ... proto */ } /* perms reftbl ... proto */ } /* Read in code */ { verify(luaZ_read(&upi->zio, &p->sizecode, sizeof(int)) == 0); luaM_reallocvector(upi->L, p->code, 1, p->sizecode, Instruction); verify(luaZ_read(&upi->zio, p->code, sizeof(Instruction) * p->sizecode) == 0); } /* Read in misc values */ { verify(luaZ_read(&upi->zio, &p->nups, sizeof(lu_byte)) == 0); verify(luaZ_read(&upi->zio, &p->numparams, sizeof(lu_byte)) == 0); verify(luaZ_read(&upi->zio, &p->is_vararg, sizeof(lu_byte)) == 0); verify(luaZ_read(&upi->zio, &p->maxstacksize, sizeof(lu_byte)) == 0); } }
static void unpersistthread(int ref, UnpersistInfo *upi) { /* perms reftbl ... */ lua_State *L2; L2 = lua_newthread(upi->L); /* L1: perms reftbl ... thr */ /* L2: (empty) */ registerobject(ref, upi); /* First, deserialize the object stack. */ { int i, stacksize; verify(luaZ_read(&upi->zio, &stacksize, sizeof(int)) == 0); luaD_growstack(L2, stacksize); /* Make sure that the first stack element (a nil, representing * the imaginary top-level C function) is written to the very, * very bottom of the stack */ L2->top--; for(i=0; i<stacksize; i++) { unpersist(upi); /* L1: perms reftbl ... thr obj* */ } lua_xmove(upi->L, L2, stacksize); /* L1: perms reftbl ... thr */ /* L2: obj* */ } /* Now, deserialize the CallInfo stack. */ { int i, numframes; verify(luaZ_read(&upi->zio, &numframes, sizeof(int)) == 0); luaD_reallocCI(L2,numframes*2); for(i=0; i<numframes; i++) { CallInfo *ci = L2->base_ci + i; int stackbase, stacktop, pc; verify(luaZ_read(&upi->zio, &stackbase, sizeof(int)) == 0); verify(luaZ_read(&upi->zio, &stacktop, sizeof(int)) == 0); verify(luaZ_read(&upi->zio, &pc, sizeof(int)) == 0); verify(luaZ_read(&upi->zio, &(ci->state), sizeof(int)) == 0); ci->base = L2->stack+stackbase; ci->top = L2->stack+stacktop; if(!(ci->state & CI_C)) { ci->u.l.savedpc = ci_func(ci)->l.p->code + pc; } ci->u.l.tailcalls = 0; /* Update the pointer each time, to keep the GC * happy*/ L2->ci = ci; } } /* L1: perms reftbl ... thr */ { int stackbase, stacktop; verify(luaZ_read(&upi->zio, &stackbase, sizeof(int)) == 0); verify(luaZ_read(&upi->zio, &stacktop, sizeof(int)) == 0); L2->base = L2->stack + stackbase; L2->top = L2->stack + stacktop; } /* Finally, "reopen" upvalues (see persistupval() for why) */ { UpVal* uv; GCObject **nextslot = &L2->openupval; while(1) { int stackpos; unpersist(upi); /* perms reftbl ... thr uv/nil */ if(lua_isnil(upi->L, -1)) { /* perms reftbl ... thr nil */ lua_pop(upi->L, 1); /* perms reftbl ... thr */ break; } /* perms reftbl ... thr boxeduv */ unboxupval(upi->L); /* perms reftbl ... thr uv */ uv = toupval(upi->L, -1); lua_pop(upi->L, 1); /* perms reftbl ... thr */ verify(luaZ_read(&upi->zio, &stackpos, sizeof(int)) == 0); uv->v = L2->stack + stackpos; gcunlink(upi->L, valtogco(uv)); uv->marked = 1; *nextslot = valtogco(uv); nextslot = &uv->next; } *nextslot = NULL; } }