| 394 | |
| 395 | |
| 396 | static int luaB_tostring (lua_State *L) { |
| 397 | luaL_checkany(L, 1); |
| 398 | if (luaL_callmeta(L, 1, "__tostring")) /* is there a metafield? */ |
| 399 | return 1; /* use its value */ |
| 400 | switch (lua_type(L, 1)) { |
| 401 | case LUA_TNUMBER: |
| 402 | lua_pushstring(L, lua_tostring(L, 1)); |
| 403 | break; |
| 404 | case LUA_TSTRING: |
| 405 | lua_pushvalue(L, 1); |
| 406 | break; |
| 407 | case LUA_TBOOLEAN: |
| 408 | lua_pushstring(L, (lua_toboolean(L, 1) ? "true" : "false")); |
| 409 | break; |
| 410 | case LUA_TNIL: |
| 411 | lua_pushliteral(L, "nil"); |
| 412 | break; |
| 413 | default: |
| 414 | lua_pushfstring(L, "%s: %p", luaL_typename(L, 1), lua_topointer(L, 1)); |
| 415 | break; |
| 416 | } |
| 417 | return 1; |
| 418 | } |
| 419 | |
| 420 | |
| 421 | static int luaB_newproxy (lua_State *L) { |
nothing calls this directly
no test coverage detected