Exemplo n.º 1
0
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()
	})
}
Exemplo n.º 2
0
Arquivo: lua.go Projeto: hxyxj/goinfi
func luaGetSubTable(L *C.lua_State, table C.int, key string) (bool, error) {
	pushStringToLua(L, key)
	C.lua_gettable(L, table)
	ltype := C.lua_type(L, -1)
	if ltype == C.LUA_TNIL {
		C.lua_createtable(L, 0, 0)
		// table[key] = {}
		pushStringToLua(L, key)
		C.lua_pushvalue(L, -2)
		C.lua_settable(L, table)
	}
	ltype = C.lua_type(L, -1)
	if ltype != C.LUA_TTABLE {
		C.lua_settop(L, -2)
		return false, fmt.Errorf("field `%v` exist, and it is not a table", key)
	}
	return true, nil
}
Exemplo n.º 3
0
Arquivo: lua.go Projeto: szll/golua
// lua_pushvalue
func (L *State) PushValue(index int) {
	C.lua_pushvalue(L.s, C.int(index))
}
Exemplo n.º 4
0
// Pushes a copy of the element at the given valid index onto the stack.
func (this *State) Pushvalue(index int) {
	C.lua_pushvalue(this.luastate, C.int(index))
}
Exemplo n.º 5
0
// Pushes a copy of the element at the given valid index onto the stack.
func (s *State) Pushvalue(index int) {
	C.lua_pushvalue(s.l, C.int(index))
}