plugify 1.0.0.0
Loading...
Searching...
No Matches
language_module.hpp
1#pragma once
2
3#include <array>
4#include <cstring>
5#include <memory>
6#include <string>
7#include <variant>
8#include <vector>
9
10#include "method.hpp"
11#include "mem_addr.hpp"
12#include "date_time.hpp"
13
14namespace plugify {
15 class PluginHandle;
16 class ModuleHandle;
17 class MethodHandle;
18 class IPlugifyProvider;
19
26 struct ErrorData {
27 std::vector<char> error;
28
29 ErrorData(std::string_view str) {
30 error.assign(str.begin(), str.end());
31 if (error.back() != 0) {
32 error.emplace_back('\0');
33 }
34 }
35 };
36
44 MethodTable table;
45 };
46
54 std::vector<MethodData> methods;
55 MemAddr data;
57 };
58
65 using InitResult = std::variant<InitResultData, ErrorData>;
66
73 using LoadResult = std::variant<LoadResultData, ErrorData>;
74
82 protected:
83 ~ILanguageModule() = default;
84
85 public:
92 virtual InitResult Initialize(std::weak_ptr<IPlugifyProvider> provider, ModuleHandle module) = 0;
93
97 virtual void Shutdown() = 0;
98
103 virtual void OnUpdate(DateTime dt) = 0;
104
110 virtual LoadResult OnPluginLoad(PluginHandle plugin) = 0;
111
116 virtual void OnPluginStart(PluginHandle plugin) = 0;
117
123 virtual void OnPluginUpdate(PluginHandle plugin, DateTime dt) = 0;
124
129 virtual void OnPluginEnd(PluginHandle plugin) = 0;
130
135 virtual void OnMethodExport(PluginHandle plugin) = 0;
136
141 virtual bool IsDebugBuild() = 0;
142 };
143} // namespace plugify
Interface for user-implemented language modules.
virtual bool IsDebugBuild()=0
Determine if language module is build with debugging mode.
virtual void OnPluginUpdate(PluginHandle plugin, DateTime dt)=0
Handle plugin update event.
virtual void Shutdown()=0
Shutdown the language module.
virtual void OnPluginEnd(PluginHandle plugin)=0
Handle plugin end event.
virtual LoadResult OnPluginLoad(PluginHandle plugin)=0
Handle plugin load event.
virtual void OnMethodExport(PluginHandle plugin)=0
Handle method export event.
virtual void OnUpdate(DateTime dt)=0
Handle actions to be performed on each frame.
virtual void OnPluginStart(PluginHandle plugin)=0
Handle plugin start event.
virtual InitResult Initialize(std::weak_ptr< IPlugifyProvider > provider, ModuleHandle module)=0
Initialize the language module.
A wrapper class for memory addresses, providing utility functions for pointer manipulation.
Definition mem_addr.hpp:11
Handle wrapper to access language module's information.
Definition module.hpp:39
Handle wrapper to access plugin's information.
Definition plugin.hpp:46
Holds information about an error.
std::vector< char > error
Description of the error.
Holds information about the initialization result.
Holds information about the load result.
MethodTable table
User data.
std::vector< MethodData > methods
Methods exported by the loaded plugin.
Represents a table of method availability flags.
Definition method.hpp:194