Esempio n. 1
0
// Generates a Lua error. The error message (which can actually be a Lua
// value of any type) must be on the stack top. This function does a long
// jump, and therefore never returns.
func (this *State) Error() {
	C.lua_error(this.luastate)

	/*err := this.Tostring(-1)
	  fmt.Println("ERROR: ", err)
	  this.Dostring(`print(debug.traceback())`)
	  panic("goluajit Panic")*/
}
Esempio n. 2
0
File: glua.go Progetto: gooops/glua
func (L *State) getValueByLuaType(i int) (v *rf.Value) {
	switch C.lua_type(L.s, C.int(i+1)) {
	case C.LUA_TBOOLEAN:
		v = L.getValueByType(rf.Bool, i)
	case C.LUA_TNUMBER:
		v = L.getValueByType(rf.Float64, i)
	case C.LUA_TSTRING:
		v = L.getValueByType(rf.String, i)
	case C.LUA_TUSERDATA:
		v = L.getValueByType(rf.Interface, i)
	default:
		L.pushString("Wrong parameters.")
		C.lua_error(L.s)
		v = nil
	}
	return
}
Esempio n. 3
0
File: glua.go Progetto: gooops/glua
//export gofuncCallback
func gofuncCallback(gs interface{}, idx int) (rn int) {
	L := gs.(*State)
	defer func() {
		if e := recover(); e != nil {
			L.pushString(fmt.Sprintf("%v\n", e))
			C.lua_error(L.s)
		}
	}()

	fv := rf.ValueOf(L.lf[idx])
	ft := rf.TypeOf(L.lf[idx])

	// 获取参数
	in := L.getFuncIn(ft)

	out := fv.Call(in)

	// 设置返回值
	L.setFuncOut(ft, out)

	return len(out)
}
Esempio n. 4
0
func (L *State) Error() int { return int(C.lua_error(L.s)) }
Esempio n. 5
0
// Generates a Lua error. The error message (which can actually be a Lua
// value of any type) must be on the stack top. This function does a long
// jump, and therefore never returns.
func (s *State) Error() {
	C.lua_error(s.l)
}