Beispiel #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")*/
}
Beispiel #2
0
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
}
Beispiel #3
0
//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)
}
Beispiel #4
0
func (L *State) Error() int { return int(C.lua_error(L.s)) }
Beispiel #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)
}