MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaL_tolstring

Function luaL_tolstring

freebsd/contrib/openzfs/module/lua/lauxlib.c:593–613  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

591
592
593LUALIB_API const char *luaL_tolstring (lua_State *L, int idx, size_t *len) {
594 if (!luaL_callmeta(L, idx, "__tostring")) { /* no metafield? */
595 switch (lua_type(L, idx)) {
596 case LUA_TNUMBER:
597 case LUA_TSTRING:
598 lua_pushvalue(L, idx);
599 break;
600 case LUA_TBOOLEAN:
601 lua_pushstring(L, (lua_toboolean(L, idx) ? "true" : "false"));
602 break;
603 case LUA_TNIL:
604 lua_pushliteral(L, "nil");
605 break;
606 default:
607 lua_pushfstring(L, "%s: %p", luaL_typename(L, idx),
608 lua_topointer(L, idx));
609 break;
610 }
611 }
612 return lua_tolstring(L, -1, len);
613}
614
615
616/*

Callers 2

luaB_tostringFunction · 0.85
str_formatFunction · 0.85

Calls 8

luaL_callmetaFunction · 0.70
lua_typeFunction · 0.70
lua_pushvalueFunction · 0.70
lua_pushstringFunction · 0.70
lua_tobooleanFunction · 0.70
lua_pushfstringFunction · 0.70
lua_topointerFunction · 0.70
lua_tolstringFunction · 0.70

Tested by

no test coverage detected