c/lua:coroutine continuation

This commit is contained in:
luoliwoshang
2024-08-25 15:31:10 +08:00
parent cf8a170133
commit 3e932c9bdf
4 changed files with 120 additions and 7 deletions

View File

@@ -23,6 +23,14 @@ const (
// ** space after that to help overflow detection)
// */
const (
REGISTRYINDEX = -MAXSTACK - 1000
)
func Upvalueindex(i c.Int) c.Int {
return c.Int(REGISTRYINDEX) - i
}
// /* thread status */
const (
OK = 0
@@ -438,9 +446,19 @@ func (L *State) Isnoneornil(n c.Int) bool { return L.Type(n) <= 0 }
// #define lua_pushliteral(L, s) lua_pushstring(L, "" s)
// #define lua_pushglobaltable(L) ((void)lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS))
// #define lua_insert(L,idx) lua_rotate(L, (idx), 1)
// #define lua_remove(L,idx) (lua_rotate(L, (idx), -1), lua_pop(L, 1))
// #define lua_replace(L,idx) (lua_copy(L, -1, (idx)), lua_pop(L, 1))
func (L *State) Insert(idx c.Int) {
L.Rotate(idx, 1)
}
func (L *State) Remove(idx c.Int) {
L.Rotate(idx, -1)
L.Pop(1)
}
func (L *State) Replace(idx c.Int) {
L.Copy(-1, idx)
L.Pop(1)
}
// /* }============================================================== */
@@ -478,10 +496,6 @@ const (
// /*
// ** Event masks
// */
// #define LUA_MASKCALL (1 << LUA_HOOKCALL)
// #define LUA_MASKRET (1 << LUA_HOOKRET)
// #define LUA_MASKLINE (1 << LUA_HOOKLINE)
// #define LUA_MASKCOUNT (1 << LUA_HOOKCOUNT)
const (
MASKCALL = 1 << HOOKCOUNT