lua: remove use of functions for API constants

v2.8-utf8proc
Sebastien Helleu 2013-03-24 20:01:57 +01:00
parent ff26a8d550
commit 2ffa199a7d
6 changed files with 147 additions and 462 deletions

View File

@ -65,6 +65,7 @@ Version 0.4.1 (under dev!)
the first server in the list)
* irc: add color in output of /names when result is on server buffer (channel
not joined) (bug #38070)
* lua: remove use of functions for API constants
* lua: fix crash on stack overflow: call lua_pop() for values returned by lua
functions (bug #38510)
* perl: simplify code to load scripts

24
NEWS
View File

@ -1,7 +1,7 @@
WeeChat Release Notes
=====================
Sébastien Helleu <flashcode@flashtux.org>
v0.4.1-dev, 2013-03-12
v0.4.1-dev, 2013-03-24
This document lists important changes for each version, that require manual
@ -48,6 +48,28 @@ If you added/changed some rmodifiers, do it manually with these commands:
/rmodifier add message_auth irc_message_auth 1,3* ^(.*(id|identify|register|ghost \S+|release \S+) +)(.*)
----------------------------------------
=== Lua constants ===
For consistency with other supported languages, the API constants in Lua have
been redefined as constants instead of functions.
Therefore, the use of a constant must be changed: the parentheses must be
removed.
The old syntax was:
[source,lua]
----------------------------------------
return weechat.WEECHAT_RC_OK()
----------------------------------------
The new syntax is:
[source,lua]
----------------------------------------
return weechat.WEECHAT_RC_OK
----------------------------------------
=== Guile callbacks ===
The way to give arguments for guile callbacks has been fixed: now arguments are

View File

@ -83,6 +83,10 @@
#define API_DEF_FUNC(__name) \
{ #__name, &weechat_lua_api_##__name }
#define API_DEF_CONST_INT(__name) \
{ #__name, __name, NULL }
#define API_DEF_CONST_STR(__name) \
{ #__name, 0, __name }
/*
@ -5028,411 +5032,7 @@ weechat_lua_api_upgrade_close (lua_State *L)
}
/*
* Lua constant as functions
*/
static int
weechat_lua_api_constant_weechat_rc_ok (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_RC_OK);
return 1;
}
static int
weechat_lua_api_constant_weechat_rc_ok_eat (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_RC_OK_EAT);
return 1;
}
static int
weechat_lua_api_constant_weechat_rc_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_RC_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_read_ok (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_READ_OK);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_read_memory_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_READ_MEMORY_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_read_file_not_found (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_READ_FILE_NOT_FOUND);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_write_ok (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_WRITE_OK);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_write_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_WRITE_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_write_memory_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_WRITE_MEMORY_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_set_ok_changed (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_SET_OK_CHANGED);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_set_ok_same_value (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_set_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_SET_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_set_option_not_found (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_unset_ok_no_reset (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_unset_ok_reset (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_UNSET_OK_RESET);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_unset_ok_removed (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED);
return 1;
}
static int
weechat_lua_api_constant_weechat_config_option_unset_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_CONFIG_OPTION_UNSET_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_list_pos_sort (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushstring (lua_current_interpreter, WEECHAT_LIST_POS_SORT);
return 1;
}
static int
weechat_lua_api_constant_weechat_list_pos_beginning (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushstring (lua_current_interpreter, WEECHAT_LIST_POS_BEGINNING);
return 1;
}
static int
weechat_lua_api_constant_weechat_list_pos_end (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushstring (lua_current_interpreter, WEECHAT_LIST_POS_END);
return 1;
}
static int
weechat_lua_api_constant_weechat_hotlist_low (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushstring (lua_current_interpreter, WEECHAT_HOTLIST_LOW);
return 1;
}
static int
weechat_lua_api_constant_weechat_hotlist_message (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushstring (lua_current_interpreter, WEECHAT_HOTLIST_MESSAGE);
return 1;
}
static int
weechat_lua_api_constant_weechat_hotlist_private (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushstring (lua_current_interpreter, WEECHAT_HOTLIST_PRIVATE);
return 1;
}
static int
weechat_lua_api_constant_weechat_hotlist_highlight (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushstring (lua_current_interpreter, WEECHAT_HOTLIST_HIGHLIGHT);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_process_running (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_PROCESS_RUNNING);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_process_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_PROCESS_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_ok (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_OK);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_address_not_found (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_ip_address_not_found (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_connection_refused (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_proxy_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_PROXY_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_local_hostname_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_gnutls_init_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_gnutls_handshake_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_memory_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_MEMORY_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_timeout (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_TIMEOUT);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_connect_socket_error (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushnumber (lua_current_interpreter, WEECHAT_HOOK_CONNECT_SOCKET_ERROR);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_signal_string (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushstring (lua_current_interpreter, WEECHAT_HOOK_SIGNAL_STRING);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_signal_int (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushstring (lua_current_interpreter, WEECHAT_HOOK_SIGNAL_INT);
return 1;
}
static int
weechat_lua_api_constant_weechat_hook_signal_pointer (lua_State *L)
{
/* make C compiler happy */
(void) L;
lua_pushstring (lua_current_interpreter, WEECHAT_HOOK_SIGNAL_POINTER);
return 1;
}
/*
* Initializes lua functions and constants.
* Lua functions.
*/
const struct luaL_Reg weechat_lua_api_funcs[] = {
@ -5622,54 +5222,57 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
API_DEF_FUNC(upgrade_read),
API_DEF_FUNC(upgrade_close),
/* define constants as function which returns values */
{ "WEECHAT_RC_OK", &weechat_lua_api_constant_weechat_rc_ok },
{ "WEECHAT_RC_OK_EAT", &weechat_lua_api_constant_weechat_rc_ok_eat },
{ "WEECHAT_RC_ERROR", &weechat_lua_api_constant_weechat_rc_error },
{ "WEECHAT_CONFIG_READ_OK", &weechat_lua_api_constant_weechat_config_read_ok },
{ "WEECHAT_CONFIG_READ_MEMORY_ERROR", &weechat_lua_api_constant_weechat_config_read_memory_error },
{ "WEECHAT_CONFIG_READ_FILE_NOT_FOUND", &weechat_lua_api_constant_weechat_config_read_file_not_found },
{ "WEECHAT_CONFIG_WRITE_OK", &weechat_lua_api_constant_weechat_config_write_ok },
{ "WEECHAT_CONFIG_WRITE_ERROR", &weechat_lua_api_constant_weechat_config_write_error },
{ "WEECHAT_CONFIG_WRITE_MEMORY_ERROR", &weechat_lua_api_constant_weechat_config_write_memory_error },
{ "WEECHAT_CONFIG_OPTION_SET_OK_CHANGED", &weechat_lua_api_constant_weechat_config_option_set_ok_changed },
{ "WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE", &weechat_lua_api_constant_weechat_config_option_set_ok_same_value },
{ "WEECHAT_CONFIG_OPTION_SET_ERROR", &weechat_lua_api_constant_weechat_config_option_set_error },
{ "WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND", &weechat_lua_api_constant_weechat_config_option_set_option_not_found },
{ "WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET", &weechat_lua_api_constant_weechat_config_option_unset_ok_no_reset },
{ "WEECHAT_CONFIG_OPTION_UNSET_OK_RESET", &weechat_lua_api_constant_weechat_config_option_unset_ok_reset },
{ "WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED", &weechat_lua_api_constant_weechat_config_option_unset_ok_removed },
{ "WEECHAT_CONFIG_OPTION_UNSET_ERROR", &weechat_lua_api_constant_weechat_config_option_unset_error },
{ "WEECHAT_LIST_POS_SORT", &weechat_lua_api_constant_weechat_list_pos_sort },
{ "WEECHAT_LIST_POS_BEGINNING", &weechat_lua_api_constant_weechat_list_pos_beginning },
{ "WEECHAT_LIST_POS_END", &weechat_lua_api_constant_weechat_list_pos_end },
{ "WEECHAT_HOTLIST_LOW", &weechat_lua_api_constant_weechat_hotlist_low },
{ "WEECHAT_HOTLIST_MESSAGE", &weechat_lua_api_constant_weechat_hotlist_message },
{ "WEECHAT_HOTLIST_PRIVATE", &weechat_lua_api_constant_weechat_hotlist_private },
{ "WEECHAT_HOTLIST_HIGHLIGHT", &weechat_lua_api_constant_weechat_hotlist_highlight },
{ "WEECHAT_HOOK_PROCESS_RUNNING", &weechat_lua_api_constant_weechat_hook_process_running },
{ "WEECHAT_HOOK_PROCESS_ERROR", &weechat_lua_api_constant_weechat_hook_process_error },
{ "WEECHAT_HOOK_CONNECT_OK", &weechat_lua_api_constant_weechat_hook_connect_ok },
{ "WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND", &weechat_lua_api_constant_weechat_hook_connect_address_not_found },
{ "WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND", &weechat_lua_api_constant_weechat_hook_connect_ip_address_not_found },
{ "WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED", &weechat_lua_api_constant_weechat_hook_connect_connection_refused },
{ "WEECHAT_HOOK_CONNECT_PROXY_ERROR", &weechat_lua_api_constant_weechat_hook_connect_proxy_error },
{ "WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR", &weechat_lua_api_constant_weechat_hook_connect_local_hostname_error },
{ "WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR", &weechat_lua_api_constant_weechat_hook_connect_gnutls_init_error },
{ "WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR", &weechat_lua_api_constant_weechat_hook_connect_gnutls_handshake_error },
{ "WEECHAT_HOOK_CONNECT_MEMORY_ERROR", &weechat_lua_api_constant_weechat_hook_connect_memory_error },
{ "WEECHAT_HOOK_CONNECT_TIMEOUT", &weechat_lua_api_constant_weechat_hook_connect_timeout },
{ "WEECHAT_HOOK_CONNECT_SOCKET_ERROR", &weechat_lua_api_constant_weechat_hook_connect_socket_error },
{ "WEECHAT_HOOK_SIGNAL_STRING", &weechat_lua_api_constant_weechat_hook_signal_string },
{ "WEECHAT_HOOK_SIGNAL_INT", &weechat_lua_api_constant_weechat_hook_signal_int },
{ "WEECHAT_HOOK_SIGNAL_POINTER", &weechat_lua_api_constant_weechat_hook_signal_pointer },
{ NULL, NULL }
};
const struct t_lua_const weechat_lua_api_consts[] =
{
API_DEF_CONST_INT(WEECHAT_RC_OK),
API_DEF_CONST_INT(WEECHAT_RC_OK_EAT),
API_DEF_CONST_INT(WEECHAT_RC_ERROR),
API_DEF_CONST_INT(WEECHAT_CONFIG_READ_OK),
API_DEF_CONST_INT(WEECHAT_CONFIG_READ_MEMORY_ERROR),
API_DEF_CONST_INT(WEECHAT_CONFIG_READ_FILE_NOT_FOUND),
API_DEF_CONST_INT(WEECHAT_CONFIG_WRITE_OK),
API_DEF_CONST_INT(WEECHAT_CONFIG_WRITE_ERROR),
API_DEF_CONST_INT(WEECHAT_CONFIG_WRITE_MEMORY_ERROR),
API_DEF_CONST_INT(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED),
API_DEF_CONST_INT(WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE),
API_DEF_CONST_INT(WEECHAT_CONFIG_OPTION_SET_ERROR),
API_DEF_CONST_INT(WEECHAT_CONFIG_OPTION_SET_OPTION_NOT_FOUND),
API_DEF_CONST_INT(WEECHAT_CONFIG_OPTION_UNSET_OK_NO_RESET),
API_DEF_CONST_INT(WEECHAT_CONFIG_OPTION_UNSET_OK_RESET),
API_DEF_CONST_INT(WEECHAT_CONFIG_OPTION_UNSET_OK_REMOVED),
API_DEF_CONST_INT(WEECHAT_CONFIG_OPTION_UNSET_ERROR),
API_DEF_CONST_STR(WEECHAT_LIST_POS_SORT),
API_DEF_CONST_STR(WEECHAT_LIST_POS_BEGINNING),
API_DEF_CONST_STR(WEECHAT_LIST_POS_END),
API_DEF_CONST_STR(WEECHAT_HOTLIST_LOW),
API_DEF_CONST_STR(WEECHAT_HOTLIST_MESSAGE),
API_DEF_CONST_STR(WEECHAT_HOTLIST_PRIVATE),
API_DEF_CONST_STR(WEECHAT_HOTLIST_HIGHLIGHT),
API_DEF_CONST_INT(WEECHAT_HOOK_PROCESS_RUNNING),
API_DEF_CONST_INT(WEECHAT_HOOK_PROCESS_ERROR),
API_DEF_CONST_INT(WEECHAT_HOOK_CONNECT_OK),
API_DEF_CONST_INT(WEECHAT_HOOK_CONNECT_ADDRESS_NOT_FOUND),
API_DEF_CONST_INT(WEECHAT_HOOK_CONNECT_IP_ADDRESS_NOT_FOUND),
API_DEF_CONST_INT(WEECHAT_HOOK_CONNECT_CONNECTION_REFUSED),
API_DEF_CONST_INT(WEECHAT_HOOK_CONNECT_PROXY_ERROR),
API_DEF_CONST_INT(WEECHAT_HOOK_CONNECT_LOCAL_HOSTNAME_ERROR),
API_DEF_CONST_INT(WEECHAT_HOOK_CONNECT_GNUTLS_INIT_ERROR),
API_DEF_CONST_INT(WEECHAT_HOOK_CONNECT_GNUTLS_HANDSHAKE_ERROR),
API_DEF_CONST_INT(WEECHAT_HOOK_CONNECT_MEMORY_ERROR),
API_DEF_CONST_INT(WEECHAT_HOOK_CONNECT_TIMEOUT),
API_DEF_CONST_INT(WEECHAT_HOOK_CONNECT_SOCKET_ERROR),
API_DEF_CONST_STR(WEECHAT_HOOK_SIGNAL_STRING),
API_DEF_CONST_STR(WEECHAT_HOOK_SIGNAL_INT),
API_DEF_CONST_STR(WEECHAT_HOOK_SIGNAL_POINTER),
{ NULL, 0, NULL }
};

View File

@ -22,6 +22,7 @@
#define __WEECHAT_LUA_API_H 1
extern struct luaL_Reg weechat_lua_api_funcs[];
extern struct t_lua_const weechat_lua_api_consts[];
extern int weechat_lua_api_buffer_input_data_cb (void *data,
struct t_gui_buffer *buffer,

View File

@ -244,26 +244,74 @@ weechat_lua_exec (struct t_plugin_script *script, int ret_type,
return ret_value;
}
/*
* Adds a constant.
*/
void
weechat_lua_add_constant (lua_State *L, struct t_lua_const *ptr_const)
{
lua_pushstring (L, ptr_const->name);
if (ptr_const->str_value)
lua_pushstring (L, ptr_const->str_value);
else
lua_pushnumber (L, ptr_const->int_value);
lua_settable(L, -3);
}
/*
* Called when a constant is modified.
*/
int
weechat_lua_newindex (lua_State *L)
{
luaL_error(L, "Error: read-only constant");
return 0;
}
/*
* Registers a library to use inside lua script.
*/
void weechat_lua_register_lib (lua_State *L, const char *libname,
const luaL_Reg *l)
void
weechat_lua_register_lib (lua_State *L, const char *libname,
const luaL_Reg *lua_api_funcs,
struct t_lua_const lua_api_consts[])
{
int i;
#if LUA_VERSION_NUM >= 502
if (libname)
{
lua_newtable (L);
luaL_setfuncs (L, l, 0);
luaL_setfuncs (L, lua_api_funcs, 0);
lua_pushvalue (L, -1);
lua_setglobal (L, libname);
}
else
luaL_setfuncs (L, l, 0);
luaL_setfuncs (L, lua_api_funcs, 0);
#else
luaL_register (L, libname, l);
luaL_register (L, libname, lua_api_funcs);
#endif
luaL_newmetatable (L, "weechat");
lua_pushliteral (L, "__index");
lua_newtable (L);
for (i= 0; lua_api_consts[i].name; i++)
{
weechat_lua_add_constant (L, &lua_api_consts[i]);
}
lua_settable (L, -3);
lua_pushliteral (L, "__newindex");
lua_pushcfunction (L, weechat_lua_newindex);
lua_settable (L, -3);
lua_setmetatable (L, -2);
lua_pop (L, 1);
}
/*
@ -329,7 +377,9 @@ weechat_lua_load (const char *filename)
luaopen_debug (lua_current_interpreter);
#endif
weechat_lua_register_lib (lua_current_interpreter, "weechat", weechat_lua_api_funcs);
weechat_lua_register_lib (lua_current_interpreter, "weechat",
weechat_lua_api_funcs,
weechat_lua_api_consts);
#ifdef LUA_VERSION_NUM
if (luaL_dostring (lua_current_interpreter, weechat_lua_code) != 0)

View File

@ -26,6 +26,13 @@
#define LUA_CURRENT_SCRIPT_NAME ((lua_current_script) ? lua_current_script->name : "-")
struct t_lua_const
{
char *name;
int int_value;
char *str_value;
};
extern struct t_weechat_plugin *weechat_lua_plugin;
extern int lua_quiet;
@ -47,6 +54,7 @@ extern void *weechat_lua_exec (struct t_plugin_script *script, int ret_type,
const char *function,
const char *format, void **argv);
extern void weechat_lua_register_lib(lua_State *L, const char *libname,
const luaL_Reg *l);
const luaL_Reg *lua_api_funcs,
struct t_lua_const lua_api_consts[]);
#endif /* __WEECHAT_LUA_H */