summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib.rs7
-rw-r--r--src/mock/mod.rs277
2 files changed, 283 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 52d3d23..cf04809 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -183,6 +183,8 @@
  * -[ ] ???
  */
 
+#![cfg_attr(feature="nightly_tests", feature(c_variadic))]
+
 #[macro_use]
 extern crate impl_trait;
 #[doc(hidden)]
@@ -205,6 +207,9 @@ mod extra_tests;
 mod infoid;
 mod internals;
 pub mod list;
+#[doc(hidden)]
+#[cfg(feature="nightly_tests")]
+pub mod mock;
 mod pluginfo;
 mod strip;
 mod word;
@@ -1920,7 +1925,7 @@ pub unsafe fn hexchat_plugin_init<'ph, T>(plugin_handle: LtPhPtr<'ph>,
             // must register this before the plugin registers anything else!
             let context_hook = pluginhandle.hook_print("Close Context", c_int::min_value(), move |ph, _| {
                 // just remove the context! it's that simple!
-                let ctx = unsafe { ph_call!(hexchat_get_context(ph)) };
+                let ctx = ph_call!(hexchat_get_context(ph));
                 contexts.borrow_mut().remove(&ctx);
                 EAT_NONE
             });
diff --git a/src/mock/mod.rs b/src/mock/mod.rs
new file mode 100644
index 0000000..4edb907
--- /dev/null
+++ b/src/mock/mod.rs
@@ -0,0 +1,277 @@
+//! Internal mock test framework.
+//!
+//! This API is not stable. Do not rely on this API to be stable.
+
+#[repr(C)]
+pub struct MockPlugin {
+    // NOTE: MUST be first thing in the struct.
+    methods: crate::internals::Ph,
+}
+
+unsafe extern "C" fn hexchat_hook_command(ph: *mut crate::internals::HexchatPlugin,
+        name: *const libc::c_char,
+        pri: libc::c_int,
+        /* CALLBACK */
+        callback: unsafe extern "C" fn(word: *const *const libc::c_char, word_eol: *const *const libc::c_char, user_data: *mut libc::c_void) -> libc::c_int,
+        help_text: *const libc::c_char,
+        userdata: *mut libc::c_void) -> *const crate::internals::HexchatHook {
+    todo!();
+}
+unsafe extern "C" fn hexchat_hook_server(ph: *mut crate::internals::HexchatPlugin,
+        name: *const libc::c_char,
+        pri: libc::c_int,
+        /* CALLBACK */
+        callback: unsafe extern "C" fn(word: *const *const libc::c_char, word_eol: *const *const libc::c_char, user_data: *mut libc::c_void) -> libc::c_int,
+        userdata: *mut libc::c_void) -> *const crate::internals::HexchatHook {
+    todo!();
+}
+unsafe extern "C" fn hexchat_hook_print(ph: *mut crate::internals::HexchatPlugin,
+        name: *const libc::c_char,
+        pri: libc::c_int,
+        /* CALLBACK */
+        callback: unsafe extern "C" fn(word: *const *const libc::c_char, user_data: *mut libc::c_void) -> libc::c_int,
+        userdata: *mut libc::c_void) -> *const crate::internals::HexchatHook {
+    todo!();
+}
+unsafe extern "C" fn hexchat_hook_timer(ph: *mut crate::internals::HexchatPlugin,
+        timeout: libc::c_int,
+        /* CALLBACK */
+        callback: unsafe extern "C" fn(user_data: *mut libc::c_void) -> libc::c_int,
+        userdata: *mut libc::c_void) -> *const crate::internals::HexchatHook {
+    todo!();
+}
+unsafe extern "C" fn hexchat_hook_fd(ph: *mut crate::internals::HexchatPlugin,
+        fd: libc::c_int,
+        flags: libc::c_int,
+        /* CALLBACK */
+        callback: Option<unsafe extern "C" fn(fd: libc::c_int, flags: libc::c_int, user_data: *mut libc::c_void) -> libc::c_int>,
+        userdata: *mut libc::c_void) -> *const crate::internals::HexchatHook {
+    todo!();
+}
+unsafe extern "C" fn hexchat_unhook(ph: *mut crate::internals::HexchatPlugin,
+        hook: *const crate::internals::HexchatHook) -> *const libc::c_void {
+    todo!();
+}
+unsafe extern "C" fn hexchat_print(ph: *mut crate::internals::HexchatPlugin,
+        text: *const libc::c_char) {
+    todo!();
+}
+pub unsafe extern "C" fn hexchat_printf_do_not_use(ph: *mut crate::internals::HexchatPlugin,
+        format: *const libc::c_char, ...) {
+    unimplemented!();
+}
+unsafe extern "C" fn hexchat_command(ph: *mut crate::internals::HexchatPlugin,
+        command: *const libc::c_char) {
+    todo!();
+}
+unsafe extern "C" fn hexchat_commandf_do_not_use(ph: *mut crate::internals::HexchatPlugin,
+        format: *const libc::c_char, ...) {
+    unimplemented!();
+}
+unsafe extern "C" fn hexchat_nickcmp(ph: *mut crate::internals::HexchatPlugin,
+        s1: *const libc::c_char,
+        s2: *const libc::c_char) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_set_context(ph: *mut crate::internals::HexchatPlugin,
+        ctx: *const crate::internals::HexchatContext) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_find_context(ph: *mut crate::internals::HexchatPlugin,
+        servname: *const libc::c_char,
+        channel: *const libc::c_char) -> *const crate::internals::HexchatContext {
+    todo!();
+}
+unsafe extern "C" fn hexchat_get_context(ph: *mut crate::internals::HexchatPlugin) -> *const crate::internals::HexchatContext {
+    todo!();
+}
+unsafe extern "C" fn hexchat_get_info(ph: *mut crate::internals::HexchatPlugin,
+        id: *const libc::c_char) -> *const libc::c_char {
+    todo!();
+}
+unsafe extern "C" fn hexchat_get_prefs(ph: *mut crate::internals::HexchatPlugin,
+        name: *const libc::c_char,
+        string: *mut *const libc::c_char,
+        integer: *mut libc::c_int) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_list_get(ph: *mut crate::internals::HexchatPlugin,
+        name: *const libc::c_char) -> *mut crate::internals::HexchatList {
+    todo!();
+}
+unsafe extern "C" fn hexchat_list_free(ph: *mut crate::internals::HexchatPlugin,
+        xlist: *const crate::internals::HexchatList) {
+    todo!();
+}
+unsafe extern "C" fn hexchat_list_fields(ph: *mut crate::internals::HexchatPlugin,
+        name: *const libc::c_char) -> *const *const libc::c_char {
+    todo!();
+}
+unsafe extern "C" fn hexchat_list_next(ph: *mut crate::internals::HexchatPlugin,
+        xlist: *const crate::internals::HexchatList) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_list_str(ph: *mut crate::internals::HexchatPlugin,
+        xlist: *const crate::internals::HexchatList,
+        name: *const libc::c_char) -> *const libc::c_char {
+    todo!();
+}
+unsafe extern "C" fn hexchat_list_int(ph: *mut crate::internals::HexchatPlugin,
+        xlist: *const crate::internals::HexchatList,
+        name: *const libc::c_char) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_plugingui_add(ph: *mut crate::internals::HexchatPlugin,
+        filename: *const libc::c_char,
+        name: *const libc::c_char,
+        desc: *const libc::c_char,
+        version: *const libc::c_char,
+        reserved: *mut char) -> *const crate::internals::PluginGuiHandle {
+    todo!();
+}
+unsafe extern "C" fn hexchat_plugingui_remove(ph: *mut crate::internals::HexchatPlugin,
+        handle: *const crate::internals::PluginGuiHandle) {
+    todo!();
+}
+unsafe extern "C" fn hexchat_emit_print(ph: *mut crate::internals::HexchatPlugin,
+        event_name: *const libc::c_char, ...) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_read_fd(ph: *mut crate::internals::HexchatPlugin,
+        src: *const libc::c_void,
+        buf: *mut char,
+        len: *mut libc::c_int) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_list_time(ph: *mut crate::internals::HexchatPlugin,
+        xlist: *const crate::internals::HexchatList,
+        name: *const libc::c_char) -> libc::time_t {
+    todo!();
+}
+unsafe extern "C" fn hexchat_gettext(ph: *mut crate::internals::HexchatPlugin,
+        msgid: *const libc::c_char) -> *const libc::c_char {
+    todo!();
+}
+unsafe extern "C" fn hexchat_send_modes(ph: *mut crate::internals::HexchatPlugin,
+        targets: *mut *const libc::c_char,
+        ntargets: libc::c_int,
+        modes_per_line: libc::c_int,
+        sign: libc::c_char,
+        mode: libc::c_char) {
+    todo!();
+}
+unsafe extern "C" fn hexchat_strip(ph: *mut crate::internals::HexchatPlugin,
+        string: *const libc::c_char,
+        len: libc::c_int,
+        flags: libc::c_int) -> *const libc::c_char {
+    todo!();
+}
+unsafe extern "C" fn hexchat_free(ph: *mut crate::internals::HexchatPlugin,
+        ptr: *const libc::c_void) {
+    todo!();
+}
+unsafe extern "C" fn hexchat_pluginpref_set_str(ph: *mut crate::internals::HexchatPlugin,
+        var: *const libc::c_char,
+        value: *const libc::c_char) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_pluginpref_get_str(ph: *mut crate::internals::HexchatPlugin,
+        var: *const libc::c_char,
+        dest: *mut char) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_pluginpref_set_int(ph: *mut crate::internals::HexchatPlugin,
+        var: *const libc::c_char,
+        value: libc::c_int) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_pluginpref_get_int(ph: *mut crate::internals::HexchatPlugin,
+        var: *const libc::c_char) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_pluginpref_delete(ph: *mut crate::internals::HexchatPlugin,
+        var: *const libc::c_char) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_pluginpref_list(ph: *mut crate::internals::HexchatPlugin,
+        dest: *mut char) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_hook_server_attrs(ph: *mut crate::internals::HexchatPlugin,
+        name: *const libc::c_char,
+        pri: libc::c_int,
+        /* CALLBACK */
+        callback: unsafe extern "C" fn(word: *const *const libc::c_char, word_eol: *const *const libc::c_char, attrs: *const crate::internals::HexchatEventAttrs, user_data: *mut libc::c_void) -> libc::c_int,
+        userdata: *mut libc::c_void) -> *const crate::internals::HexchatHook {
+    todo!();
+}
+unsafe extern "C" fn hexchat_hook_print_attrs(ph: *mut crate::internals::HexchatPlugin,
+        name: *const libc::c_char,
+        pri: libc::c_int,
+        /* CALLBACK */
+        callback: unsafe extern "C" fn(word: *const *const libc::c_char, attrs: *const crate::internals::HexchatEventAttrs, user_data: *mut libc::c_void) -> libc::c_int,
+        userdata: *mut libc::c_void) -> *const crate::internals::HexchatHook {
+    todo!();
+}
+unsafe extern "C" fn hexchat_emit_print_attrs(ph: *mut crate::internals::HexchatPlugin, attrs: *const crate::internals::HexchatEventAttrs,
+        event_name: *const libc::c_char, ...) -> libc::c_int {
+    todo!();
+}
+unsafe extern "C" fn hexchat_event_attrs_create(ph: *mut crate::internals::HexchatPlugin) -> *mut crate::internals::HexchatEventAttrs {
+    todo!();
+}
+unsafe extern "C" fn hexchat_event_attrs_free(ph: *mut crate::internals::HexchatPlugin,
+        attrs: *mut crate::internals::HexchatEventAttrs) {
+    todo!();
+}
+
+impl MockPlugin {
+    fn new() -> MockPlugin {
+        MockPlugin {
+            methods: crate::internals::Ph {
+                hexchat_hook_command,
+                hexchat_hook_server,
+                hexchat_hook_print,
+                hexchat_hook_timer,
+                hexchat_hook_fd,
+                hexchat_unhook,
+                hexchat_print,
+                userdata: std::ptr::null_mut(),
+                hexchat_command,
+                hexchat_commandf_do_not_use,
+                hexchat_nickcmp,
+                hexchat_set_context,
+                hexchat_find_context,
+                hexchat_get_context,
+                hexchat_get_info,
+                hexchat_get_prefs,
+                hexchat_list_get,
+                hexchat_list_free,
+                hexchat_list_fields,
+                hexchat_list_next,
+                hexchat_list_str,
+                hexchat_list_int,
+                hexchat_plugingui_add,
+                hexchat_plugingui_remove,
+                hexchat_emit_print,
+                hexchat_read_fd,
+                hexchat_list_time,
+                hexchat_gettext,
+                hexchat_send_modes,
+                hexchat_strip,
+                hexchat_free,
+                hexchat_pluginpref_set_str,
+                hexchat_pluginpref_get_str,
+                hexchat_pluginpref_set_int,
+                hexchat_pluginpref_get_int,
+                hexchat_pluginpref_delete,
+                hexchat_pluginpref_list,
+                hexchat_hook_server_attrs,
+                hexchat_hook_print_attrs,
+                hexchat_emit_print_attrs,
+                hexchat_event_attrs_create,
+                hexchat_event_attrs_free,
+            }
+        }
+    }
+}