| 777 | |
| 778 | |
| 779 | LUA_API int lua_getmetatable (lua_State *L, int objindex) { |
| 780 | const TValue *obj; |
| 781 | Table *mt; |
| 782 | int res = 0; |
| 783 | lua_lock(L); |
| 784 | obj = index2value(L, objindex); |
| 785 | switch (ttype(obj)) { |
| 786 | case LUA_TTABLE: |
| 787 | mt = hvalue(obj)->metatable; |
| 788 | break; |
| 789 | case LUA_TUSERDATA: |
| 790 | mt = uvalue(obj)->metatable; |
| 791 | break; |
| 792 | default: |
| 793 | mt = G(L)->mt[ttype(obj)]; |
| 794 | break; |
| 795 | } |
| 796 | if (mt != NULL) { |
| 797 | sethvalue2s(L, L->top, mt); |
| 798 | api_incr_top(L); |
| 799 | res = 1; |
| 800 | } |
| 801 | lua_unlock(L); |
| 802 | return res; |
| 803 | } |
| 804 | |
| 805 | |
| 806 | LUA_API int lua_getiuservalue (lua_State *L, int idx, int n) { |
no test coverage detected