MCPcopy Create free account
hub / github.com/defold/defold / JsonToLuaInternal

Function JsonToLuaInternal

engine/script/src/script_json.cpp:49–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47 */
48
49 static int JsonToLuaInternal(lua_State* L, int options_index, const char* json, size_t json_len, int protected_mode)
50 {
51 int top = lua_gettop(L);
52 char buffer[256] = {0};
53 int ret = lua_cjson_decode(L, json, json_len, options_index, protected_mode, buffer, sizeof(buffer));
54 if (ret != 1)
55 {
56 lua_pop(L, lua_gettop(L) - top);
57 }
58
59 if (protected_mode)
60 {
61 assert(top + 1 == lua_gettop(L));
62 }
63 else if(!protected_mode && (ret == 0)) // let's restore the stack if we couldn't create
64 {
65 int num_to_pop = lua_gettop(L) - top;
66 lua_pop(L, num_to_pop);
67
68 dmLogError("%s", buffer);
69 }
70 return ret;
71 }
72
73 int JsonToLua(lua_State* L, const char* json, size_t json_len)
74 {

Callers 2

JsonToLuaFunction · 0.85
Json_DecodeFunction · 0.85

Calls 3

lua_gettopFunction · 0.85
lua_cjson_decodeFunction · 0.85
assertFunction · 0.50

Tested by

no test coverage detected