refactor: Refactorized whole project structure

This commit is contained in:
AURUMVORXX
2025-01-24 22:36:25 +03:00
parent d50f55086b
commit a479b5f85d
321 changed files with 288 additions and 219 deletions

View File

@@ -0,0 +1,51 @@
#ifndef NONUT_CORE_ARRAY_H
#define NONUT_CORE_ARRAY_H
#include "CommonHeader.h"
#include "Utils.h"
#include <sqapi.h>
namespace nonut
{
class Array
{
public:
explicit Array(SQObject object);
~Array();
[[nodiscard]] size_t size() const;
template <typename T>
T get(const String index)
{
HSQUIRRELVM vm = Sqrat::DefaultVM::Get();
T result{};
sq_pushobject(vm, object);
sq_pushstring(vm, index.c_str(), index.length());
if (SQ_FAILED(sq_get(vm, -2)))
{
sq_pop(vm, 1);
return result;
}
if constexpr (std::is_same_v<T, String>)
{
const SQChar* intermediateResult = nullptr;
sq_getstring(vm, -1, &intermediateResult);
result = intermediateResult;
}
else
{
sqGetValue(vm, -1, &result);
}
sq_pop(vm, 2);
return result;
}
private:
SQObject object;
size_t cachedSize;
};
}
#endif // NONUT_CORE_ARRAY_H