diff options
-rw-r--r-- | degesch.c | 60 |
1 files changed, 8 insertions, 52 deletions
@@ -1954,43 +1954,27 @@ hook_insert (struct hook *list, struct hook *item) struct input_hook { struct hook super; ///< Common hook fields - struct input_hook_vtable *vtable; ///< Methods -}; -struct input_hook_vtable -{ /// Takes over the ownership of "input", returns either NULL if input /// was thrown away, or a possibly modified version of it char *(*filter) (struct input_hook *self, struct buffer *buffer, char *input); }; -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - struct irc_hook { struct hook super; ///< Common hook fields - struct irc_hook_vtable *vtable; ///< Methods -}; -struct irc_hook_vtable -{ /// Takes over the ownership of "message", returns either NULL if message /// was thrown away, or a possibly modified version of it char *(*filter) (struct irc_hook *self, struct server *server, char *message); }; -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - struct prompt_hook { struct hook super; ///< Common hook fields - struct prompt_hook_vtable *vtable; ///< Methods -}; -struct prompt_hook_vtable -{ /// Returns what the prompt should look like right now based on other state char *(*make) (struct prompt_hook *self); }; @@ -2017,11 +2001,7 @@ struct completion struct completion_hook { struct hook super; ///< Common hook fields - struct completion_hook_vtable *vtable; -}; -struct completion_hook_vtable -{ /// Tries to add possible completions of "word" to "output" void (*complete) (struct completion_hook *self, struct completion *data, const char *word, struct str_vector *output); @@ -5044,7 +5024,7 @@ irc_process_hooks (struct server *s, char *input) LIST_FOR_EACH (struct hook, iter, s->ctx->irc_hooks) { struct irc_hook *hook = (struct irc_hook *) iter; - if (!(input = hook->vtable->filter (hook, s, input))) + if (!(input = hook->filter (hook, s, input))) { log_server_debug (s, "#a>= #s#r", ATTR_JOIN, "thrown away by hook"); return NULL; @@ -5908,7 +5888,7 @@ make_prompt (struct app_context *ctx, struct str *output) LIST_FOR_EACH (struct hook, iter, ctx->prompt_hooks) { struct prompt_hook *hook = (struct prompt_hook *) iter; - char *made = hook->vtable->make (hook); + char *made = hook->make (hook); if (made) { str_append (output, made); @@ -8873,13 +8853,6 @@ lua_input_hook_filter (struct input_hook *self, struct buffer *buffer, return input; } -struct input_hook_vtable lua_input_hook_vtable = -{ - .filter = lua_input_hook_filter, -}; - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static char * lua_irc_hook_filter (struct irc_hook *self, struct server *s, char *message) { @@ -8904,13 +8877,6 @@ lua_irc_hook_filter (struct irc_hook *self, struct server *s, char *message) return message; } -struct irc_hook_vtable lua_irc_hook_vtable = -{ - .filter = lua_irc_hook_filter, -}; - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static char * lua_prompt_hook_make (struct prompt_hook *self) { @@ -8934,11 +8900,6 @@ lua_prompt_hook_make (struct prompt_hook *self) return prompt; } -struct prompt_hook_vtable lua_prompt_hook_vtable = -{ - .make = lua_prompt_hook_make, -}; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static void @@ -9026,11 +8987,6 @@ lua_completion_hook_complete (struct completion_hook *self, lua_plugin_log_error (plugin, "autocomplete hook", e); } -struct completion_hook_vtable lua_completion_hook_vtable = -{ - .complete = lua_completion_hook_complete, -}; - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - static void @@ -9081,7 +9037,7 @@ lua_plugin_hook_input (lua_State *L) struct lua_plugin *plugin = lua_touserdata (L, lua_upvalueindex (1)); struct lua_hook *hook = lua_plugin_push_hook (plugin, 1, XLUA_HOOK_INPUT, luaL_optinteger (L, 2, 0)); - hook->data.input_hook.vtable = &lua_input_hook_vtable; + hook->data.input_hook.filter = lua_input_hook_filter; plugin->ctx->input_hooks = hook_insert (plugin->ctx->input_hooks, &hook->data.hook); return 1; @@ -9093,7 +9049,7 @@ lua_plugin_hook_irc (lua_State *L) struct lua_plugin *plugin = lua_touserdata (L, lua_upvalueindex (1)); struct lua_hook *hook = lua_plugin_push_hook (plugin, 1, XLUA_HOOK_IRC, luaL_optinteger (L, 2, 0)); - hook->data.irc_hook.vtable = &lua_irc_hook_vtable; + hook->data.irc_hook.filter = lua_irc_hook_filter; plugin->ctx->irc_hooks = hook_insert (plugin->ctx->irc_hooks, &hook->data.hook); return 1; @@ -9105,7 +9061,7 @@ lua_plugin_hook_prompt (lua_State *L) struct lua_plugin *plugin = lua_touserdata (L, lua_upvalueindex (1)); struct lua_hook *hook = lua_plugin_push_hook (plugin, 1, XLUA_HOOK_PROMPT, luaL_optinteger (L, 2, 0)); - hook->data.prompt_hook.vtable = &lua_prompt_hook_vtable; + hook->data.prompt_hook.make = lua_prompt_hook_make; plugin->ctx->prompt_hooks = hook_insert (plugin->ctx->prompt_hooks, &hook->data.hook); refresh_prompt (plugin->ctx); @@ -9118,7 +9074,7 @@ lua_plugin_hook_completion (lua_State *L) struct lua_plugin *plugin = lua_touserdata (L, lua_upvalueindex (1)); struct lua_hook *hook = lua_plugin_push_hook (plugin, 1, XLUA_HOOK_COMPLETION, luaL_optinteger (L, 2, 0)); - hook->data.c_hook.vtable = &lua_completion_hook_vtable; + hook->data.c_hook.complete = lua_completion_hook_complete; plugin->ctx->completion_hooks = hook_insert (plugin->ctx->completion_hooks, &hook->data.hook); return 1; @@ -11888,7 +11844,7 @@ process_input_hooks (struct app_context *ctx, struct buffer *buffer, LIST_FOR_EACH (struct hook, iter, ctx->input_hooks) { struct input_hook *hook = (struct input_hook *) iter; - if (!(input = hook->vtable->filter (hook, buffer, input))) + if (!(input = hook->filter (hook, buffer, input))) { log_global_debug (ctx, "Input thrown away by hook"); return NULL; @@ -12186,7 +12142,7 @@ complete_word (struct app_context *ctx, struct completion *data, LIST_FOR_EACH (struct hook, iter, ctx->completion_hooks) { struct completion_hook *hook = (struct completion_hook *) iter; - hook->vtable->complete (hook, data, word, &words); + hook->complete (hook, data, word, &words); } if (words.len == 1) |