MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / luaL_tolstring

Function luaL_tolstring

src/Chain/libraries/glua/lauxlib.cpp:2444–2480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2442
2443
2444LUALIB_API const char *luaL_tolstring(lua_State *L, int idx, size_t *len) {
2445 if (!luaL_callmeta(L, idx, "__tostring")) { /* no metafield? */
2446 switch (lua_type(L, idx)) {
2447 case LUA_TNUMBER: {
2448 if (lua_isinteger(L, idx))
2449 {
2450 auto value = lua_tointeger(L, idx);
2451 std::string s = std::to_string(value);
2452 lua_pushfstring(L, "%s", s.c_str());
2453 }
2454 else {
2455 auto value = lua_tonumber(L, idx);
2456 std::string s = std::to_string(value);
2457 lua_pushfstring(L, "%s", s.c_str());
2458 }
2459 break;
2460 }
2461 case LUA_TSTRING:
2462 lua_pushvalue(L, idx);
2463 break;
2464 case LUA_TBOOLEAN:
2465 lua_pushstring(L, (lua_toboolean(L, idx) ? "true" : "false"));
2466 break;
2467 case LUA_TNIL:
2468 lua_pushliteral(L, "nil");
2469 break;
2470 default:
2471 auto value_typename = luaL_typename(L, idx);
2472 lua_pushfstring(L, "%s: %d", value_typename,
2473 0);
2474 //lua_pushfstring(L, "%s: %p", luaL_typename(L, idx),
2475 // lua_topointer(L, idx));
2476 break;
2477 }
2478 }
2479 return lua_tolstring(L, -1, len);
2480}
2481
2482void free_lua_table_map(lua_State *L, GluaTableMapP map)
2483{

Callers 4

lualib_http_requestFunction · 0.85
add_sFunction · 0.85
str_formatFunction · 0.85
luaB_tostringFunction · 0.85

Calls 10

luaL_callmetaFunction · 0.85
lua_typeFunction · 0.85
lua_isintegerFunction · 0.85
lua_pushfstringFunction · 0.85
lua_pushvalueFunction · 0.85
lua_pushstringFunction · 0.85
lua_tobooleanFunction · 0.85
lua_tolstringFunction · 0.85
to_stringFunction · 0.50
c_strMethod · 0.45

Tested by

no test coverage detected