Exemplo n.º 1
0
Arquivo: glua.go Projeto: gooops/glua
// 执行lua脚本
func (L *State) Dofile(fname string) (ok bool) {
	fn := C.CString(fname)
	defer C.free(unsafe.Pointer(fn))

	if C.luaL_loadfile(L.s, fn) == 0 {
		return C.lua_pcall(L.s, 0, C.LUA_MULTRET, 0) == 0
	}
	return false
}
Exemplo n.º 2
0
// luaL_loadfile
func (L *State) LoadFile(filename string) int {
	Cfilename := C.CString(filename)
	defer C.free(unsafe.Pointer(Cfilename))
	return int(C.luaL_loadfile(L.s, Cfilename))
}
Exemplo n.º 3
0
// Loadfile Loads a file as a Lua chunk. This function uses lua_load to load
// the chunk in the file named filename. The first line in the file is ignored
// if it starts with a #
//
// As lua_load, this function only loads the chunk; it does not run it.
//
// http://www.lua.org/manual/5.1/manual.html#luaL_loadfile
func (this *State) Loadfile(filename string) error {
	cs := C.CString(filename)
	defer C.free(unsafe.Pointer(cs))

	return this.geterror(int(C.luaL_loadfile(this.luastate, cs)))
}
Exemplo n.º 4
0
// Loads the specified file as a Lua chunk. The first line in the file is
// ignored if it starts with '#'.
//
// This function only loads the chunk; it does not run it.
func (s *State) Loadfile(filename string) error {
	cs := C.CString(filename)
	defer C.free(unsafe.Pointer(cs))
	r := int(C.luaL_loadfile(s.l, cs))
	return numtoerror(r)
}
Exemplo n.º 5
0
func (L *State) LoadFile(filename string) int {
	return int(C.luaL_loadfile(L.s, C.CString(filename)))
}