sandbox
Loading...
Searching...
No Matches
scripting_module.hpp
1// SPDX-License-Identifier: MIT
2#ifndef LIBSBX_SCRIPTING_SCRIPTING_MODULE_HPP_
3#define LIBSBX_SCRIPTING_SCRIPTING_MODULE_HPP_
4
5#include <memory>
6#include <optional>
7#include <utility>
8#include <filesystem>
9#include <unordered_map>
10#include <string>
11#include <vector>
12
13#include <libsbx/utility/hashed_string.hpp>
14
15#include <libsbx/core/module.hpp>
16
17#include <libsbx/scenes/node.hpp>
18#include <libsbx/scenes/scenes_module.hpp>
19
20#include <libsbx/filesystem/filesystem_module.hpp>
21
22#include <libsbx/scripting/managed/runtime.hpp>
23
24namespace sbx::scripting {
25
26struct scripts {
27 std::vector<managed::object> instances;
28}; // struct scripts
29
31 std::string type_name;
32 std::string method_name;
33 void* function;
34}; // struct internal_call
35
36class scripting_module final : public core::module<scripting_module> {
37
38 inline static const auto is_registered = register_module(stage::normal, dependencies<scenes::scenes_module, filesystem::filesystem_module>{});
39
40public:
41
43
44 ~scripting_module() override;
45
46 auto update() -> void override;
47
48 auto load_assembly(const std::filesystem::path& assembly_path, std::initializer_list<internal_call> bindings = {}) -> void;
49
50 auto instantiate(const scenes::node node, std::string_view class_name) -> managed::object;
51
52private:
53
54 static auto _exception_callback(std::string_view message) -> void {
55 throw utility::runtime_error{"{}", message};
56 }
57
58 std::filesystem::path _assembly_path;
59
62 scripting::managed::assembly _core_assembly;
63
64}; // class scripting_module
65
66} // namespace sbx::scripting
67
68#endif // LIBSBX_SCRIPTING_SCRIPTING_MODULE_HPP_
Definition: tests.cpp:6
Definition: module.hpp:92
Definition: assembly.hpp:27
Definition: object.hpp:89
Definition: runtime.hpp:35
Definition: scripting_module.hpp:36
Definition: scripting_module.hpp:30
Definition: scripting_module.hpp:26
Definition: exception.hpp:18