コード例 #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)))
}