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)
| 1046 | // |
| 1047 | // http://www.lua.org/manual/5.2/manual.html#lua_getmetatable |
| 1048 | func (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. |