#include #include #include #include "Dictionary.h" namespace py = pybind11; Sqrat::Table* PyDictionary::toSqObject(py::dict value) { Sqrat::Table* result = new Sqrat::Table(Sqrat::DefaultVM::Get()); HSQUIRRELVM vm = Sqrat::DefaultVM::Get(); for(auto item : value) { std::string key = item.first.cast(); if (py::isinstance(item.second)) result->SetValue(key.c_str(), item.second.cast().c_str()); else if (py::isinstance(item.second)) result->SetValue(key.c_str(), item.second.cast()); else if (py::isinstance(item.second)) result->SetValue(key.c_str(), item.second.cast()); else if (py::isinstance(item.second)) result->SetValue(key.c_str(), item.second.cast()); else if (py::isinstance(item.second)) { Sqrat::Table *pTable = PyDictionary::toSqObject(item.second.cast()); sq_pushobject(vm, result->GetObject()); sq_pushstring(vm, key.c_str(), -1); sq_pushobject(vm, pTable->GetObject()); sq_newslot(vm, -3, false); sq_pop(vm,1); delete pTable; } } return result; };