Macro hexchat_api::dll_entry_points
source · macro_rules! dll_entry_points { ( $info:ident, $init:ident, $deinit:ident ) => { ... }; }
Expand description
dll_entry_points()
makes it very easy to set up your plugin’s DLL
interface required by the Hexchat loader. This macro generates the necessary
DLL entry points that Hexchat looks for when a DLL is being loaded.
Normal Rust functions having the required signatures can be passed to the
macro like so:
dll_entry_points!( my_info_func, my_init_func, my_deinit_func )
That’s it. You don’t need to worry about how to export your Rust functions to interface with the C environment of Hexchat. This macro does it all for you.
The signatures for the functions are:
my_info_func () -> PluginInfo;
my_init_func (&'static Hexchat) -> i32;
my_deinit_func(&'static Hexchat) -> i32;
The info function should create an instance of PluginInfo
by calling
its constructor with information about the plugin as parameters.
The init function is typically where you’ll want to register your
plugin’s commands. Hook commands are provided by the &Hexchat
reference
provided as a paramter when your init function is called by Hexchat. The
init function needs to return either 0 (good) or 1 (error).
The deinit function gets called when your plugin is unloaded. Return a
0 (good) or 1 (error). Any cleanup actions needed to be done can be done
here. However, when your DLL is unloaded by Hexchat, all its hooked
commands are unhooked automatically - so you don’t need to worry about
managing the Hook
objects returned by the hook commands unless you’re
plugin needs to for some reason. If your plugin creates any static
variables, This is the place to drop their values, for example:
MY_STATIC_VAR = None;