Add Call and IsNil
This commit is contained in:
parent
c74ad4bbc9
commit
146b0a51db
14
wrapper.go
14
wrapper.go
|
@ -189,6 +189,7 @@ func (s *State) IsString(index int) bool { return s.GetType(index) == TypeStr
|
||||||
func (s *State) IsNumber(index int) bool { return s.GetType(index) == TypeNumber }
|
func (s *State) IsNumber(index int) bool { return s.GetType(index) == TypeNumber }
|
||||||
func (s *State) IsFunction(index int) bool { return s.GetType(index) == TypeFunction }
|
func (s *State) IsFunction(index int) bool { return s.GetType(index) == TypeFunction }
|
||||||
func (s *State) IsTable(index int) bool { return s.GetType(index) == TypeTable }
|
func (s *State) IsTable(index int) bool { return s.GetType(index) == TypeTable }
|
||||||
|
func (s *State) IsNil(index int) bool { return s.GetType(index) == TypeNil }
|
||||||
func (s *State) ToBoolean(index int) bool { return C.lua_toboolean(s.L, C.int(index)) != 0 }
|
func (s *State) ToBoolean(index int) bool { return C.lua_toboolean(s.L, C.int(index)) != 0 }
|
||||||
func (s *State) ToNumber(index int) float64 { return float64(C.lua_tonumber(s.L, C.int(index))) }
|
func (s *State) ToNumber(index int) float64 { return float64(C.lua_tonumber(s.L, C.int(index))) }
|
||||||
func (s *State) ToString(index int) string {
|
func (s *State) ToString(index int) string {
|
||||||
|
@ -327,3 +328,16 @@ func (s *State) AddPackagePath(path string) error {
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *State) Call(nargs, nresults int) error {
|
||||||
|
status := C.lua_pcall(s.L, C.int(nargs), C.int(nresults), 0)
|
||||||
|
if status != 0 {
|
||||||
|
err := &LuaError{
|
||||||
|
Code: int(status),
|
||||||
|
Message: s.ToString(-1),
|
||||||
|
}
|
||||||
|
s.Pop(1)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user