mirror of
https://github.com/weechat/weechat.git
synced 2026-06-26 04:46:37 +02:00
core: add pointer in some callbacks (closes #406)
This pointer is the first argument received by callbacks, and the existing argument "data" is now automatically freed by WeeChat when the object containing the callback is removed. With this new pointer, the linked list of callbacks in scripts has been removed. This will improve speed of scripts (using a lot of hooks), reduce memory used by scripts and reduce time to unload scripts. Following functions are affected in the C API: * exec_on_files * config_new * config_new_section * config_new_option * hook_command * hook_command_run * hook_timer * hook_fd * hook_process * hook_process_hashtable * hook_connect * hook_print * hook_signal * hook_hsignal * hook_config * hook_completion * hook_modifier * hook_info * hook_info_hashtable * hook_infolist * hook_hdata * hook_focus * unhook_all_plugin * buffer_new * bar_item_new * upgrade_new * upgrade_read
This commit is contained in:
+28
-14
@@ -179,8 +179,7 @@ script_get_scripts ()
|
||||
script_loaded = weechat_hashtable_new (32,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
WEECHAT_HASHTABLE_STRING,
|
||||
NULL,
|
||||
NULL);
|
||||
NULL, NULL);
|
||||
}
|
||||
else
|
||||
weechat_hashtable_remove_all (script_loaded);
|
||||
@@ -217,10 +216,12 @@ script_get_scripts ()
|
||||
*/
|
||||
|
||||
int
|
||||
script_debug_dump_cb (void *data, const char *signal, const char *type_data,
|
||||
script_debug_dump_cb (const void *pointer, void *data,
|
||||
const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) signal;
|
||||
(void) type_data;
|
||||
@@ -247,9 +248,10 @@ script_debug_dump_cb (void *data, const char *signal, const char *type_data,
|
||||
*/
|
||||
|
||||
int
|
||||
script_timer_refresh_cb (void *data, int remaining_calls)
|
||||
script_timer_refresh_cb (const void *pointer, void *data, int remaining_calls)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
|
||||
script_get_loaded_plugins ();
|
||||
@@ -268,10 +270,12 @@ script_timer_refresh_cb (void *data, int remaining_calls)
|
||||
*/
|
||||
|
||||
int
|
||||
script_signal_plugin_cb (void *data, const char *signal, const char *type_data,
|
||||
script_signal_plugin_cb (const void *pointer, void *data,
|
||||
const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) type_data;
|
||||
|
||||
@@ -285,7 +289,8 @@ script_signal_plugin_cb (void *data, const char *signal, const char *type_data,
|
||||
if (!script_timer_refresh)
|
||||
{
|
||||
script_timer_refresh = weechat_hook_timer (50, 0, 1,
|
||||
&script_timer_refresh_cb, NULL);
|
||||
&script_timer_refresh_cb,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
@@ -296,10 +301,12 @@ script_signal_plugin_cb (void *data, const char *signal, const char *type_data,
|
||||
*/
|
||||
|
||||
int
|
||||
script_signal_script_cb (void *data, const char *signal, const char *type_data,
|
||||
script_signal_script_cb (const void *pointer, void *data,
|
||||
const char *signal, const char *type_data,
|
||||
void *signal_data)
|
||||
{
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) type_data;
|
||||
|
||||
@@ -313,7 +320,8 @@ script_signal_script_cb (void *data, const char *signal, const char *type_data,
|
||||
if (!script_timer_refresh)
|
||||
{
|
||||
script_timer_refresh = weechat_hook_timer (50, 0, 1,
|
||||
&script_timer_refresh_cb, NULL);
|
||||
&script_timer_refresh_cb,
|
||||
NULL, NULL);
|
||||
}
|
||||
|
||||
return WEECHAT_RC_OK;
|
||||
@@ -324,7 +332,8 @@ script_signal_script_cb (void *data, const char *signal, const char *type_data,
|
||||
*/
|
||||
|
||||
struct t_hashtable *
|
||||
script_focus_chat_cb (void *data, struct t_hashtable *info)
|
||||
script_focus_chat_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *info)
|
||||
{
|
||||
const char *buffer;
|
||||
int rc;
|
||||
@@ -336,6 +345,7 @@ script_focus_chat_cb (void *data, struct t_hashtable *info)
|
||||
struct tm *tm;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
|
||||
if (!script_buffer)
|
||||
@@ -429,12 +439,16 @@ weechat_plugin_init (struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||||
script_completion_init ();
|
||||
script_info_init ();
|
||||
|
||||
weechat_hook_signal ("debug_dump", &script_debug_dump_cb, NULL);
|
||||
weechat_hook_signal ("window_scrolled", &script_buffer_window_scrolled_cb, NULL);
|
||||
weechat_hook_signal ("plugin_*", &script_signal_plugin_cb, NULL);
|
||||
weechat_hook_signal ("*_script_*", &script_signal_script_cb, NULL);
|
||||
weechat_hook_signal ("debug_dump",
|
||||
&script_debug_dump_cb, NULL, NULL);
|
||||
weechat_hook_signal ("window_scrolled",
|
||||
&script_buffer_window_scrolled_cb, NULL, NULL);
|
||||
weechat_hook_signal ("plugin_*",
|
||||
&script_signal_plugin_cb, NULL, NULL);
|
||||
weechat_hook_signal ("*_script_*",
|
||||
&script_signal_script_cb, NULL, NULL);
|
||||
|
||||
weechat_hook_focus ("chat", &script_focus_chat_cb, NULL);
|
||||
weechat_hook_focus ("chat", &script_focus_chat_cb, NULL, NULL);
|
||||
|
||||
if (script_repo_file_exists ())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user