core: add type char for hdata and function hdata_char in plugin/script API

v2.8-utf8proc
Sebastien Helleu 2011-11-25 15:09:44 +01:00
parent 96940af8c3
commit bfc010df2f
13 changed files with 311 additions and 10 deletions

View File

@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.3.7-dev, 2011-11-21
v0.3.7-dev, 2011-11-25
Version 0.3.7 (under dev!)
@ -30,7 +30,7 @@ Version 0.3.7 (under dev!)
* core: fix compilation error with "pid_t" on Mac OS X (bug #34639)
* core: enable background process under Cygwin to connect to servers, fix
reconnection problem (bug #34626)
* api: add new functions strcasecmp_range and strncasecmp_range
* api: add new functions strcasecmp_range, strncasecmp_range and hdata_char
* irc: do not delete servers added in irc.conf on /reload (bug #34872)
* irc: remove autorejoin on channels when disconnected from server (bug #32207)
* irc: display messages kick/kill/mode/topic even if nick is ignored

View File

@ -12092,6 +12092,7 @@ Arguments:
* 'name': variable name
* 'offset': offset of variable in structure
* 'type': variable type, one of:
** WEECHAT_HDATA_CHAR
** WEECHAT_HDATA_INTEGER
** WEECHAT_HDATA_LONG
** WEECHAT_HDATA_STRING
@ -12305,6 +12306,9 @@ C example:
int type = weechat_hdata_get_var_type (hdata, "name");
switch (type)
{
case WEECHAT_HDATA_CHAR:
/* ... */
break;
case WEECHAT_HDATA_INTEGER:
/* ... */
break;
@ -12589,6 +12593,48 @@ if buffer:
buffer = weechat.hdata_move(hdata, buffer, -1)
----------------------------------------
weechat_hdata_char
^^^^^^^^^^^^^^^^^^
_New in version 0.3.7._
Return value of char variable in structure using hdata.
Prototype:
[source,C]
----------------------------------------
char weechat_hdata_char (struct t_hdata *hdata, void *pointer, const char *name);
----------------------------------------
Arguments:
* 'hdata': hdata pointer
* 'pointer': pointer to WeeChat/plugin object
* 'name': variable name (must be type "char")
Return value:
* char value of variable
C example:
[source,C]
----------------------------------------
weechat_printf (NULL, "letter = %c", weechat_hdata_char (hdata, pointer, "letter"));
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototype
value = weechat.hdata_char(hdata, pointer, name)
# example
weechat.prnt("", "letter = %c" % weechat.hdata_char(hdata, pointer, "letter"))
----------------------------------------
weechat_hdata_integer
^^^^^^^^^^^^^^^^^^^^^

View File

@ -12297,6 +12297,7 @@ Paramètres :
* 'name' : nom de la variable
* 'offset' : position (offset) de la variable dans la structure
* 'type' : type de la variable, un parmi ceux-ci :
** WEECHAT_HDATA_CHAR
** WEECHAT_HDATA_INTEGER
** WEECHAT_HDATA_LONG
** WEECHAT_HDATA_STRING
@ -12512,6 +12513,9 @@ Exemple en C :
int type = weechat_hdata_get_var_type (hdata, "name");
switch (type)
{
case WEECHAT_HDATA_CHAR:
/* ... */
break;
case WEECHAT_HDATA_INTEGER:
/* ... */
break;
@ -12797,6 +12801,49 @@ if buffer:
buffer = weechat.hdata_move(hdata, buffer, -1)
----------------------------------------
weechat_hdata_char
^^^^^^^^^^^^^^^^^^
_Nouveau dans la version 0.3.7._
Retourne la valeur de la variable dans la structure en utilisant le hdata, sous
forme de caractère.
Prototype :
[source,C]
----------------------------------------
char weechat_hdata_char (struct t_hdata *hdata, void *pointer, const char *name);
----------------------------------------
Paramètres :
* 'hdata' : pointeur vers le hdata
* 'pointer' : pointeur vers un objet WeeChat ou d'une extension
* 'name' : nom de la variable (doit être de type "char")
Valeur de retour :
* valeur de la variable, sous forme de caractère
Exemple en C :
[source,C]
----------------------------------------
weechat_printf (NULL, "letter = %c", weechat_hdata_char (hdata, pointer, "letter"));
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototype
value = weechat.hdata_char(hdata, pointer, name)
# exemple
weechat.prnt("", "letter = %c" % weechat.hdata_char(hdata, pointer, "letter"))
----------------------------------------
weechat_hdata_integer
^^^^^^^^^^^^^^^^^^^^^

View File

@ -12205,6 +12205,7 @@ Argomenti:
* 'name': nome della variabile
* 'offset': offset della variabile nella struttura
* 'type': tipo variabile, una di:
** WEECHAT_HDATA_CHAR
** WEECHAT_HDATA_INTEGER
** WEECHAT_HDATA_LONG
** WEECHAT_HDATA_STRING
@ -12419,6 +12420,9 @@ Esempio in C:
int type = weechat_hdata_get_var_type (hdata, "name");
switch (type)
{
case WEECHAT_HDATA_CHAR:
/* ... */
break;
case WEECHAT_HDATA_INTEGER:
/* ... */
break;
@ -12704,6 +12708,49 @@ if buffer:
buffer = weechat.hdata_move(hdata, buffer, -1)
----------------------------------------
weechat_hdata_char
^^^^^^^^^^^^^^^^^^
_Novità nella versione 0.3.7._
Restituisce il valore di una variabile char in una struttura dati usando hdata.
Prototipo:
[source,C]
----------------------------------------
char weechat_hdata_char (struct t_hdata *hdata, void *pointer, const char *name);
----------------------------------------
Argomenti:
* 'hdata': puntatore hdata
* 'pointer': puntatore all'oggetto di WeeChat/plugin
* 'name': nome della variabile (deve essere di tipo "char")
Valore restituito:
// TRANSLATION MISSING
* char value of variable
Esempio in C:
[source,C]
----------------------------------------
weechat_printf (NULL, "letter = %c", weechat_hdata_char (hdata, pointer, "letter"));
----------------------------------------
Script (Python):
[source,python]
----------------------------------------
# prototipo
value = weechat.hdata_char(hdata, pointer, name)
# esempio
weechat.prnt("", "letter = %c" % weechat.hdata_char(hdata, pointer, "letter"))
----------------------------------------
weechat_hdata_integer
^^^^^^^^^^^^^^^^^^^^^

View File

@ -38,8 +38,8 @@
struct t_hashtable *weechat_hdata = NULL;
char *hdata_type_string[6] =
{ "other", "integer", "long", "string", "pointer", "time" };
char *hdata_type_string[7] =
{ "other", "char", "integer", "long", "string", "pointer", "time" };
/*
@ -261,6 +261,25 @@ hdata_move (struct t_hdata *hdata, void *pointer, int count)
return NULL;
}
/*
* hdata_char: get char value of a variable in structure using hdata
*/
char
hdata_char (struct t_hdata *hdata, void *pointer, const char *name)
{
int offset;
if (hdata && pointer)
{
offset = hdata_get_var_offset (hdata, name);
if (offset >= 0)
return *((char *)(pointer + offset));
}
return '\0';
}
/*
* hdata_integer: get integer value of a variable in structure using hdata
*/

View File

@ -62,6 +62,8 @@ extern void *hdata_get_var_at_offset (struct t_hdata *hdata, void *pointer,
int offset);
extern void *hdata_get_list (struct t_hdata *hdata, const char *name);
extern void *hdata_move (struct t_hdata *hdata, void *pointer, int count);
extern char hdata_char (struct t_hdata *hdata, void *pointer,
const char *name);
extern int hdata_integer (struct t_hdata *hdata, void *pointer,
const char *name);
extern long hdata_long (struct t_hdata *hdata, void *pointer,

View File

@ -739,6 +739,7 @@ plugin_load (const char *filename, int argc, char **argv)
new_plugin->hdata_get_var_at_offset = &hdata_get_var_at_offset;
new_plugin->hdata_get_list = &hdata_get_list;
new_plugin->hdata_move = &hdata_move;
new_plugin->hdata_char = &hdata_char;
new_plugin->hdata_integer = &hdata_integer;
new_plugin->hdata_long = &hdata_long;
new_plugin->hdata_string = &hdata_string;

View File

@ -4855,6 +4855,28 @@ weechat_guile_api_hdata_move (SCM hdata, SCM pointer, SCM count)
API_RETURN_STRING_FREE(result);
}
/*
* weechat_guile_api_hdata_char: get char value of a variable in structure
* using hdata
*/
SCM
weechat_guile_api_hdata_char (SCM hdata, SCM pointer, SCM name)
{
int value;
API_FUNC(1, "hdata_char", API_RETURN_INT(0));
if (!scm_is_string (hdata) || !scm_is_string (pointer)
|| !scm_is_string (name))
API_WRONG_ARGS(API_RETURN_INT(0));
value = (int)weechat_hdata_char (script_str2ptr (scm_i_string_chars (hdata)),
script_str2ptr (scm_i_string_chars (pointer)),
scm_i_string_chars (name));
API_RETURN_INT(value);
}
/*
* weechat_guile_api_hdata_integer: get integer value of a variable in structure
* using hdata
@ -5312,6 +5334,7 @@ weechat_guile_api_module_init (void *data)
scm_c_define_gsubr ("weechat:hdata_get_var_hdata", 2, 0, 0, &weechat_guile_api_hdata_get_var_hdata);
scm_c_define_gsubr ("weechat:hdata_get_list", 2, 0, 0, &weechat_guile_api_hdata_get_list);
scm_c_define_gsubr ("weechat:hdata_move", 3, 0, 0, &weechat_guile_api_hdata_move);
scm_c_define_gsubr ("weechat:hdata_char", 3, 0, 0, &weechat_guile_api_hdata_char);
scm_c_define_gsubr ("weechat:hdata_integer", 3, 0, 0, &weechat_guile_api_hdata_integer);
scm_c_define_gsubr ("weechat:hdata_long", 3, 0, 0, &weechat_guile_api_hdata_long);
scm_c_define_gsubr ("weechat:hdata_string", 3, 0, 0, &weechat_guile_api_hdata_string);

View File

@ -5351,6 +5351,32 @@ weechat_lua_api_hdata_move (lua_State *L)
API_RETURN_STRING_FREE(result);
}
/*
* weechat_lua_api_hdata_char: get char value of a variable in structure using
* hdata
*/
static int
weechat_lua_api_hdata_char (lua_State *L)
{
const char *hdata, *pointer, *name;
int value;
API_FUNC(1, "hdata_char", API_RETURN_INT(0));
if (lua_gettop (lua_current_interpreter) < 3)
API_WRONG_ARGS(API_RETURN_INT(0));
hdata = lua_tostring (lua_current_interpreter, -3);
pointer = lua_tostring (lua_current_interpreter, -2);
name = lua_tostring (lua_current_interpreter, -1);
value = (int)weechat_hdata_char (script_str2ptr (hdata),
script_str2ptr (pointer),
name);
API_RETURN_INT(value);
}
/*
* weechat_lua_api_hdata_integer: get integer value of a variable in structure
* using hdata
@ -6205,6 +6231,7 @@ const struct luaL_reg weechat_lua_api_funcs[] = {
{ "hdata_get_var_hdata", &weechat_lua_api_hdata_get_var_hdata },
{ "hdata_get_list", &weechat_lua_api_hdata_get_list },
{ "hdata_move", &weechat_lua_api_hdata_move },
{ "hdata_char", &weechat_lua_api_hdata_char },
{ "hdata_integer", &weechat_lua_api_hdata_integer },
{ "hdata_long", &weechat_lua_api_hdata_long },
{ "hdata_string", &weechat_lua_api_hdata_string },

View File

@ -5089,6 +5089,31 @@ XS (XS_weechat_api_hdata_move)
API_RETURN_STRING_FREE(result);
}
/*
* weechat::hdata_char: get char value of a variable in structure using hdata
*/
XS (XS_weechat_api_hdata_char)
{
char *hdata, *pointer, *name;
int value;
dXSARGS;
API_FUNC(1, "hdata_char", API_RETURN_INT(0));
if (items < 3)
API_WRONG_ARGS(API_RETURN_INT(0));
hdata = SvPV_nolen (ST (0));
pointer = SvPV_nolen (ST (1));
name = SvPV_nolen (ST (2));
value = (int)weechat_hdata_char (script_str2ptr (hdata),
script_str2ptr (pointer),
name);
API_RETURN_INT(value);
}
/*
* weechat::hdata_integer: get integer value of a variable in structure using
* hdata
@ -5562,6 +5587,7 @@ weechat_perl_api_init (pTHX)
newXS ("weechat::hdata_get_var_hdata", XS_weechat_api_hdata_get_var_hdata, "weechat");
newXS ("weechat::hdata_get_list", XS_weechat_api_hdata_get_list, "weechat");
newXS ("weechat::hdata_move", XS_weechat_api_hdata_move, "weechat");
newXS ("weechat::hdata_char", XS_weechat_api_hdata_char, "weechat");
newXS ("weechat::hdata_integer", XS_weechat_api_hdata_integer, "weechat");
newXS ("weechat::hdata_long", XS_weechat_api_hdata_long, "weechat");
newXS ("weechat::hdata_string", XS_weechat_api_hdata_string, "weechat");

View File

@ -5270,6 +5270,31 @@ weechat_python_api_hdata_move (PyObject *self, PyObject *args)
API_RETURN_STRING_FREE(result);
}
/*
* weechat_python_api_hdata_char: get char value of a variable in structure
* using hdata
*/
static PyObject *
weechat_python_api_hdata_char (PyObject *self, PyObject *args)
{
char *hdata, *pointer, *name;
int value;
API_FUNC(1, "hdata_char", API_RETURN_INT(0));
hdata = NULL;
pointer = NULL;
name = NULL;
if (!PyArg_ParseTuple (args, "sss", &hdata, &pointer, &name))
API_WRONG_ARGS(API_RETURN_INT(0));
value = (int)weechat_hdata_char (script_str2ptr (hdata),
script_str2ptr (pointer),
name);
API_RETURN_INT(value);
}
/*
* weechat_python_api_hdata_integer: get integer value of a variable in
* structure using hdata
@ -5733,6 +5758,7 @@ PyMethodDef weechat_python_funcs[] =
{ "hdata_get_var_hdata", &weechat_python_api_hdata_get_var_hdata, METH_VARARGS, "" },
{ "hdata_get_list", &weechat_python_api_hdata_get_list, METH_VARARGS, "" },
{ "hdata_move", &weechat_python_api_hdata_move, METH_VARARGS, "" },
{ "hdata_char", &weechat_python_api_hdata_char, METH_VARARGS, "" },
{ "hdata_integer", &weechat_python_api_hdata_integer, METH_VARARGS, "" },
{ "hdata_long", &weechat_python_api_hdata_long, METH_VARARGS, "" },
{ "hdata_string", &weechat_python_api_hdata_string, METH_VARARGS, "" },

View File

@ -6055,6 +6055,37 @@ weechat_ruby_api_hdata_move (VALUE class, VALUE hdata, VALUE pointer,
API_RETURN_STRING_FREE(result);
}
/*
* weechat_ruby_api_hdata_char: get char value of a variable in structure using
* hdata
*/
static VALUE
weechat_ruby_api_hdata_char (VALUE class, VALUE hdata, VALUE pointer,
VALUE name)
{
char *c_hdata, *c_pointer, *c_name;
int value;
API_FUNC(1, "hdata_char", API_RETURN_INT(0));
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (name))
API_WRONG_ARGS(API_RETURN_INT(0));
Check_Type (hdata, T_STRING);
Check_Type (pointer, T_STRING);
Check_Type (name, T_STRING);
c_hdata = StringValuePtr (hdata);
c_pointer = StringValuePtr (pointer);
c_name = StringValuePtr (name);
value = (int)weechat_hdata_char (script_str2ptr (c_hdata),
script_str2ptr (c_pointer),
c_name);
API_RETURN_INT(value);
}
/*
* weechat_ruby_api_hdata_integer: get integer value of a variable in structure
* using hdata
@ -6619,6 +6650,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "hdata_get_var_hdata", &weechat_ruby_api_hdata_get_var_hdata, 2);
rb_define_module_function (ruby_mWeechat, "hdata_get_list", &weechat_ruby_api_hdata_get_list, 2);
rb_define_module_function (ruby_mWeechat, "hdata_move", &weechat_ruby_api_hdata_move, 3);
rb_define_module_function (ruby_mWeechat, "hdata_char", &weechat_ruby_api_hdata_char, 3);
rb_define_module_function (ruby_mWeechat, "hdata_integer", &weechat_ruby_api_hdata_integer, 3);
rb_define_module_function (ruby_mWeechat, "hdata_long", &weechat_ruby_api_hdata_long, 3);
rb_define_module_function (ruby_mWeechat, "hdata_string", &weechat_ruby_api_hdata_string, 3);

View File

@ -46,7 +46,7 @@ struct timeval;
*/
/* API version (used to check that plugin has same API and can be loaded) */
#define WEECHAT_PLUGIN_API_VERSION "20111112-01"
#define WEECHAT_PLUGIN_API_VERSION "20111125-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@ -105,11 +105,12 @@ struct timeval;
/* types for hdata */
#define WEECHAT_HDATA_OTHER 0
#define WEECHAT_HDATA_INTEGER 1
#define WEECHAT_HDATA_LONG 2
#define WEECHAT_HDATA_STRING 3
#define WEECHAT_HDATA_POINTER 4
#define WEECHAT_HDATA_TIME 5
#define WEECHAT_HDATA_CHAR 1
#define WEECHAT_HDATA_INTEGER 2
#define WEECHAT_HDATA_LONG 3
#define WEECHAT_HDATA_STRING 4
#define WEECHAT_HDATA_POINTER 5
#define WEECHAT_HDATA_TIME 6
/* buffer hotlist */
#define WEECHAT_HOTLIST_LOW "0"
@ -824,6 +825,8 @@ struct t_weechat_plugin
int offset);
void *(*hdata_get_list) (struct t_hdata *hdata, const char *name);
void *(*hdata_move) (struct t_hdata *hdata, void *pointer, int count);
char (*hdata_char) (struct t_hdata *hdata, void *pointer,
const char *name);
int (*hdata_integer) (struct t_hdata *hdata, void *pointer,
const char *name);
long (*hdata_long) (struct t_hdata *hdata, void *pointer,
@ -1567,6 +1570,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
weechat_plugin->hdata_get_list(__hdata, __name)
#define weechat_hdata_move(__hdata, __pointer, __count) \
weechat_plugin->hdata_move(__hdata, __pointer, __count)
#define weechat_hdata_char(__hdata, __pointer, __name) \
weechat_plugin->hdata_char(__hdata, __pointer, __name)
#define weechat_hdata_integer(__hdata, __pointer, __name) \
weechat_plugin->hdata_integer(__hdata, __pointer, __name)
#define weechat_hdata_long(__hdata, __pointer, __name) \