Skip to content

Commit

Permalink
Updated to use dmScript::LuaToJson()
Browse files Browse the repository at this point in the history
  • Loading branch information
AGulev committed Nov 2, 2022
1 parent b8836dc commit a5e748b
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions defunityads/src/unityads_callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,9 @@ namespace dmUnityAds {
}

lua_pushnumber(L, type);
bool is_fail = false;
dmJson::Document doc;
dmJson::Result r = dmJson::Parse(json, &doc);
if (r == dmJson::RESULT_OK && doc.m_NodeCount > 0)
{
char error_str_out[128];
if (dmScript::JsonToLua(L, &doc, 0, error_str_out, sizeof(error_str_out)) < 0)
{
dmLogError("Failed converting object JSON to Lua; %s", error_str_out);
is_fail = true;
}
}
else
{
dmLogError("Failed to parse JSON object(%d): (%s)", r, json);
is_fail = true;
}
dmJson::Free(&doc);
if (is_fail)
{
lua_pop(L, 2);
assert(top == lua_gettop(L));
return;
}

int number_of_arguments = 3;
dmScript::JsonToLua(L, json, strlen(json)); // throws lua error if it fails

int ret = dmScript::PCall(L, number_of_arguments, 0);
int ret = dmScript::PCall(L, 3, 0);
(void)ret;
dmScript::TeardownCallback(m_luaCallback);

Expand Down

0 comments on commit a5e748b

Please sign in to comment.