MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaL_tolstring

Function luaL_tolstring

extlibs/sol3/include/sol/sol.hpp:3162–3194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3160}
3161
3162COMPAT53_API const char *luaL_tolstring(lua_State *L, int idx, size_t *len) {
3163 if (!luaL_callmeta(L, idx, "__tostring")) {
3164 int t = lua_type(L, idx), tt = 0;
3165 char const* name = NULL;
3166 switch (t) {
3167 case LUA_TNIL:
3168 lua_pushliteral(L, "nil");
3169 break;
3170 case LUA_TSTRING:
3171 case LUA_TNUMBER:
3172 lua_pushvalue(L, idx);
3173 break;
3174 case LUA_TBOOLEAN:
3175 if (lua_toboolean(L, idx))
3176 lua_pushliteral(L, "true");
3177 else
3178 lua_pushliteral(L, "false");
3179 break;
3180 default:
3181 tt = luaL_getmetafield(L, idx, "__name");
3182 name = (tt == LUA_TSTRING) ? lua_tostring(L, -1) : lua_typename(L, t);
3183 lua_pushfstring(L, "%s: %p", name, lua_topointer(L, idx));
3184 if (tt != LUA_TNIL)
3185 lua_replace(L, -2);
3186 break;
3187 }
3188 }
3189 else {
3190 if (!lua_isstring(L, -1))
3191 luaL_error(L, "'__tostring' must return a string");
3192 }
3193 return lua_tolstring(L, -1, len);
3194}
3195
3196COMPAT53_API void luaL_requiref(lua_State *L, const char *modname,
3197 lua_CFunction openf, int glb) {

Callers

nothing calls this directly

Calls 11

luaL_callmetaFunction · 0.85
lua_typeFunction · 0.85
lua_pushvalueFunction · 0.85
lua_tobooleanFunction · 0.85
luaL_getmetafieldFunction · 0.85
lua_typenameFunction · 0.85
lua_pushfstringFunction · 0.85
lua_topointerFunction · 0.85
lua_isstringFunction · 0.85
luaL_errorFunction · 0.85
lua_tolstringFunction · 0.85

Tested by

no test coverage detected