summaryrefslogtreecommitdiff
path: root/src/plugins/plugin-script.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/plugin-script.h')
-rw-r--r--src/plugins/plugin-script.h123
1 files changed, 79 insertions, 44 deletions
diff --git a/src/plugins/plugin-script.h b/src/plugins/plugin-script.h
index 9202e5934..c797d9de8 100644
--- a/src/plugins/plugin-script.h
+++ b/src/plugins/plugin-script.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2017 Sébastien Helleu <flashcode@flashtux.org>
+ * Copyright (C) 2003-2018 Sébastien Helleu <flashcode@flashtux.org>
*
* This file is part of WeeChat, the extensible chat client.
*
@@ -17,8 +17,8 @@
* along with WeeChat. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef WEECHAT_PLUGIN_SCRIPT_H
-#define WEECHAT_PLUGIN_SCRIPT_H 1
+#ifndef WEECHAT_PLUGIN_PLUGIN_SCRIPT_H
+#define WEECHAT_PLUGIN_PLUGIN_SCRIPT_H
/* constants which defines return types for weechat_<lang>_exec functions */
@@ -26,11 +26,17 @@ enum t_weechat_script_exec_type
{
WEECHAT_SCRIPT_EXEC_INT = 0,
WEECHAT_SCRIPT_EXEC_STRING,
+ WEECHAT_SCRIPT_EXEC_POINTER,
WEECHAT_SCRIPT_EXEC_HASHTABLE,
+ WEECHAT_SCRIPT_EXEC_IGNORE,
};
#define WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE 16
+#define WEECHAT_SCRIPT_STATIC_STRINGS 32
+
+#define WEECHAT_SCRIPT_EVAL_NAME "__eval__"
+
#define WEECHAT_SCRIPT_MSG_NOT_INIT(__current_script, \
__function) \
weechat_printf (NULL, \
@@ -66,48 +72,65 @@ struct t_plugin_script
struct t_plugin_script *next_script; /* link to next script */
};
-struct t_plugin_script_init
+struct t_plugin_script_data
{
- int (*callback_command)(const void *pointer, void *data,
- struct t_gui_buffer *buffer,
- int argc, char **argv, char **argv_eol);
- int (*callback_completion)(const void *pointer, void *data,
- const char *completion_item,
- struct t_gui_buffer *buffer,
- struct t_gui_completion *completion);
- struct t_hdata *(*callback_hdata)(const void *pointer,
- void *data,
- const char *hdata_name);
- struct t_infolist *(*callback_infolist)(const void *pointer,
- void *data,
- const char *infolist_name,
- void *obj_pointer,
- const char *arguments);
- int (*callback_signal_debug_dump)(const void *pointer, void *data,
- const char *signal,
- const char *type_data,
- void *signal_data);
- int (*callback_signal_debug_libs)(const void *pointer, void *data,
- const char *signal,
- const char *type_data,
- void *signal_data);
- int (*callback_signal_script_action)(const void *pointer, void *data,
- const char *signal,
- const char *type_data,
- void *signal_data);
- void (*callback_load_file)(void *data, const char *filename);
+ /* variables */
+ struct t_config_file **config_file;
+ struct t_config_option **config_look_check_license;
+ struct t_config_option **config_look_eval_keep_context;
+ struct t_plugin_script **scripts;
+ struct t_plugin_script **last_script;
+ char *static_string[WEECHAT_SCRIPT_STATIC_STRINGS];
+ int index_static_string;
+
+ /* callbacks */
+ int (*callback_command) (const void *pointer, void *data,
+ struct t_gui_buffer *buffer,
+ int argc, char **argv, char **argv_eol);
+ int (*callback_completion) (const void *pointer, void *data,
+ const char *completion_item,
+ struct t_gui_buffer *buffer,
+ struct t_gui_completion *completion);
+ struct t_hdata *(*callback_hdata) (const void *pointer,
+ void *data,
+ const char *hdata_name);
+ const char *(*callback_info_eval) (const void *pointer,
+ void *data,
+ const char *info_name,
+ const char *arguments);
+ struct t_infolist *(*callback_infolist) (const void *pointer,
+ void *data,
+ const char *infolist_name,
+ void *obj_pointer,
+ const char *arguments);
+ int (*callback_signal_debug_dump) (const void *pointer, void *data,
+ const char *signal,
+ const char *type_data,
+ void *signal_data);
+ int (*callback_signal_script_action) (const void *pointer, void *data,
+ const char *signal,
+ const char *type_data,
+ void *signal_data);
+ void (*callback_load_file) (void *data, const char *filename);
+
+ /* functions */
+ void (*unload_all) ();
};
+extern void plugin_script_display_interpreter (struct t_weechat_plugin *plugin,
+ int indent);
extern void plugin_script_init (struct t_weechat_plugin *weechat_plugin,
int argc, char *argv[],
- struct t_plugin_script_init *init);
+ struct t_plugin_script_data *plugin_data);
extern int plugin_script_valid (struct t_plugin_script *scripts,
struct t_plugin_script *script);
-extern char *plugin_script_ptr2str (void *pointer);
+extern const char *plugin_script_ptr2str (void *pointer);
extern void *plugin_script_str2ptr (struct t_weechat_plugin *weechat_plugin,
const char *script_name,
const char *function_name,
const char *pointer_str);
+extern char *plugin_script_get_static_string (struct t_plugin_script_data *plugin_data,
+ char *string);
extern char *plugin_script_build_function_and_data (const char *function,
const char *data);
extern void plugin_script_get_function_and_data (void *callback_data,
@@ -121,13 +144,24 @@ extern struct t_plugin_script *plugin_script_search (struct t_weechat_plugin *we
const char *name);
extern char *plugin_script_search_path (struct t_weechat_plugin *weechat_plugin,
const char *filename);
+extern struct t_plugin_script *plugin_script_alloc (const char *filename,
+ const char *name,
+ const char *author,
+ const char *version,
+ const char *license,
+ const char *description,
+ const char *shutdown_func,
+ const char *charset);
extern struct t_plugin_script *plugin_script_add (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script **scripts,
- struct t_plugin_script **last_script,
- const char *filename, const char *name,
- const char *author, const char *version,
- const char *license, const char *description,
- const char *shutdown_func, const char *charset);
+ struct t_plugin_script_data *plugin_data,
+ const char *filename,
+ const char *name,
+ const char *author,
+ const char *version,
+ const char *license,
+ const char *description,
+ const char *shutdown_func,
+ const char *charset);
extern void plugin_script_set_buffer_callbacks (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts,
struct t_plugin_script *script,
@@ -138,6 +172,7 @@ extern void plugin_script_set_buffer_callbacks (struct t_weechat_plugin *weechat
int (*callback_buffer_close) (const void *pointer,
void *data,
struct t_gui_buffer *buffer));
+extern void plugin_script_free (struct t_plugin_script *script);
extern void plugin_script_remove (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script **scripts,
struct t_plugin_script **last_script,
@@ -149,7 +184,8 @@ extern void plugin_script_action_add (char **action_list, const char *name);
extern void plugin_script_action_install (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts,
void (*script_unload)(struct t_plugin_script *script),
- int (*script_load)(const char *filename),
+ struct t_plugin_script *(*script_load)(const char *filename,
+ const char *code),
int *quiet,
char **list);
extern void plugin_script_action_remove (struct t_weechat_plugin *weechat_plugin,
@@ -177,9 +213,8 @@ extern struct t_infolist *plugin_script_infolist_list_scripts (struct t_weechat_
void *pointer,
const char *arguments);
extern void plugin_script_end (struct t_weechat_plugin *weechat_plugin,
- struct t_plugin_script **scripts,
- void (*callback_unload_all)());
+ struct t_plugin_script_data *plugin_data);
extern void plugin_script_print_log (struct t_weechat_plugin *weechat_plugin,
struct t_plugin_script *scripts);
-#endif /* WEECHAT_PLUGIN_SCRIPT_H */
+#endif /* WEECHAT_PLUGIN_PLUGIN_SCRIPT_H */