summaryrefslogtreecommitdiff
path: root/src/plugins/python
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2016-11-27 17:34:15 +0100
committerSébastien Helleu <flashcode@flashtux.org>2016-11-27 17:34:15 +0100
commit64f05204f933dfa7f342639cf50b952ae29c9a23 (patch)
treeb65f4234a4da0710105e37a5da1c33a9dfc6f7eb /src/plugins/python
parent6e82e6618c7eba39f404df759ad34bd0499eeb27 (diff)
downloadweechat-64f05204f933dfa7f342639cf50b952ae29c9a23.zip
api: move functions hook_completion* after hook_command
Diffstat (limited to 'src/plugins/python')
-rw-r--r--src/plugins/python/weechat-python-api.c224
1 files changed, 112 insertions, 112 deletions
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index 23acaba0b..d9cd74862 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -2003,6 +2003,115 @@ API_FUNC(hook_command)
}
int
+weechat_python_api_hook_completion_cb (const void *pointer, void *data,
+ const char *completion_item,
+ struct t_gui_buffer *buffer,
+ struct t_gui_completion *completion)
+{
+ struct t_plugin_script *script;
+ void *func_argv[4];
+ char empty_arg[1] = { '\0' };
+ const char *ptr_function, *ptr_data;
+ int *rc, ret;
+
+ script = (struct t_plugin_script *)pointer;
+ plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
+
+ if (ptr_function && ptr_function[0])
+ {
+ func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
+ func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
+ func_argv[2] = API_PTR2STR(buffer);
+ func_argv[3] = API_PTR2STR(completion);
+
+ rc = (int *) weechat_python_exec (script,
+ WEECHAT_SCRIPT_EXEC_INT,
+ ptr_function,
+ "ssss", func_argv);
+
+ if (!rc)
+ ret = WEECHAT_RC_ERROR;
+ else
+ {
+ ret = *rc;
+ free (rc);
+ }
+ if (func_argv[2])
+ free (func_argv[2]);
+ if (func_argv[3])
+ free (func_argv[3]);
+
+ return ret;
+ }
+
+ return WEECHAT_RC_ERROR;
+}
+
+API_FUNC(hook_completion)
+{
+ char *completion, *description, *function, *data, *result;
+ PyObject *return_value;
+
+ API_INIT_FUNC(1, "hook_completion", API_RETURN_EMPTY);
+ completion = NULL;
+ description = NULL;
+ function = NULL;
+ data = NULL;
+ if (!PyArg_ParseTuple (args, "ssss", &completion, &description, &function,
+ &data))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = API_PTR2STR(plugin_script_api_hook_completion (weechat_python_plugin,
+ python_current_script,
+ completion,
+ description,
+ &weechat_python_api_hook_completion_cb,
+ function,
+ data));
+
+ API_RETURN_STRING_FREE(result);
+}
+
+API_FUNC(hook_completion_get_string)
+{
+ char *completion, *property;
+ const char *result;
+
+ API_INIT_FUNC(1, "hook_completion_get_string", API_RETURN_EMPTY);
+ completion = NULL;
+ property = NULL;
+ if (!PyArg_ParseTuple (args, "ss", &completion, &property))
+ API_WRONG_ARGS(API_RETURN_EMPTY);
+
+ result = weechat_hook_completion_get_string (API_STR2PTR(completion),
+ property);
+
+ API_RETURN_STRING(result);
+}
+
+API_FUNC(hook_completion_list_add)
+{
+ char *completion, *word, *where;
+ int nick_completion;
+
+ API_INIT_FUNC(1, "hook_completion_list_add", API_RETURN_ERROR);
+ completion = NULL;
+ word = NULL;
+ nick_completion = 0;
+ where = NULL;
+ if (!PyArg_ParseTuple (args, "ssis", &completion, &word, &nick_completion,
+ &where))
+ API_WRONG_ARGS(API_RETURN_ERROR);
+
+ weechat_hook_completion_list_add (API_STR2PTR(completion),
+ word,
+ nick_completion,
+ where);
+
+ API_RETURN_OK;
+}
+
+int
weechat_python_api_hook_command_run_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
const char *command)
@@ -2782,115 +2891,6 @@ API_FUNC(hook_config)
API_RETURN_STRING_FREE(result);
}
-int
-weechat_python_api_hook_completion_cb (const void *pointer, void *data,
- const char *completion_item,
- struct t_gui_buffer *buffer,
- struct t_gui_completion *completion)
-{
- struct t_plugin_script *script;
- void *func_argv[4];
- char empty_arg[1] = { '\0' };
- const char *ptr_function, *ptr_data;
- int *rc, ret;
-
- script = (struct t_plugin_script *)pointer;
- plugin_script_get_function_and_data (data, &ptr_function, &ptr_data);
-
- if (ptr_function && ptr_function[0])
- {
- func_argv[0] = (ptr_data) ? (char *)ptr_data : empty_arg;
- func_argv[1] = (completion_item) ? (char *)completion_item : empty_arg;
- func_argv[2] = API_PTR2STR(buffer);
- func_argv[3] = API_PTR2STR(completion);
-
- rc = (int *) weechat_python_exec (script,
- WEECHAT_SCRIPT_EXEC_INT,
- ptr_function,
- "ssss", func_argv);
-
- if (!rc)
- ret = WEECHAT_RC_ERROR;
- else
- {
- ret = *rc;
- free (rc);
- }
- if (func_argv[2])
- free (func_argv[2]);
- if (func_argv[3])
- free (func_argv[3]);
-
- return ret;
- }
-
- return WEECHAT_RC_ERROR;
-}
-
-API_FUNC(hook_completion)
-{
- char *completion, *description, *function, *data, *result;
- PyObject *return_value;
-
- API_INIT_FUNC(1, "hook_completion", API_RETURN_EMPTY);
- completion = NULL;
- description = NULL;
- function = NULL;
- data = NULL;
- if (!PyArg_ParseTuple (args, "ssss", &completion, &description, &function,
- &data))
- API_WRONG_ARGS(API_RETURN_EMPTY);
-
- result = API_PTR2STR(plugin_script_api_hook_completion (weechat_python_plugin,
- python_current_script,
- completion,
- description,
- &weechat_python_api_hook_completion_cb,
- function,
- data));
-
- API_RETURN_STRING_FREE(result);
-}
-
-API_FUNC(hook_completion_get_string)
-{
- char *completion, *property;
- const char *result;
-
- API_INIT_FUNC(1, "hook_completion_get_string", API_RETURN_EMPTY);
- completion = NULL;
- property = NULL;
- if (!PyArg_ParseTuple (args, "ss", &completion, &property))
- API_WRONG_ARGS(API_RETURN_EMPTY);
-
- result = weechat_hook_completion_get_string (API_STR2PTR(completion),
- property);
-
- API_RETURN_STRING(result);
-}
-
-API_FUNC(hook_completion_list_add)
-{
- char *completion, *word, *where;
- int nick_completion;
-
- API_INIT_FUNC(1, "hook_completion_list_add", API_RETURN_ERROR);
- completion = NULL;
- word = NULL;
- nick_completion = 0;
- where = NULL;
- if (!PyArg_ParseTuple (args, "ssis", &completion, &word, &nick_completion,
- &where))
- API_WRONG_ARGS(API_RETURN_ERROR);
-
- weechat_hook_completion_list_add (API_STR2PTR(completion),
- word,
- nick_completion,
- where);
-
- API_RETURN_OK;
-}
-
char *
weechat_python_api_hook_modifier_cb (const void *pointer, void *data,
const char *modifier,
@@ -5100,6 +5100,9 @@ PyMethodDef weechat_python_funcs[] =
API_DEF_FUNC(prnt_y),
API_DEF_FUNC(log_print),
API_DEF_FUNC(hook_command),
+ API_DEF_FUNC(hook_completion),
+ API_DEF_FUNC(hook_completion_get_string),
+ API_DEF_FUNC(hook_completion_list_add),
API_DEF_FUNC(hook_command_run),
API_DEF_FUNC(hook_timer),
API_DEF_FUNC(hook_fd),
@@ -5112,9 +5115,6 @@ PyMethodDef weechat_python_funcs[] =
API_DEF_FUNC(hook_hsignal),
API_DEF_FUNC(hook_hsignal_send),
API_DEF_FUNC(hook_config),
- API_DEF_FUNC(hook_completion),
- API_DEF_FUNC(hook_completion_get_string),
- API_DEF_FUNC(hook_completion_list_add),
API_DEF_FUNC(hook_modifier),
API_DEF_FUNC(hook_modifier_exec),
API_DEF_FUNC(hook_info),