mirror of
https://github.com/Adamcake/Bolt.git
synced 2026-04-17 15:56:53 -04:00
library: api_close
This commit is contained in:
@@ -275,9 +275,10 @@ void _bolt_plugin_init(const struct PluginManagedFunctions* functions) {
|
||||
}
|
||||
|
||||
static int _bolt_api_init(lua_State* state) {
|
||||
lua_createtable(state, 0, 18);
|
||||
lua_createtable(state, 0, 19);
|
||||
API_ADD(apiversion)
|
||||
API_ADD(checkversion)
|
||||
API_ADD(close)
|
||||
API_ADD(time)
|
||||
API_ADD(datetime)
|
||||
API_ADD(weekday)
|
||||
@@ -1009,6 +1010,16 @@ static int api_checkversion(lua_State* state) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
static int api_close(lua_State* state) {
|
||||
lua_getfield(state, LUA_REGISTRYINDEX, PLUGIN_REGISTRYNAME);
|
||||
const struct Plugin* plugin = lua_touserdata(state, -1);
|
||||
const uint64_t id = plugin->id;
|
||||
lua_pop(state, 1);
|
||||
_bolt_plugin_stop(id);
|
||||
_bolt_plugin_notify_stopped(id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int api_time(lua_State* state) {
|
||||
_bolt_check_argc(state, 0, "time");
|
||||
#if defined(_WIN32)
|
||||
|
||||
@@ -55,6 +55,11 @@ static int api_apiversion(lua_State*);
|
||||
/// For compatibility reasons, there will never be a breaking change to this function.
|
||||
static int api_checkversion(lua_State*);
|
||||
|
||||
/// [-0, +0, -]
|
||||
/// Stops this instance of this plugin. Any resources will be cleaned up and destroyed. Do not use
|
||||
/// any API functions after this one.
|
||||
static int api_close(lua_State*);
|
||||
|
||||
/// [-0, +1, -]
|
||||
/// Returns a monotonic time as an integer, in microseconds.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user