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