-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRuntimePatchingSystem.h
126 lines (98 loc) · 3.68 KB
/
RuntimePatchingSystem.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*******************************************************************
* \file RuntimePatchingSystem.h
* \brief Documentation for the API functions
*
* \author gynt
* \date July 2021
*********************************************************************/
/**
* @mainpage Runtime Patching System overview.
*
* @section Overview
*/
#pragma once
#ifdef RUNTIMEPATCHINGLIBRARY_EXPORTS
#define RUNTIMEPATCHINGSYSTEM_API __declspec(dllexport)
#else
#define RUNTIMEPATCHINGSYSTEM_API __declspec(dllimport)
#endif
#include "lua.hpp"
#include <string>
/**
* Initializes a lua environment. Registers RPS lua functions in that environment.
* @param bootstrapFilePath path of the bootstrap lua file.
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_initialize(std::string bootstrapFilePath);
/**
* Initialize a lua state and run the bootstrap file. The lua RPS functions are put in the global namespace. Optional redirection of `print` output to std::cout
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_initialize(std::string bootstrapFilePath, bool initializePrintRedirect);
/**
* Initializes the lua state.
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_initializeLua();
/**
* Sets up the `print` redirect to `std::cout`.
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_initializePrintRedirect(lua_State* L);
RUNTIMEPATCHINGSYSTEM_API void RPS_initializePrintRedirect();
/**
* Registers the lua api in the global namespace.
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_initializeLuaAPI(lua_State* L);
RUNTIMEPATCHINGSYSTEM_API void RPS_initializeLuaAPI();
/**
* Load all common libraries, including base.
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_initializeLuaOpenLibs();
/**
* Load the base library.
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_initializeLuaOpenBase();
/**
* Registers the lua api in the given namespace. A table with the functions with the given name is created in the global namespace
* @param apiNamespace if NULL or empty, the table is left on the lua stack. If "global" the functions are registered in the global namespace.
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_initializeLuaAPI(lua_State* L, std::string apiNamespace);
RUNTIMEPATCHINGSYSTEM_API void RPS_initializeLuaAPI(std::string apiNamespace);
RUNTIMEPATCHINGSYSTEM_API void RPS_initializeLuaAPI();
/**
* The functions to register in the global namespace.
*/
RUNTIMEPATCHINGSYSTEM_API extern const struct luaL_Reg RPS_LIB[];
/**
* Deinitialize the lua api. Destroys the lua state and destroys the code heap.
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_deinitialize();
/**
* Execute a snippet of code in the lua state.
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_executeSnippet(std::string code);
/**
* Get the lua state.
*/
RUNTIMEPATCHINGSYSTEM_API lua_State* RPS_getLuaState();
/**
* Set the lua state that is used internally.
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_setLuaState(lua_State* value);
/**
* Get the amount of objects on the lua stack.
*/
RUNTIMEPATCHINGSYSTEM_API int RPS_getCurrentStackSize();
/**
* Setup the package path by changing the `package.path` lua variable.
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_setupPackagePath(lua_State* L, std::string packagePath);
RUNTIMEPATCHINGSYSTEM_API void RPS_setupPackagePath(std::string packagePath);
/**
* Setup the package cpath by changing the `package.cpath` lua variable..
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_setupPackageCPath(lua_State* L, std::string packageCPath);
RUNTIMEPATCHINGSYSTEM_API void RPS_setupPackageCPath(std::string packageCPath);
/**
* Run a (bootstrap) file.
*/
RUNTIMEPATCHINGSYSTEM_API void RPS_runBootstrapFile(lua_State* L, std::string bootstrapFilePath);
RUNTIMEPATCHINGSYSTEM_API void RPS_runBootstrapFile(std::string bootstrapFilePath);
extern "C" RUNTIMEPATCHINGSYSTEM_API int luaopen_RPS(lua_State * L);