func (self *RefLua) init(state State, lobject int) { self.VM = state.VM C.lua_pushvalue(state.L, C.int(lobject)) refvalue := C.luaL_ref(state.L, C.LUA_REGISTRYINDEX) self.Ref = int(refvalue) runtime.SetFinalizer(self, func(r *RefLua) { r.Release() }) }
func (sinfo *structInfo) makeFieldsIndexCache(vm *VM) { L := vm.globalL sinfo.cache = make(map[*C.char]*structField, len(sinfo.fields)) sinfo.lref = make(map[string]int, len(sinfo.fields)) for key, field := range sinfo.fields { pushStringToLua(L, key) pstr := C.lua_tolstring(L, -1, nil) sinfo.cache[pstr] = field sinfo.lref[key] = int(C.luaL_ref(L, C.LUA_REGISTRYINDEX)) } }
// luaL_ref func (L *State) Ref(t int) int { return int(C.luaL_ref(L.s, C.int(t))) }