Rework plugin structure #13
2 changed files with 16 additions and 9 deletions
|
@ -69,7 +69,7 @@ typedef void *(*GetApiFunction)(unsigned api);
|
||||||
|
|
||||||
struct PluginApi {
|
struct PluginApi {
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
uint32_t version = 65;
|
uint32_t version = 69;
|
||||||
uint32_t flags = 3; // lua plugin
|
uint32_t flags = 3; // lua plugin
|
||||||
#else
|
#else
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
|
@ -83,13 +83,19 @@ struct PluginApi {
|
||||||
loaded. */
|
loaded. */
|
||||||
void (*loaded)(GetApiFunction get_engine_api);
|
void (*loaded)(GetApiFunction get_engine_api);
|
||||||
|
|
||||||
|
// Seemingly not called by current versions of the engine, at least in release
|
||||||
|
// mode.
|
||||||
/* Called at the start of a "hot reload" of the plugin DLL. Should return a
|
/* Called at the start of a "hot reload" of the plugin DLL. Should return a
|
||||||
pointer to a serialized "state" for the plugin.*/
|
pointer to a serialized "state" for the plugin.*/
|
||||||
void *(*start_reload)(GetApiFunction get_engine_api);
|
void *(*start_reload)(GetApiFunction get_engine_api);
|
||||||
|
|
||||||
|
// Seemingly not called by current versions of the engine, at least in release
|
||||||
|
// mode.
|
||||||
/* Called just before the plugin is unloaded. */
|
/* Called just before the plugin is unloaded. */
|
||||||
void (*unloaded)();
|
void (*unloaded)();
|
||||||
|
|
||||||
|
// Seemingly not called by current versions of the engine, at least in release
|
||||||
|
// mode.
|
||||||
/* Called to finalized the "hot reload" after the plugin has been reloaded
|
/* Called to finalized the "hot reload" after the plugin has been reloaded
|
||||||
with the new code. Should restore the state from the serialized state data.
|
with the new code. Should restore the state from the serialized state data.
|
||||||
Note that it is the responsibility of the plugin to free the state data. */
|
Note that it is the responsibility of the plugin to free the state data. */
|
||||||
|
@ -223,9 +229,8 @@ struct LuaApi {
|
||||||
int (*checkstack)(lua_State *L, int sz);
|
int (*checkstack)(lua_State *L, int sz);
|
||||||
void (*xmove)(lua_State *from, lua_State *to, int n);
|
void (*xmove)(lua_State *from, lua_State *to, int n);
|
||||||
|
|
||||||
const void *(*fnx1)(lua_State *L, int idx);
|
|
||||||
|
|
||||||
/* Access functions */
|
/* Access functions */
|
||||||
|
int (*isnil)(lua_State *L, int idx);
|
||||||
int (*isnumber)(lua_State *L, int idx);
|
int (*isnumber)(lua_State *L, int idx);
|
||||||
int (*isstring)(lua_State *L, int idx);
|
int (*isstring)(lua_State *L, int idx);
|
||||||
int (*iscfunction)(lua_State *L, int idx);
|
int (*iscfunction)(lua_State *L, int idx);
|
||||||
|
@ -313,8 +318,6 @@ struct LuaApi {
|
||||||
int (*gethookmask)(lua_State *L);
|
int (*gethookmask)(lua_State *L);
|
||||||
int (*gethookcount)(lua_State *L);
|
int (*gethookcount)(lua_State *L);
|
||||||
|
|
||||||
// int (*fnx3) (lua_State* L);
|
|
||||||
|
|
||||||
/* Library functions */
|
/* Library functions */
|
||||||
void (*lib_openlib)(lua_State *L, const char *libname, const luaL_Reg *l,
|
void (*lib_openlib)(lua_State *L, const char *libname, const luaL_Reg *l,
|
||||||
int nup);
|
int nup);
|
||||||
|
@ -399,6 +402,8 @@ struct LuaApi {
|
||||||
/* Gets a Unit at the specified index. */
|
/* Gets a Unit at the specified index. */
|
||||||
CApiUnit *(*getunit)(lua_State *L, int i);
|
CApiUnit *(*getunit)(lua_State *L, int i);
|
||||||
|
|
||||||
|
void *(*getunknown)(lua_State *L, int i);
|
||||||
|
|
||||||
/* Gets the Lua state where the main scripts execute. */
|
/* Gets the Lua state where the main scripts execute. */
|
||||||
lua_State *(*getscriptenvironmentstate)();
|
lua_State *(*getscriptenvironmentstate)();
|
||||||
|
|
||||||
|
@ -423,8 +428,10 @@ struct LuaApi {
|
||||||
/* Returns true if the stack entry is a UnitReference. */
|
/* Returns true if the stack entry is a UnitReference. */
|
||||||
int (*isunitreference)(lua_State *L, int i);
|
int (*isunitreference)(lua_State *L, int i);
|
||||||
|
|
||||||
|
size_t (*objlen2)(lua_State *L, int idx);
|
||||||
|
|
||||||
/* Reserved for expansion of the API. */
|
/* Reserved for expansion of the API. */
|
||||||
void *reserved[32];
|
// void *reserved[30];
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LoggingApi {
|
struct LoggingApi {
|
||||||
|
|
|
@ -13,16 +13,16 @@ use std::ffi::CString;
|
||||||
use std::os::raw::c_char;
|
use std::os::raw::c_char;
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
|
|
||||||
use bindings::lua_CFunction;
|
|
||||||
pub use bindings::lua_State;
|
|
||||||
pub use bindings::GetApiFunction;
|
pub use bindings::GetApiFunction;
|
||||||
pub use bindings::PluginApi;
|
pub use bindings::PluginApi;
|
||||||
pub use bindings::PluginApiID;
|
pub use bindings::PluginApiID;
|
||||||
|
use bindings::lua_CFunction;
|
||||||
|
pub use bindings::lua_State;
|
||||||
|
|
||||||
impl std::default::Default for PluginApi {
|
impl std::default::Default for PluginApi {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
version: 65,
|
version: 69,
|
||||||
flags: 3,
|
flags: 3,
|
||||||
setup_game: None,
|
setup_game: None,
|
||||||
update_game: None,
|
update_game: None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue