add metatable methods
This commit is contained in:
parent
83134f3dbc
commit
fc7958312d
14
wrapper.go
14
wrapper.go
@ -33,6 +33,10 @@ static int execute_with_results(lua_State *L, const char *code, int store_result
|
||||
if (status != 0) return status;
|
||||
return lua_pcall(L, 0, store_results ? LUA_MULTRET : 0, 0);
|
||||
}
|
||||
|
||||
static int has_metatable(lua_State *L, int index) {
|
||||
return lua_getmetatable(L, index);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
@ -464,3 +468,13 @@ func (s *State) AddPackagePath(path string) error {
|
||||
code := fmt.Sprintf(`package.path = package.path .. ";%s"`, path)
|
||||
return s.DoString(code)
|
||||
}
|
||||
|
||||
// SetMetatable sets the metatable for the value at the given index
|
||||
func (s *State) SetMetatable(index int) {
|
||||
C.lua_setmetatable(s.L, C.int(index))
|
||||
}
|
||||
|
||||
// GetMetatable gets the metatable of the value at the given index
|
||||
func (s *State) GetMetatable(index int) bool {
|
||||
return C.lua_getmetatable(s.L, C.int(index)) != 0
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user