| 191 | |
| 192 | |
| 193 | int luaL_typeerror (lua_State *L, int arg, const char *tname) { |
| 194 | const char *msg; |
| 195 | const char *typearg; /* name for the type of the actual argument */ |
| 196 | if (luaL_getmetafield(L, arg, "__name") == LUA_TSTRING) |
| 197 | typearg = lua_tostring(L, -1); /* use the given type name */ |
| 198 | else if (lua_type(L, arg) == LUA_TLIGHTUSERDATA) |
| 199 | typearg = "light userdata"; /* special name for messages */ |
| 200 | else |
| 201 | typearg = luaL_typename(L, arg); /* standard name */ |
| 202 | msg = lua_pushfstring(L, "%s expected, got %s", tname, typearg); |
| 203 | return luaL_argerror(L, arg, msg); |
| 204 | } |
| 205 | |
| 206 | |
| 207 | static void tag_error (lua_State *L, int arg, int tag) { |
no test coverage detected