예제 #1
0
파일: glua.go 프로젝트: 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
}
예제 #2
0
파일: lauxlib.go 프로젝트: 1lann/golua
// 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))
}
예제 #3
0
파일: State.go 프로젝트: rdlaitila/leaf
// 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)))
}
예제 #4
0
파일: state.go 프로젝트: halturin/luajit
// 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)
}
예제 #5
0
파일: lauxlib.go 프로젝트: afitz/golua
func (L *State) LoadFile(filename string) int {
	return int(C.luaL_loadfile(L.s, C.CString(filename)))
}