本文整理汇总了C++中setthvalue函数的典型用法代码示例。如果您正苦于以下问题:C++ setthvalue函数的具体用法?C++ setthvalue怎么用?C++ setthvalue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setthvalue函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: G
LUA_API lua_State *lua_newthread (lua_State *L) {
global_State *g = G(L);
lua_State *L1;
lua_lock(L);
luaC_checkGC(L);
/* create new thread */
L1 = &cast(LX *, luaM_newobject(L, LUA_TTHREAD, sizeof(LX)))->l;
L1->marked = luaC_white(g);
L1->tt = LUA_TTHREAD;
/* link it on list 'allgc' */
L1->next = g->allgc;
g->allgc = obj2gco(L1);
/* anchor it on L stack */
setthvalue(L, L->top, L1);
api_incr_top(L);
preinit_thread(L1, g);
L1->hookmask = L->hookmask;
L1->basehookcount = L->basehookcount;
L1->hook = L->hook;
resethookcount(L1);
/* initialize L1 extra space */
memcpy(lua_getextraspace(L1), lua_getextraspace(g->mainthread),
LUA_EXTRASPACE);
luai_userstatethread(L, L1);
stack_init(L1, L); /* init stack */
lua_unlock(L);
return L1;
}
示例2: lua_pushthread
LUA_API int lua_pushthread (lua_State *L) {
lua_lock(L);
setthvalue(L, L->top, L);
api_incr_top(L);
lua_unlock(L);
return (G(L)->mainthread == L);
}
示例3: LUA_pushthread
LUA_API int LUA_pushthread (LUA_State *L) {
LUA_lock(L);
setthvalue(L, L->top, L);
api_incr_top(L);
LUA_unlock(L);
return (G(L)->mainthread == L);
}
示例4: lua_lock
/* weet:
* 创建一个新的Lua协程
* */
LUA_API lua_State *lua_newthread (lua_State *L) {
lua_State *L1;
lua_lock(L);
luaC_checkGC(L);
L1 = luaE_newthread(L);
setthvalue(L->top, L1);
api_incr_top(L);
lua_unlock(L);
lua_userstateopen(L1); // weet: 一个空的宏
return L1;
}
示例5: lua_newthread
LuaObject LuaState::CreateThread(LuaState* parentState)
{
lua_State* L1 = lua_newthread(parentState->GetCState());
lua_TValue tobject;
setnilvalue2n(L1, &tobject);
setthvalue(parentState->GetCState(), &tobject, L1);
LuaObject retObj = LuaObject((LuaState*)lua_getstateuserdata(L1), &tobject);
setnilvalue(&tobject);
lua_pop(parentState->GetCState(), 1);
return retObj;
}
示例6: ktap_init_registry
static void ktap_init_registry(ktap_state *ks)
{
ktap_value mt;
ktap_table *registry = kp_table_new(ks);
sethvalue(&G(ks)->registry, registry);
kp_table_resize(ks, registry, KTAP_RIDX_LAST, 0);
setthvalue(ks, &mt, ks);
kp_table_setint(ks, registry, KTAP_RIDX_MAINTHREAD, &mt);
sethvalue(&mt, kp_table_new(ks));
kp_table_setint(ks, registry, KTAP_RIDX_GLOBALS, &mt);
}
示例7: init_registry
/*
** Create registry table and its predefined values
*/
static void init_registry (lua_State *L, global_State *g) {
TValue temp;
/* create registry */
Table *registry = luaH_new(L);
sethvalue(L, &g->l_registry, registry);
luaH_resize(L, registry, LUA_RIDX_LAST, 0);
/* registry[LUA_RIDX_MAINTHREAD] = L */
setthvalue(L, &temp, L); /* temp = L */
luaH_setint(L, registry, LUA_RIDX_MAINTHREAD, &temp);
/* registry[LUA_RIDX_GLOBALS] = table of globals */
sethvalue(L, &temp, luaH_new(L)); /* temp = new table (global table) */
luaH_setint(L, registry, LUA_RIDX_GLOBALS, &temp);
}
示例8: init_registry
/*
** Create registry table and its predefined values
*/
static void init_registry (LUA_State *L, global_State *g) {
TValue mt;
/* create registry */
Table *registry = LUAH_new(L);
sethvalue(L, &g->l_registry, registry);
LUAH_resize(L, registry, LUA_RIDX_LAST, 0);
/* registry[LUA_RIDX_MAINTHREAD] = L */
setthvalue(L, &mt, L);
LUAH_setint(L, registry, LUA_RIDX_MAINTHREAD, &mt);
/* registry[LUA_RIDX_GLOBALS] = table of globals */
sethvalue(L, &mt, LUAH_new(L));
LUAH_setint(L, registry, LUA_RIDX_GLOBALS, &mt);
}
示例9: lua_newthread
LuaObject LuaState::CreateThread(LuaState* parentState)
{
lua_State* L1 = lua_newthread(LuaState_to_lua_State(parentState));
lua_TValue tobject;
#if LUA_REFCOUNT
setnilvalue2n(L1, &tobject);
#else
setnilvalue(&tobject);
#endif /* LUA_REFCOUNT */
setthvalue(parentState->GetCState(), &tobject, L1);
LuaObject retObj = LuaObject(lua_State_To_LuaState(L1), &tobject);
setnilvalue(&tobject);
lua_pop(LuaState_to_lua_State(parentState), 1);
return retObj;
}
示例10: 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;
}
示例11: 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;
}