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["kill"] = &Subprocess::kill;
35 sub_type["wait"] = &Subprocess::wait;
36
37 lua.set_function("galaxy_seed_random", &platform::seed_random);
38 lua.set_function("galaxy_set_metadata", &platform::set_metadata);
39 lua.set_function("galaxy_set_hint", &platform::set_hint);
40 }
41} // namespace galaxy
static void inject_platform() noexcept
Inject platform stuff into Lua.
Manages a subprocess launched by galaxy.
void kill() noexcept
Terminates process.
void create(std::string_view process, std::span< std::string > args={})
Launch a subprocess.
bool wait(const bool block) noexcept
Wait for a process to finish execution.
void seed_random() noexcept
Seed the cstdlib rng algos.
Definition Platform.cpp:20
void set_metadata(const char *type, const char *value) noexcept
Sets metadata.
Definition Platform.cpp:25
void set_hint(const char *hint, const char *value) noexcept
Sets SDL hints.
Definition Platform.cpp:30
Animated.cpp galaxy.
Definition Animated.cpp:16