MCPcopy Index your code
hub / github.com/Shopify/go-lua / MetaTable

Method MetaTable

lua.go:1048–1063  ·  view source on GitHub ↗

MetaTable pushes onto the stack the metatable of the value at index. If the value at index does not have a metatable, the function returns false and nothing is put onto the stack. http://www.lua.org/manual/5.2/manual.html#lua_getmetatable

(index int)

Source from the content-addressed store, hash-verified

1046//
1047// http://www.lua.org/manual/5.2/manual.html#lua_getmetatable
1048func (l *State) MetaTable(index int) bool {
1049 var mt *table
1050 switch v := l.indexToValue(index).(type) {
1051 case *table:
1052 mt = v.metaTable
1053 case *userData:
1054 mt = v.metaTable
1055 default:
1056 mt = l.global.metaTable(v)
1057 }
1058 if mt == nil {
1059 return false
1060 }
1061 l.apiPush(mt)
1062 return true
1063}
1064
1065// UserValue pushes onto the stack the Lua value associated with the userdata
1066// at index. This value must be a table or nil.

Callers 4

debug.goFile · 0.80
base.goFile · 0.80
MetaFieldFunction · 0.80
TestUserDataFunction · 0.80

Calls 3

indexToValueMethod · 0.95
apiPushMethod · 0.95
metaTableMethod · 0.80

Tested by 1

TestUserDataFunction · 0.64