MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / luaL_tolstring

Function luaL_tolstring

Source/Misc/luabind/src/lua51compat.cpp:35–56  ·  view source on GitHub ↗

Taken (with slightly adapted formatting) from Lua 5.2.3: ** $Id: lauxlib.c,v 1.248.1.1 2013/04/12 18:48:47 roberto Exp $ ** Auxiliary functions for building Lua libraries * Copyright (C) 1994-2013 Lua.org, PUC-Rio. * * Permission is hereby granted, free of charge, to any person obtaining * a copy of this software and associated documentation files (the * "Software"), to deal in the Software withou

Source from the content-addressed store, hash-verified

33* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34*/
35LUABIND_API char const* luaL_tolstring (lua_State* L, int idx, size_t* len)
36{
37 if (!luaL_callmeta(L, idx, "__tostring")) { /* no metafield? */
38 switch (lua_type(L, idx)) {
39 case LUA_TNUMBER:
40 case LUA_TSTRING:
41 lua_pushvalue(L, idx);
42 break;
43 case LUA_TBOOLEAN:
44 lua_pushstring(L, (lua_toboolean(L, idx) ? "true" : "false"));
45 break;
46 case LUA_TNIL:
47 lua_pushliteral(L, "nil");
48 break;
49 default:
50 lua_pushfstring(L, "%s: %p", luaL_typename(L, idx),
51 lua_topointer(L, idx));
52 break;
53 }
54 }
55 return lua_tolstring(L, -1, len);
56}
57
58#endif // LUA_VERSION_NUM < 502

Callers 1

value_to_stringFunction · 0.85

Calls 8

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

Tested by

no test coverage detected