Esempio n. 1
0
func main() {

	L := C.luaL_newstate()
	defer C.lua_close(L)

	C.luaL_openlibs(L) /* Load Lua libraries */
	C.luaopen_cmsgpack(L)

	sumS := C.CString(sum)
	defer C.free(unsafe.Pointer(sumS))

	C.luaL_loadstring(L, sumS)

	msg, _ := msgpack.Marshal([]int{1, 2, 3, 4, 5, 6})
	C.lua_pushstring(L, cptr(msg))

	dstr := C.CString("mpdata")
	defer C.free(unsafe.Pointer(dstr))
	C.luaSetglobal(L, dstr)

	C.luaExecute(L)

	sum := C.lua_tonumber(L, -1)

	fmt.Println(sum) // Output: 21
}
Esempio n. 2
0
// Closes the lua context.
func (e *ExecutionEngine) Destroy() {
	if e.state != nil {
		C.lua_close(e.state)
		e.state = nil
	}
	if e.iterator != nil {
		e.SetIterator(nil)
	}
}
Esempio n. 3
0
File: lua.go Progetto: szll/golua
// lua_close
func (L *State) Close() {
	C.lua_close(L.s)
}
Esempio n. 4
0
// Destroys all objects in the given Lua state (calling the corresponding
// garbage-collection metamethods, if any) and frees all dynamic memory
// used by this state. On several platforms, you may not need to call
// this function, because all resources are naturally released when the
// host program ends. On the other hand, long-running programs, such as
// a daemon or a web server, might need to release states as soon as they
// are not needed, to avoid growing too large.
func (this *State) Close() {
	C.lua_close(this.luastate)
}
Esempio n. 5
0
// lua_close
func (L *State) Close() {
	C.lua_close(L.s)
	unregisterGoState(L)
}
Esempio n. 6
0
// Destroys all objects in the given Lua state (calling the corresponding
// garbage-collection metamethods, if any) and frees all dynamic memory
// used by this state. On several platforms, you may not need to call
// this function, because all resources are naturally released when the
// host program ends. On the other hand, long-running programs, such as
// a daemon or a web server, might need to release states as soon as they
// are not needed, to avoid growing too large.
func (s *State) Close() {
	C.lua_close(s.l)
}
Esempio n. 7
0
File: lua.go Progetto: reusee/lua
// Close close the lua vm
func (l *Lua) Close() {
	C.lua_close(l.State)
}
Esempio n. 8
0
File: glua.go Progetto: gooops/glua
// 释放lua_stat
func (L *State) free() {
	log.Printf("Free %v.\n", *L)
	C.lua_close(L.s)
}
Esempio n. 9
0
File: lua.go Progetto: hxyxj/goinfi
func (vm *VM) Close() {
	C.lua_close(vm.globalL)
	vm.globalL = nil
}
Esempio n. 10
0
File: core.go Progetto: vron/lua
func Close(s *State) {
	C.lua_close((*C.lua_State)(s))
}