| 732 | |
| 733 | |
| 734 | LUA_API int lua_getmetatable (lua_State *L, int objindex) { |
| 735 | const TValue *obj; |
| 736 | Table *mt; |
| 737 | int res = 0; |
| 738 | lua_lock(L); |
| 739 | obj = index2value(L, objindex); |
| 740 | switch (ttype(obj)) { |
| 741 | case LUA_TTABLE: |
| 742 | mt = hvalue(obj)->metatable; |
| 743 | break; |
| 744 | case LUA_TUSERDATA: |
| 745 | mt = uvalue(obj)->metatable; |
| 746 | break; |
| 747 | default: |
| 748 | mt = G(L)->mt[ttype(obj)]; |
| 749 | break; |
| 750 | } |
| 751 | if (mt != NULL) { |
| 752 | sethvalue2s(L, L->top, mt); |
| 753 | api_incr_top(L); |
| 754 | res = 1; |
| 755 | } |
| 756 | lua_unlock(L); |
| 757 | return res; |
| 758 | } |
| 759 | |
| 760 | |
| 761 | LUA_API int lua_getiuservalue (lua_State *L, int idx, int n) { |
no test coverage detected