| 180 | |
| 181 | |
| 182 | static int typeerror (lua_State *L, int arg, const char *tname) { |
| 183 | const char *msg; |
| 184 | const char *typearg; /* name for the type of the actual argument */ |
| 185 | if (luaL_getmetafield(L, arg, "__name") == LUA_TSTRING) |
| 186 | typearg = lua_tostring(L, -1); /* use the given type name */ |
| 187 | else if (lua_type(L, arg) == LUA_TLIGHTUSERDATA) |
| 188 | typearg = "light userdata"; /* special name for messages */ |
| 189 | else |
| 190 | typearg = luaL_typename(L, arg); /* standard name */ |
| 191 | msg = lua_pushfstring(L, "%s expected, got %s", tname, typearg); |
| 192 | return luaL_argerror(L, arg, msg); |
| 193 | } |
| 194 | |
| 195 | |
| 196 | static void tag_error (lua_State *L, int arg, int tag) { |
no test coverage detected