| 695 | |
| 696 | |
| 697 | LUA_API int lua_getmetatable (lua_State *L, int objindex) { |
| 698 | const TValue *obj; |
| 699 | Table *mt; |
| 700 | int res = 0; |
| 701 | lua_lock(L); |
| 702 | obj = index2addr(L, objindex); |
| 703 | switch (ttnov(obj)) { |
| 704 | case LUA_TTABLE: |
| 705 | mt = hvalue(obj)->metatable; |
| 706 | break; |
| 707 | case LUA_TUSERDATA: |
| 708 | mt = uvalue(obj)->metatable; |
| 709 | break; |
| 710 | default: |
| 711 | mt = G(L)->mt[ttnov(obj)]; |
| 712 | break; |
| 713 | } |
| 714 | if (mt != NULL) { |
| 715 | sethvalue(L, L->top, mt); |
| 716 | api_incr_top(L); |
| 717 | res = 1; |
| 718 | } |
| 719 | lua_unlock(L); |
| 720 | return res; |
| 721 | } |
| 722 | |
| 723 | |
| 724 | LUA_API int lua_getuservalue (lua_State *L, int idx) { |
no test coverage detected