2021-11-18 15:19:54 +00:00
|
|
|
#include "content.hpp"
|
|
|
|
|
2023-01-29 16:06:09 +00:00
|
|
|
namespace LuaUi::Content
|
2021-11-18 15:19:54 +00:00
|
|
|
{
|
2023-01-29 16:06:09 +00:00
|
|
|
namespace
|
2021-11-18 15:19:54 +00:00
|
|
|
{
|
2023-01-29 16:06:09 +00:00
|
|
|
sol::table loadMetatable(sol::state_view sol)
|
2021-11-18 15:19:54 +00:00
|
|
|
{
|
2023-01-29 16:06:09 +00:00
|
|
|
std::string scriptBody =
|
|
|
|
#include "content.lua"
|
|
|
|
;
|
|
|
|
auto result = sol.safe_script(scriptBody);
|
|
|
|
if (result.get_type() != sol::type::table)
|
|
|
|
throw std::logic_error("Expected a meta table");
|
|
|
|
return result.get<sol::table>();
|
2021-11-18 15:19:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-29 16:06:09 +00:00
|
|
|
sol::protected_function makeFactory(sol::state_view sol)
|
2021-11-18 15:19:54 +00:00
|
|
|
{
|
2023-01-29 16:06:09 +00:00
|
|
|
sol::table metatable = loadMetatable(sol);
|
|
|
|
if (metatable["new"].get_type() != sol::type::function)
|
|
|
|
throw std::logic_error("Expected function");
|
|
|
|
return metatable["new"].get<sol::protected_function>();
|
2021-11-18 15:19:54 +00:00
|
|
|
}
|
|
|
|
|
2023-01-29 16:06:09 +00:00
|
|
|
int64_t View::sInstanceCount = 0;
|
2021-11-18 15:19:54 +00:00
|
|
|
|
2023-01-29 16:06:09 +00:00
|
|
|
int64_t getInstanceCount()
|
2021-11-18 15:19:54 +00:00
|
|
|
{
|
2023-01-29 16:06:09 +00:00
|
|
|
return View::sInstanceCount;
|
2021-11-18 15:19:54 +00:00
|
|
|
}
|
|
|
|
}
|