Example #1
0
File: glua.go Project: 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
}
Example #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))
}
Example #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)))
}
Example #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)
}
Example #5
0
func (L *State) LoadFile(filename string) int {
	return int(C.luaL_loadfile(L.s, C.CString(filename)))
}