| 803 | |
| 804 | |
| 805 | LUA_API int lua_getmetatable (lua_State *L, int objindex) { |
| 806 | const TValue *obj; |
| 807 | Table *mt; |
| 808 | int res = 0; |
| 809 | lua_lock(L); |
| 810 | obj = index2value(L, objindex); |
| 811 | switch (ttype(obj)) { |
| 812 | case LUA_TTABLE: |
| 813 | mt = hvalue(obj)->metatable; |
| 814 | break; |
| 815 | case LUA_TUSERDATA: |
| 816 | mt = uvalue(obj)->metatable; |
| 817 | break; |
| 818 | default: |
| 819 | mt = G(L)->mt[ttype(obj)]; |
| 820 | break; |
| 821 | } |
| 822 | if (mt != NULL) { |
| 823 | sethvalue2s(L, L->top.p, mt); |
| 824 | api_incr_top(L); |
| 825 | res = 1; |
| 826 | } |
| 827 | lua_unlock(L); |
| 828 | return res; |
| 829 | } |
| 830 | |
| 831 | |
| 832 | LUA_API int lua_getiuservalue (lua_State *L, int idx, int n) { |
no test coverage detected