本文整理汇总了C++中preinit_state函数的典型用法代码示例。如果您正苦于以下问题:C++ preinit_state函数的具体用法?C++ preinit_state怎么用?C++ preinit_state使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了preinit_state函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: state_size
LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
int i;
lua_State *L;
global_State *g;
void *l = (*f)(ud, NULL, 0, state_size(LG));
if (l == NULL) return NULL;
L = tostate(l);
g = &((LG *)L)->g;
L->next = NULL;
L->tt = LUA_TTHREAD;
g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT);
L->marked = luaC_white(g);
set2bits(L->marked, FIXEDBIT, SFIXEDBIT);
preinit_state(L, g);
g->frealloc = f;
g->ud = ud;
g->mainthread = L;
g->uvhead.u.l.prev = &g->uvhead;
g->uvhead.u.l.next = &g->uvhead;
g->GCthreshold = 0; /* mark it as unfinished state */
g->strt.size = 0;
g->strt.nuse = 0;
g->strt.hash = NULL;
setnilvalue(registry(L));
luaZ_initbuffer(L, &g->buff);
g->panic = NULL;
g->gcstate = GCSpause;
g->rootgc = obj2gco(L);
g->sweepstrgc = 0;
g->sweepgc = &g->rootgc;
g->gray = NULL;
g->grayagain = NULL;
g->weak = NULL;
g->tmudata = NULL;
g->totalbytes = sizeof(LG);
g->gcpause = LUAI_GCPAUSE;
g->gcstepmul = LUAI_GCMUL;
g->gcdept = 0;
for (i=0; i<NUM_TAGS; i++) g->mt[i] = NULL;
if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) {
/* memory allocation error: free partial state */
close_state(L);
L = NULL;
}
else
luai_userstateopen(L);
/* SPRING additions, default to disabled functions */
g->fopen_func = NULL;
g->popen_func = NULL;
g->pclose_func = NULL;
g->system_func = NULL;
g->remove_func = NULL;
g->rename_func = NULL;
return L;
}
开发者ID:Arkazon,项目名称:spring,代码行数:57,代码来源:lstate.cpp
示例2: mallocstate
lua_State *luaE_newthread (lua_State *L) {
lua_State *L1 = mallocstate(L);
luaC_link(L, valtogco(L1), LUA_TTHREAD);
preinit_state(L1);
L1->l_G = L->l_G;
stack_init(L1, L); /* init stack */
setobj2n(gt(L1), gt(L)); /* share table of globals */
return L1;
}
开发者ID:zlandau,项目名称:lua-safe,代码行数:9,代码来源:lstate.c
示例3: cast
LUA_API lua_State *lua_newstate () {
int i;
lua_State *L;
global_State *g;
LG *l = cast(LG *, l_alloc(NULL, NULL, LUA_TTHREAD, sizeof(LG)));
if (l == NULL) return NULL;
L = &l->l.l;
g = &l->g;
L->next = NULL;
L->tt = LUA_TTHREAD;
/*g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT);
L->marked = luaC_white(g);
g->gckind = KGC_NORMAL;*/
preinit_state(L, g);
g->frealloc = l_alloc;
g->mainthread = L;
//g->seed = makeseed(L);
//g->uvhead.u.l.prev = &g->uvhead;
//g->uvhead.u.l.next = &g->uvhead;
//g->gcrunning = 0; /* no GC while building state */
//g->GCestimate = 0;
g->strt.size = 0;
g->strt.nuse = 0;
g->strt.hash = NULL;
setnilvalue(&g->l_registry);
/*luaZ_initbuffer(L, &g->buff);
g->panic = NULL;
g->version = lua_version(NULL);
g->gcstate = GCSpause;
g->allgc = NULL;
g->finobj = NULL;
g->tobefnz = NULL;
g->sweepgc = g->sweepfin = NULL;
g->gray = g->grayagain = NULL;
g->weak = g->ephemeron = g->allweak = NULL;*/
g->totalbytes = sizeof(LG);
/*g->GCdebt = 0;
g->gcpause = LUAI_GCPAUSE;
g->gcmajorinc = LUAI_GCMAJOR;
g->gcstepmul = LUAI_GCMUL;
for (i=0; i < LUA_NUMTAGS; i++) g->mt[i] = NULL;*/
//if (luaD_rawrunprotected(L, f_luaopen, NULL) != LUA_OK) {
// /* memory allocation error: free partial state */
// close_state(L);
// L = NULL;
//}
//else
// luai_userstateopen(L);
f_luaopen(L, NULL);
return L;
}
开发者ID:yinzhuo1,项目名称:SimpleLua,代码行数:53,代码来源:lstate.c
示例4: tostate
lua_State *luaE_newthread (lua_State *L) {
lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
luaC_link(L, obj2gco(L1), LUA_TTHREAD);
preinit_state(L1, G(L));
stack_init(L1, L); /* init stack */
setobj2n(L, gt(L1), gt(L)); /* share table of globals */
L1->hookmask = L->hookmask;
L1->basehookcount = L->basehookcount;
L1->hook = L->hook;
resethookcount(L1);
lua_assert(iswhite(obj2gco(L1)));
return L1;
}
开发者ID:Alibaba-boonya,项目名称:wax,代码行数:13,代码来源:lstate.c
示例5: killa_cast
KILLA_API killa_State *killa_newstate (killa_Alloc f, void *ud) {
int i;
killa_State *L;
killa_GlobalState *g;
LG *l = killa_cast(LG *, (*f)(ud, NULL, KILLA_TTHREAD, sizeof(LG)));
if (l == NULL) return NULL;
L = &l->l.l;
g = &l->g;
L->next = NULL;
L->tt = KILLA_TTHREAD;
g->currentwhite = killa_bit2mask(KILLA_WHITE0BIT, KILLA_FIXEDBIT);
L->marked = killaC_white(g);
g->gckind = KILLA_KGC_NORMAL;
preinit_state(L, g);
g->frealloc = f;
g->ud = ud;
g->mainthread = L;
g->uvhead.u.l.prev = &g->uvhead;
g->uvhead.u.l.next = &g->uvhead;
g->gcrunning = 0; /* no GC while building state */
g->lastmajormem = 0;
g->strt.size = 0;
g->strt.nuse = 0;
g->strt.hash = NULL;
killa_setnilvalue(&g->l_registry);
killaZ_initbuffer(L, &g->buff);
g->panic = NULL;
g->version = killa_version(NULL);
g->gcstate = killa_GCSpause;
g->allgc = NULL;
g->finobj = NULL;
g->tobefnz = NULL;
g->gray = g->grayagain = NULL;
g->weak = g->ephemeron = g->allweak = NULL;
g->totalbytes = sizeof(LG);
g->GCdebt = 0;
g->gcpause = KILLAI_GCPAUSE;
g->gcmajorinc = KILLAI_GCMAJOR;
g->gcstepmul = KILLAI_GCMUL;
for (i=0; i < KILLA_NUMTAGS; i++) g->mt[i] = NULL;
if (killaD_rawrunprotected(L, f_killaopen, NULL) != KILLA_OK) {
/* memory allocation error: free partial state */
close_state(L);
L = NULL;
}
else
killai_userstateopen(L);
return L;
}
开发者ID:caivega,项目名称:Killa,代码行数:49,代码来源:kstate.c
示例6: tostate
lua_State *luaE_newthread (lua_State *L) {
lua_State *L1 = tostate(luaM_malloc(L, state_size(lua_State)));
luaC_link(L, obj2gco(L1), LUA_TTHREAD);
setthvalue(L, L->top, L1); /* put thread on stack */
incr_top(L);
preinit_state(L1, G(L));
stack_init(L1, L); /* init stack */
setobj2n(L, gt(L1), gt(L)); /* share table of globals */
L1->hookmask = L->hookmask;
L1->basehookcount = L->basehookcount;
L1->hook = L->hook;
resethookcount(L1);
lua_assert(!isdead(G(L), obj2gco(L1)));
L->top--; /* remove thread from stack */
return L1;
}
开发者ID:cls22,项目名称:eLua-PIC32-,代码行数:16,代码来源:lstate.c
示例7: lua_lock
LUA_API lua_State *lua_newthread (lua_State *L) {
lua_State *L1;
lua_lock(L);
luaC_checkGC(L);
L1 = &luaC_newobj(L, LUA_TTHREAD, sizeof(LX), NULL, offsetof(LX, l))->th;
setthvalue(L, L->top, L1);
api_incr_top(L);
preinit_state(L1, G(L));
L1->hookmask = L->hookmask;
L1->basehookcount = L->basehookcount;
L1->hook = L->hook;
resethookcount(L1);
luai_userstatethread(L, L1);
stack_init(L1, L); /* init stack */
lua_unlock(L);
return L1;
}
开发者ID:q3k,项目名称:Cucumber,代码行数:17,代码来源:lstate.c
示例8: killa_lock
KILLA_API killa_State *killa_newthread (killa_State *L) {
killa_State *L1;
killa_lock(L);
killaC_checkGC(L);
L1 = &killaC_newobj(L, KILLA_TTHREAD, sizeof(LX), NULL, offsetof(LX, l))->th;
killa_setthvalue(L, L->top, L1);
killaA_incr_top(L);
preinit_state(L1, KILLA_G(L));
L1->hookmask = L->hookmask;
L1->basehookcount = L->basehookcount;
L1->hook = L->hook;
killa_resethookcount(L1);
killai_userstatethread(L, L1);
stack_init(L1, L); /* init stack */
killa_unlock(L);
return L1;
}
开发者ID:caivega,项目名称:Killa,代码行数:17,代码来源:kstate.c
示例9: sizeof
LUA_API lua_State *lua_open (void) {
lua_State *L;
global_State globalState;
lua_State luaState;
#ifdef _DEBUG
luaState.allocName = "Lua_lua_State";
#endif _DEBUG
luaState.l_G = &globalState;
globalState.reallocFunc = luaHelper_Realloc;
globalState.freeFunc = luaHelper_Free;
globalState.memData = luaHelper_memData;
globalState.nblocks = sizeof(lua_State) + sizeof(global_State); // Bogus.
L = mallocstate(&luaState);
if (L) { /* allocation OK? */
L->tt = LUA_TTHREAD;
L->marked = 0;
L->next = NULL;
#if LUA_REFCOUNT
L->prev = NULL;
L->gclist_head.next = (GCObject*)&L->gclist_tail;
L->gclist_head.prev = NULL;
L->gclist_tail.next = NULL;
L->gclist_tail.prev = (GCObject*)&L->gclist_head;
L->gclist_head.tt = LUA_TNIL;
L->gclist_head.marked = 0;
L->gclist_head.ref = 0;
L->gclist_tail.tt = LUA_TNIL;
L->gclist_tail.marked = 0;
L->gclist_tail.ref = 0;
L->ref = 0;
#else !LUA_REFCOUNT
L->gclist = NULL;
#endif LUA_REFCOUNT
preinit_state(L);
L->l_G = NULL;
if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) {
/* memory allocation error: free partial state */
close_state(L);
L = NULL;
}
}
lua_userstateopen(L);
return L;
}
开发者ID:dodong471520,项目名称:pap,代码行数:44,代码来源:lstate.c
示例10: mallocstate
lua_State *luaE_newthread (lua_State *L) {
lua_State *L1 = mallocstate(L);
luaC_link(L, valtogco(L1), LUA_TTHREAD);
preinit_state(L1);
L1->l_G = L->l_G;
#if LUA_REFCOUNT
L1->gclist_head.next = (GCObject*)&L->gclist_tail;
L1->gclist_head.prev = NULL;
L1->gclist_tail.next = NULL;
L1->gclist_tail.prev = (GCObject*)&L->gclist_head;
L1->gclist_head.tt = LUA_TNIL;
L1->gclist_head.marked = 0;
L1->gclist_head.ref = 0;
L1->gclist_tail.tt = LUA_TNIL;
L1->gclist_tail.marked = 0;
L1->gclist_tail.ref = 0;
L1->ref = 0;
#endif LUA_REFCOUNT
stack_init(L1, L); /* init stack */
setobj2n(gt(L1), gt(L)); /* share table of globals */
return L1;
}
开发者ID:dodong471520,项目名称:pap,代码行数:22,代码来源:lstate.c
示例11: state_size
LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
int i;
lua_State *L;
global_State *g;
#if LUAPLUS_EXTENSIONS
void *l = (*f)(ud, NULL, 0, state_size(LG), "lua_State", 0);
#else
void *l = (*f)(ud, NULL, 0, state_size(LG));
#endif /* LUAPLUS_EXTENSIONS */
if (l == NULL) return NULL;
L = tostate(l);
g = &((LG *)L)->g;
L->next = NULL;
#if LUA_REFCOUNT
L->prev = NULL;
#endif /* LUA_REFCOUNT */
L->tt = LUA_TTHREAD;
g->currentwhite = bit2mask(WHITE0BIT, FIXEDBIT);
L->marked = luaC_white(g);
set2bits(L->marked, FIXEDBIT, SFIXEDBIT);
preinit_state(L, g);
g->frealloc = f;
g->ud = ud;
g->mainthread = L;
g->uvhead.u.l.prev = &g->uvhead;
g->uvhead.u.l.next = &g->uvhead;
g->GCthreshold = 0; /* mark it as unfinished state */
g->strt.size = 0;
g->strt.nuse = 0;
g->strt.hash = NULL;
#if LUA_REFCOUNT
setnilvalue2n(L, registry(L));
#else
setnilvalue(registry(L));
#endif /* LUA_REFCOUNT */
luaZ_initbuffer(L, &g->buff);
g->panic = NULL;
g->gcstate = GCSpause;
g->rootgc = obj2gco(L);
g->sweepstrgc = 0;
g->sweepgc = &g->rootgc;
g->gray = NULL;
g->grayagain = NULL;
g->weak = NULL;
g->tmudata = NULL;
g->totalbytes = sizeof(LG);
g->gcpause = LUAI_GCPAUSE;
g->gcstepmul = LUAI_GCMUL;
g->gcdept = 0;
#if LUAPLUS_EXTENSIONS
g->loadNotifyFunction = NULL;
g->userGCFunction = NULL;
g->gchead_next = &g->gctail_next;
g->gchead_prev = NULL;
g->gctail_next = NULL;
g->gctail_prev = &g->gchead_next;
#endif /* LUAPLUS_EXTENSIONS */
for (i=0; i<NUM_TAGS; i++) g->mt[i] = NULL;
if (luaD_rawrunprotected(L, f_luaopen, NULL) != 0) {
/* memory allocation error: free partial state */
close_state(L);
L = NULL;
}
else
luai_userstateopen(L);
return L;
}
开发者ID:Abyss116,项目名称:luaplus51-all,代码行数:67,代码来源:lstate.c
注:本文中的preinit_state函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论