galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
LuaPlatform.cpp
Go to the documentation of this file.
1
7
8#include <entt/locator/locator.hpp>
9#include <sol/sol.hpp>
10
13
14#include "../Lua.hpp"
15
16namespace galaxy
17{
18 void Lua::inject_platform() noexcept
19 {
20 auto& lua = entt::locator<sol::state>::value();
21
22 lua.set("GALAXY_DEBUG_BUILD", GALAXY_DEBUG_BUILD);
23
24#ifdef GALAXY_WIN_PLATFORM
25 lua.set("GALAXY_WIN_PLATFORM", true);
26 lua.set("GALAXY_UNIX_PLATFORM", false);
27#elif GALAXY_UNIX_PLATFORM
28 lua.set("GALAXY_WIN_PLATFORM", false);
29 lua.set("GALAXY_UNIX_PLATFORM", true);
30#endif
31
32 auto sub_type = lua.new_usertype<Subprocess>("Subprocess", sol::constructors<Subprocess(), Subprocess(std::string_view)>());
33 sub_type["create"] = &Subprocess::create;
34 sub_type["alive"] = &Subprocess::alive;
35 sub_type["destroy"] = &Subprocess::destroy;
36 sub_type["join"] = &Subprocess::join;
37 sub_type["terminate"] = &Subprocess::terminate;
38
39 lua.set_function("galaxy_seed_random", &platform::seed_random);
40 }
41} // namespace galaxy
static void inject_platform() noexcept
Inject platform stuff into Lua.
Manages a subprocess launched by galaxy.
void terminate() noexcept
Terminate process, killing if alive.
int join() noexcept
Wait for a process to finish execution.
bool alive() noexcept
Check if subprocess is still alive and executing.
void create(std::string_view process, std::span< std::string > args={})
Launch a subprocess.
void destroy() noexcept
Destroy process, preserving if alive.
void seed_random() noexcept
Seed the cstdlib rng algos.
Definition Platform.cpp:19
Application.hpp galaxy.