Files
PyG2O/src/sqcontainers.cpp
AURUMVORXX bb51677592 fix: Crash on adding name key into kwargs dictionary
+ Changed file structure for events
2024-11-04 05:11:15 +03:00

43 lines
1.1 KiB
C++

#include <sqapi.h>
#include <pybind11/embed.h>
#include "sqcontainers.h"
namespace py = pybind11;
using namespace pybind11::literals;
py::dict sqParseTable(Sqrat::Table tab)
{
py::dict result;
Sqrat::Object::iterator tabIterator;
int i = 0;
while (tab.Next(tabIterator))
{
HSQOBJECT key = tabIterator.getKey();
HSQOBJECT value = tabIterator.getValue();
if (key._type != OT_STRING)
continue;
switch(value._type)
{
case OT_STRING:
result[sq_objtostring(&key)] = sq_objtostring(&value);
break;
case OT_INTEGER:
result[sq_objtostring(&key)] = sq_objtointeger(&value);
break;
case OT_FLOAT:
result[sq_objtostring(&key)] = sq_objtofloat(&value);
break;
case OT_TABLE:
result[sq_objtostring(&key)] = sqParseTable(Sqrat::Table(value));
break;
default:
continue;
}
}
return result;
}