1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-06 18:45:42 +02:00

Migration of Lua plugin to new API

This commit is contained in:
Sebastien Helleu
2008-01-13 23:29:43 +01:00
parent 05e1e4715c
commit 68f7238887
12 changed files with 3754 additions and 2762 deletions
+4 -1
View File
@@ -20,6 +20,9 @@ libdir = ${weechat_libdir}/plugins
lib_LTLIBRARIES = lua.la
lua_la_SOURCES = lua.c
lua_la_SOURCES = weechat-lua.c \
weechat-lua.h \
weechat-lua-api.c \
weechat-lua-api.h
lua_la_LDFLAGS = -module
lua_la_LIBADD = ../lib_weechat_plugins_scripts.la $(LUA_LFLAGS)
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+25
View File
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_LUA_API_H
#define __WEECHAT_LUA_API_H 1
extern struct luaL_reg weechat_lua_api_funcs[];
#endif /* weechat-lua.h */
File diff suppressed because it is too large Load Diff
+35
View File
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>
* See README for License detail, AUTHORS for developers list.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __WEECHAT_LUA_H
#define __WEECHAT_LUA_H 1
#define weechat_plugin weechat_lua_plugin
extern struct t_weechat_plugin *weechat_lua_plugin;
extern struct t_plugin_script *lua_scripts;
extern struct t_plugin_script *lua_current_script;
extern char *lua_current_script_filename;
extern lua_State *lua_current_interpreter;
extern void * weechat_lua_exec (struct t_plugin_script *script,
int ret_type, char *function, char **argv);
#endif /* weechat-lua.h */
+6 -6
View File
@@ -45,7 +45,7 @@
XSRETURN (1); \
} \
XST_mPV (0, ""); \
XSRETURN (1);
XSRETURN (1)
#define PERL_RETURN_STRING_FREE(__string) \
if (__string) \
{ \
@@ -54,7 +54,7 @@
XSRETURN (1); \
} \
XST_mPV (0, ""); \
XSRETURN (1);
XSRETURN (1)
extern void boot_DynaLoader (pTHX_ CV* cv);
@@ -328,7 +328,7 @@ static XS (XS_weechat_color)
}
/*
* weechat::print: print message into a buffer (current or specified one)
* weechat::print: print message in a buffer
*/
static XS (XS_weechat_print)
@@ -828,7 +828,7 @@ static XS (XS_weechat_hook_signal)
static XS (XS_weechat_hook_signal_send)
{
char *type_data;
int int_value;
int number;
dXSARGS;
/* make C compiler happy */
@@ -856,10 +856,10 @@ static XS (XS_weechat_hook_signal_send)
}
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
{
int_value = SvIV(ST (2));
number = SvIV(ST (2));
weechat_hook_signal_send (SvPV (ST (0), PL_na), /* signal */
type_data,
&int_value); /* signal_data */
&number); /* signal_data */
PERL_RETURN_OK;
}
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
+1 -2
View File
@@ -730,8 +730,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
weechat_hook_signal ("dump_data", &weechat_perl_dump_data_cb, NULL);
script_init (weechat_perl_plugin);
script_auto_load (weechat_perl_plugin,
"perl", &weechat_perl_load_cb);
script_auto_load (weechat_perl_plugin, "perl", &weechat_perl_load_cb);
/* init ok */
return WEECHAT_RC_OK;
@@ -41,7 +41,7 @@
#define PYTHON_RETURN_STRING(__string) \
if (__string) \
return Py_BuildValue ("s", __string); \
return Py_BuildValue ("s", "");
return Py_BuildValue ("s", "")
#define PYTHON_RETURN_STRING_FREE(__string) \
if (__string) \
{ \
@@ -49,7 +49,7 @@
free (__string); \
return object; \
} \
return Py_BuildValue ("s", "");
return Py_BuildValue ("s", "")
/*
@@ -342,7 +342,7 @@ weechat_python_api_color (PyObject *self, PyObject *args)
}
/*
* weechat_python_api_prnt: print message into a buffer (current or specified one)
* weechat_python_api_prnt: print message in a buffer
*/
static PyObject *
@@ -900,7 +900,7 @@ static PyObject *
weechat_python_api_hook_signal_send (PyObject *self, PyObject *args)
{
char *signal, *type_data, *signal_data, *error;
long number;
int number;
/* make C compiler happy */
(void) self;
@@ -920,10 +920,11 @@ weechat_python_api_hook_signal_send (PyObject *self, PyObject *args)
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("hook_signal_send");
PYTHON_RETURN_ERROR;
}
if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_STRING) == 0)
{
weechat_hook_signal_send (signal, type_data, signal_data);
PYTHON_RETURN_OK;
}
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
{
@@ -933,13 +934,16 @@ weechat_python_api_hook_signal_send (PyObject *self, PyObject *args)
{
weechat_hook_signal_send (signal, type_data, &number);
}
PYTHON_RETURN_OK;
}
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
{
weechat_hook_signal_send (signal, type_data,
script_string_to_pointer (signal_data));
PYTHON_RETURN_OK;
}
PYTHON_RETURN_OK;
PYTHON_RETURN_ERROR;
}
/*
+1 -2
View File
@@ -767,8 +767,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
weechat_hook_signal ("dump_data", &weechat_python_dump_data_cb, NULL);
script_init (weechat_python_plugin);
script_auto_load (weechat_python_plugin,
"python", &weechat_python_load_cb);
script_auto_load (weechat_python_plugin, "python", &weechat_python_load_cb);
/* init ok */
return WEECHAT_RC_OK;
+11 -9
View File
@@ -45,7 +45,7 @@
#define RUBY_RETURN_STRING(__string) \
if (__string) \
return rb_str_new2 (__string); \
return rb_str_new2 ("");
return rb_str_new2 ("")
#define RUBY_RETURN_STRING_FREE(__string) \
if (__string) \
{ \
@@ -53,7 +53,7 @@
free (__string); \
return return_value; \
} \
return rb_str_new2 ("");
return rb_str_new2 ("")
/*
@@ -402,7 +402,7 @@ weechat_ruby_api_color (VALUE class, VALUE color)
}
/*
* weechat_ruby_api_print: print message into a buffer (current or specified one)
* weechat_ruby_api_print: print message in a buffer
*/
static VALUE
@@ -1043,7 +1043,7 @@ weechat_ruby_api_hook_signal_send (VALUE class, VALUE signal, VALUE type_data,
VALUE signal_data)
{
char *c_signal, *c_type_data, *c_signal_data;
int int_value;
int number;
/* make C compiler happy */
(void) class;
@@ -1080,8 +1080,8 @@ weechat_ruby_api_hook_signal_send (VALUE class, VALUE signal, VALUE type_data,
else if (strcmp (c_type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
{
Check_Type (signal_data, T_STRING);
int_value = FIX2INT (signal_data);
weechat_hook_signal_send (c_signal, c_type_data, &int_value);
number = FIX2INT (signal_data);
weechat_hook_signal_send (c_signal, c_type_data, &number);
RUBY_RETURN_OK;
}
else if (strcmp (c_type_data, WEECHAT_HOOK_SIGNAL_POINTER) == 0)
@@ -1101,7 +1101,8 @@ weechat_ruby_api_hook_signal_send (VALUE class, VALUE signal, VALUE type_data,
*/
int
weechat_ruby_api_hook_config_cb (void *data, char *type, char *option, char *value)
weechat_ruby_api_hook_config_cb (void *data, char *type, char *option,
char *value)
{
struct t_script_callback *script_callback;
char *ruby_argv[4];
@@ -1184,7 +1185,8 @@ weechat_ruby_api_hook_config (VALUE class, VALUE type, VALUE option, VALUE funct
*/
int
weechat_ruby_api_hook_completion_cb (void *data, char *completion, struct t_gui_buffer *buffer,
weechat_ruby_api_hook_completion_cb (void *data, char *completion,
struct t_gui_buffer *buffer,
struct t_weelist *list)
{
struct t_script_callback *script_callback;
@@ -1734,7 +1736,7 @@ weechat_ruby_api_nicklist_add_nick (VALUE class, VALUE buffer, VALUE group,
script_string_to_pointer (c_group),
c_name,
c_color,
prefix,
char_prefix,
c_prefix_color,
c_visible);
+1 -2
View File
@@ -821,8 +821,7 @@ weechat_plugin_init (struct t_weechat_plugin *plugin)
weechat_hook_signal ("dump_data", &weechat_ruby_dump_data_cb, NULL);
script_init (weechat_ruby_plugin);
script_auto_load (weechat_ruby_plugin,
"ruby", &weechat_ruby_load_cb);
script_auto_load (weechat_ruby_plugin, "ruby", &weechat_ruby_load_cb);
/* init ok */
return WEECHAT_RC_OK;