MCPcopy Create free account
hub / github.com/Tencent/UnLua / toValue

Function toValue

Plugins/UnLuaExtensions/LuaRapidjson/Source/src/values.cpp:19–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17
18
19 Value toValue(lua_State* L, int idx, int depth, Allocator& allocator) {
20 int t = lua_type(L, idx);
21 switch (t) {
22 case LUA_TBOOLEAN:
23 return Value(lua_toboolean(L, idx) != 0);
24 case LUA_TNUMBER:
25 return NumberValue(L, idx);
26 case LUA_TSTRING:
27 return StringValue(L, idx, allocator);
28 case LUA_TTABLE:
29 return TableValue(L, idx, depth + 1, allocator);
30 case LUA_TNIL:
31 return Value();
32 case LUA_TLIGHTUSERDATA:
33 if (isnull(L, idx))
34 return Value();
35 // otherwise fall thought
36 case LUA_TFUNCTION: // fall thought
37 case LUA_TUSERDATA: // fall thought
38 case LUA_TTHREAD: // fall thought
39 case LUA_TNONE: // fall thought
40 default:
41 luaL_error(L, "value type %s is not a valid json value", lua_typename(L, t));
42 return Value(); // Just make compiler happy
43 }
44 }
45
46 Value NumberValue(lua_State* L, int idx) {
47 int64_t integer;

Callers 3

Document_setFunction · 0.70
ObjectValueFunction · 0.70
ArrayValueFunction · 0.70

Calls 8

lua_typeFunction · 0.85
lua_tobooleanFunction · 0.85
NumberValueFunction · 0.85
StringValueFunction · 0.85
TableValueFunction · 0.85
isnullFunction · 0.85
luaL_errorFunction · 0.85
lua_typenameFunction · 0.85

Tested by

no test coverage detected