1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 16:53:14 +02:00

api: add function "hdata_longlong" (issue #2081)

This commit is contained in:
Sébastien Helleu
2024-02-26 07:33:12 +01:00
parent c85b57b8b3
commit 9e0dd18152
29 changed files with 730 additions and 30 deletions
+8
View File
@@ -125,6 +125,14 @@ end:
ptr_buffer, list_keys[i]) : -1);
weechat_hashtable_set (info, list_keys[i], str_value);
break;
case WEECHAT_HDATA_LONGLONG:
snprintf (str_value, sizeof (str_value),
"%lld",
(ptr_buffer) ?
weechat_hdata_longlong (buflist_hdata_buffer,
ptr_buffer, list_keys[i]) : 0);
weechat_hashtable_set (info, list_keys[i], str_value);
break;
case WEECHAT_HDATA_STRING:
case WEECHAT_HDATA_SHARED_STRING:
ptr_value = weechat_hdata_string (buflist_hdata_buffer,
+21
View File
@@ -93,6 +93,9 @@
#define API_RETURN_LONG(__long) \
API_FREE_STRINGS; \
return scm_from_long (__long)
#define API_RETURN_LONGLONG(__long) \
API_FREE_STRINGS; \
return scm_from_long_long (__long)
#define API_RETURN_OTHER(__scm) \
API_FREE_STRINGS; \
return __scm
@@ -5148,6 +5151,23 @@ weechat_guile_api_hdata_long (SCM hdata, SCM pointer, SCM name)
API_RETURN_LONG(value);
}
SCM
weechat_guile_api_hdata_longlong (SCM hdata, SCM pointer, SCM name)
{
long long value;
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONGLONG(0));
if (!scm_is_string (hdata) || !scm_is_string (pointer)
|| !scm_is_string (name))
API_WRONG_ARGS(API_RETURN_LONGLONG(0));
value = weechat_hdata_longlong (API_STR2PTR(API_SCM_TO_STRING(hdata)),
API_STR2PTR(API_SCM_TO_STRING(pointer)),
API_SCM_TO_STRING(name));
API_RETURN_LONGLONG(value);
}
SCM
weechat_guile_api_hdata_string (SCM hdata, SCM pointer, SCM name)
{
@@ -5631,6 +5651,7 @@ weechat_guile_api_module_init (void *data)
API_DEF_FUNC(hdata_char, 3);
API_DEF_FUNC(hdata_integer, 3);
API_DEF_FUNC(hdata_long, 3);
API_DEF_FUNC(hdata_longlong, 3);
API_DEF_FUNC(hdata_string, 3);
API_DEF_FUNC(hdata_pointer, 3);
API_DEF_FUNC(hdata_time, 3);
+19
View File
@@ -5066,6 +5066,24 @@ API_FUNC(hdata_long)
API_RETURN_LONG(value);
}
API_FUNC(hdata_longlong)
{
long long value;
API_INIT_FUNC(1, "hdata_longlong", "sss", API_RETURN_LONG(0));
v8::String::Utf8Value hdata(args[0]);
v8::String::Utf8Value pointer(args[1]);
v8::String::Utf8Value name(args[2]);
value = weechat_hdata_longlong (
(struct t_hdata *)API_STR2PTR(*hdata),
API_STR2PTR(*pointer),
*name);
API_RETURN_LONG(value);
}
API_FUNC(hdata_string)
{
const char *result;
@@ -5543,6 +5561,7 @@ WeechatJsV8::loadLibs()
API_DEF_FUNC(hdata_char);
API_DEF_FUNC(hdata_integer);
API_DEF_FUNC(hdata_long);
API_DEF_FUNC(hdata_longlong);
API_DEF_FUNC(hdata_string);
API_DEF_FUNC(hdata_pointer);
API_DEF_FUNC(hdata_time);
+21
View File
@@ -5475,6 +5475,26 @@ API_FUNC(hdata_long)
API_RETURN_LONG(value);
}
API_FUNC(hdata_longlong)
{
const char *hdata, *pointer, *name;
long long value;
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONG(0));
if (lua_gettop (L) < 3)
API_WRONG_ARGS(API_RETURN_LONG(0));
hdata = lua_tostring (L, -3);
pointer = lua_tostring (L, -2);
name = lua_tostring (L, -1);
value = weechat_hdata_longlong (API_STR2PTR(hdata),
API_STR2PTR(pointer),
name);
API_RETURN_LONG(value);
}
API_FUNC(hdata_string)
{
const char *hdata, *pointer, *name, *result;
@@ -5951,6 +5971,7 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
API_DEF_FUNC(hdata_char),
API_DEF_FUNC(hdata_integer),
API_DEF_FUNC(hdata_long),
API_DEF_FUNC(hdata_longlong),
API_DEF_FUNC(hdata_string),
API_DEF_FUNC(hdata_pointer),
API_DEF_FUNC(hdata_time),
+22
View File
@@ -5392,6 +5392,27 @@ API_FUNC(hdata_long)
API_RETURN_LONG(value);
}
API_FUNC(hdata_longlong)
{
char *hdata, *pointer, *name;
long long value;
dXSARGS;
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONG(0));
if (items < 3)
API_WRONG_ARGS(API_RETURN_LONG(0));
hdata = SvPV_nolen (ST (0));
pointer = SvPV_nolen (ST (1));
name = SvPV_nolen (ST (2));
value = weechat_hdata_longlong (API_STR2PTR(hdata),
API_STR2PTR(pointer),
name);
API_RETURN_LONG(value);
}
API_FUNC(hdata_string)
{
char *hdata, *pointer, *name;
@@ -5888,6 +5909,7 @@ weechat_perl_api_init (pTHX)
API_DEF_FUNC(hdata_char);
API_DEF_FUNC(hdata_integer);
API_DEF_FUNC(hdata_long);
API_DEF_FUNC(hdata_longlong);
API_DEF_FUNC(hdata_string);
API_DEF_FUNC(hdata_pointer);
API_DEF_FUNC(hdata_time);
+22
View File
@@ -5544,6 +5544,28 @@ API_FUNC(hdata_long)
API_RETURN_LONG(result);
}
API_FUNC(hdata_longlong)
{
zend_string *z_hdata, *z_pointer, *z_name;
struct t_hdata *hdata;
void *pointer;
char *name;
long long result;
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONG(0));
if (zend_parse_parameters (ZEND_NUM_ARGS(), "SSS", &z_hdata, &z_pointer,
&z_name) == FAILURE)
API_WRONG_ARGS(API_RETURN_LONG(0));
hdata = (struct t_hdata *)API_STR2PTR(ZSTR_VAL(z_hdata));
pointer = (void *)API_STR2PTR(ZSTR_VAL(z_pointer));
name = ZSTR_VAL(z_name);
result = weechat_hdata_longlong (hdata, pointer, (const char *)name);
API_RETURN_LONG(result);
}
API_FUNC(hdata_string)
{
zend_string *z_hdata, *z_pointer, *z_name;
+1
View File
@@ -252,6 +252,7 @@ PHP_FUNCTION(weechat_hdata_search);
PHP_FUNCTION(weechat_hdata_char);
PHP_FUNCTION(weechat_hdata_integer);
PHP_FUNCTION(weechat_hdata_long);
PHP_FUNCTION(weechat_hdata_longlong);
PHP_FUNCTION(weechat_hdata_string);
PHP_FUNCTION(weechat_hdata_pointer);
PHP_FUNCTION(weechat_hdata_time);
+1
View File
@@ -310,6 +310,7 @@ const zend_function_entry weechat_functions[] = {
PHP_FE(weechat_hdata_char, arginfo_weechat_hdata_char)
PHP_FE(weechat_hdata_integer, arginfo_weechat_hdata_integer)
PHP_FE(weechat_hdata_long, arginfo_weechat_hdata_long)
PHP_FE(weechat_hdata_longlong, arginfo_weechat_hdata_longlong)
PHP_FE(weechat_hdata_string, arginfo_weechat_hdata_string)
PHP_FE(weechat_hdata_pointer, arginfo_weechat_hdata_pointer)
PHP_FE(weechat_hdata_time, arginfo_weechat_hdata_time)
+1
View File
@@ -218,6 +218,7 @@ function weechat_hdata_search(string $p0, string $p1, string $p2, array $p3, arr
function weechat_hdata_char(string $p0, string $p1, string $p2): int {}
function weechat_hdata_integer(string $p0, string $p1, string $p2): int {}
function weechat_hdata_long(string $p0, string $p1, string $p2): int {}
function weechat_hdata_longlong(string $p0, string $p1, string $p2): int {}
function weechat_hdata_string(string $p0, string $p1, string $p2): string {}
function weechat_hdata_pointer(string $p0, string $p1, string $p2): string {}
function weechat_hdata_time(string $p0, string $p1, string $p2): int {}
+3 -1
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 59292da89eab98ef1f615c173d9722b9fdafad80 */
* Stub hash: cf4a06ff974bca04f671e75e22f7d16534ca643f */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_register, 0, 7, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0)
@@ -616,6 +616,8 @@ ZEND_END_ARG_INFO()
#define arginfo_weechat_hdata_long arginfo_weechat_config_write_line
#define arginfo_weechat_hdata_longlong arginfo_weechat_config_write_line
#define arginfo_weechat_hdata_string arginfo_weechat_config_search_option
#define arginfo_weechat_hdata_pointer arginfo_weechat_config_search_option
+3 -1
View File
@@ -1,5 +1,5 @@
/* This is a generated file, edit the .stub.php file instead.
* Stub hash: 59292da89eab98ef1f615c173d9722b9fdafad80 */
* Stub hash: cf4a06ff974bca04f671e75e22f7d16534ca643f */
ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_register, 0, 0, 7)
ZEND_ARG_INFO(0, p0)
@@ -451,6 +451,8 @@ ZEND_END_ARG_INFO()
#define arginfo_weechat_hdata_long arginfo_weechat_ngettext
#define arginfo_weechat_hdata_longlong arginfo_weechat_ngettext
#define arginfo_weechat_hdata_string arginfo_weechat_ngettext
#define arginfo_weechat_hdata_pointer arginfo_weechat_ngettext
+1
View File
@@ -932,6 +932,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
new_plugin->hdata_char = &hdata_char;
new_plugin->hdata_integer = &hdata_integer;
new_plugin->hdata_long = &hdata_long;
new_plugin->hdata_longlong = &hdata_longlong;
new_plugin->hdata_string = &hdata_string;
new_plugin->hdata_pointer = &hdata_pointer;
new_plugin->hdata_time = &hdata_time;
+22
View File
@@ -80,6 +80,8 @@
return PyLong_FromLong ((long)__int)
#define API_RETURN_LONG(__long) \
return PyLong_FromLong (__long)
#define API_RETURN_LONGLONG(__longlong) \
return PyLong_FromLongLong (__longlong)
#define API_RETURN_ULONGLONG(__ulonglong) \
return PyLong_FromUnsignedLongLong (__ulonglong)
@@ -5345,6 +5347,25 @@ API_FUNC(hdata_long)
API_RETURN_LONG(value);
}
API_FUNC(hdata_longlong)
{
char *hdata, *pointer, *name;
long long value;
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONGLONG(0));
hdata = NULL;
pointer = NULL;
name = NULL;
if (!PyArg_ParseTuple (args, "sss", &hdata, &pointer, &name))
API_WRONG_ARGS(API_RETURN_LONGLONG(0));
value = weechat_hdata_longlong (API_STR2PTR(hdata),
API_STR2PTR(pointer),
name);
API_RETURN_LONGLONG(value);
}
API_FUNC(hdata_string)
{
char *hdata, *pointer, *name;
@@ -5816,6 +5837,7 @@ PyMethodDef weechat_python_funcs[] =
API_DEF_FUNC(hdata_char),
API_DEF_FUNC(hdata_integer),
API_DEF_FUNC(hdata_long),
API_DEF_FUNC(hdata_longlong),
API_DEF_FUNC(hdata_string),
API_DEF_FUNC(hdata_pointer),
API_DEF_FUNC(hdata_time),
+10
View File
@@ -2701,6 +2701,16 @@ def hdata_long(hdata: str, pointer: str, name: str) -> int:
...
def hdata_longlong(hdata: str, pointer: str, name: str) -> int:
"""`hdata_longlong in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_hdata_longlong>`_
::
# example
weechat.prnt("", "longlongvar = %d" % weechat.hdata_longlong(hdata, pointer, "longlongvar"))
"""
...
def hdata_string(hdata: str, pointer: str, name: str) -> str:
"""`hdata_string in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_hdata_string>`_
::
@@ -175,6 +175,23 @@ relay_weechat_msg_add_long (struct t_relay_weechat_msg *msg, long value)
relay_weechat_msg_add_bytes (msg, str_long, length);
}
/*
* Adds a long long integer to a message.
*/
void
relay_weechat_msg_add_longlong (struct t_relay_weechat_msg *msg,
long long value)
{
char str_longlong[128];
unsigned char length;
snprintf (str_longlong, sizeof (str_longlong), "%lld", value);
length = strlen (str_longlong);
relay_weechat_msg_add_bytes (msg, &length, 1);
relay_weechat_msg_add_bytes (msg, str_longlong, length);
}
/*
* Adds length + string to a message.
*/
@@ -434,6 +451,7 @@ relay_weechat_msg_add_hdata_path (struct t_relay_weechat_msg *msg,
relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_INT);
break;
case WEECHAT_HDATA_LONG:
case WEECHAT_HDATA_LONGLONG:
relay_weechat_msg_add_type (msg, RELAY_WEECHAT_MSG_OBJ_LONG);
break;
case WEECHAT_HDATA_STRING:
@@ -480,6 +498,12 @@ relay_weechat_msg_add_hdata_path (struct t_relay_weechat_msg *msg,
pointer,
name));
break;
case WEECHAT_HDATA_LONGLONG:
relay_weechat_msg_add_longlong (msg,
weechat_hdata_longlong (hdata,
pointer,
name));
break;
case WEECHAT_HDATA_STRING:
case WEECHAT_HDATA_SHARED_STRING:
relay_weechat_msg_add_string (msg,
@@ -694,6 +718,7 @@ relay_weechat_msg_add_hdata (struct t_relay_weechat_msg *msg,
strcat (keys_types, RELAY_WEECHAT_MSG_OBJ_INT);
break;
case WEECHAT_HDATA_LONG:
case WEECHAT_HDATA_LONGLONG:
strcat (keys_types, RELAY_WEECHAT_MSG_OBJ_LONG);
break;
case WEECHAT_HDATA_STRING:
@@ -62,6 +62,8 @@ extern void relay_weechat_msg_add_int (struct t_relay_weechat_msg *msg,
int value);
extern void relay_weechat_msg_add_long (struct t_relay_weechat_msg *msg,
long value);
extern void relay_weechat_msg_add_longlong (struct t_relay_weechat_msg *msg,
long long value);
extern void relay_weechat_msg_add_string (struct t_relay_weechat_msg *msg,
const char *string);
extern void relay_weechat_msg_add_buffer (struct t_relay_weechat_msg *msg,
+27
View File
@@ -6591,6 +6591,32 @@ weechat_ruby_api_hdata_long (VALUE class, VALUE hdata, VALUE pointer,
API_RETURN_LONG(value);
}
static VALUE
weechat_ruby_api_hdata_longlong (VALUE class, VALUE hdata, VALUE pointer,
VALUE name)
{
char *c_hdata, *c_pointer, *c_name;
long long value;
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONG(0));
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (name))
API_WRONG_ARGS(API_RETURN_LONGLONG(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 = weechat_hdata_longlong (API_STR2PTR(c_hdata),
API_STR2PTR(c_pointer),
c_name);
API_RETURN_LONGLONG(value);
}
static VALUE
weechat_ruby_api_hdata_string (VALUE class, VALUE hdata, VALUE pointer,
VALUE name)
@@ -7147,6 +7173,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
API_DEF_FUNC(hdata_char, 3);
API_DEF_FUNC(hdata_integer, 3);
API_DEF_FUNC(hdata_long, 3);
API_DEF_FUNC(hdata_longlong, 3);
API_DEF_FUNC(hdata_string, 3);
API_DEF_FUNC(hdata_pointer, 3);
API_DEF_FUNC(hdata_time, 3);
+21
View File
@@ -5373,6 +5373,26 @@ API_FUNC(hdata_long)
API_RETURN_LONG(result);
}
API_FUNC(hdata_longlong)
{
char *hdata, *pointer, *name;
long long result;
API_INIT_FUNC(1, "hdata_longlong", API_RETURN_LONG(0));
if (objc < 4)
API_WRONG_ARGS(API_RETURN_LONG(0));
hdata = Tcl_GetString (objv[1]);
pointer = Tcl_GetString (objv[2]);
name = Tcl_GetString (objv[3]);
result = weechat_hdata_longlong (API_STR2PTR(hdata),
API_STR2PTR(pointer),
name);
API_RETURN_LONG(result);
}
API_FUNC(hdata_string)
{
char *hdata, *pointer, *name;
@@ -5887,6 +5907,7 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
API_DEF_FUNC(hdata_char);
API_DEF_FUNC(hdata_integer);
API_DEF_FUNC(hdata_long);
API_DEF_FUNC(hdata_longlong);
API_DEF_FUNC(hdata_string);
API_DEF_FUNC(hdata_pointer);
API_DEF_FUNC(hdata_time);
+20 -10
View File
@@ -71,7 +71,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
#define WEECHAT_PLUGIN_API_VERSION "20240304-01"
#define WEECHAT_PLUGIN_API_VERSION "20240307-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -137,15 +137,21 @@ struct timeval;
#define WEECHAT_HASHTABLE_TIME "time"
/* types for hdata */
#define WEECHAT_HDATA_OTHER 0
#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
#define WEECHAT_HDATA_HASHTABLE 7
#define WEECHAT_HDATA_SHARED_STRING 8
enum t_weechat_hdata
{
WEECHAT_HDATA_OTHER = 0,
WEECHAT_HDATA_CHAR,
WEECHAT_HDATA_INTEGER,
WEECHAT_HDATA_LONG,
WEECHAT_HDATA_LONGLONG,
WEECHAT_HDATA_STRING,
WEECHAT_HDATA_POINTER,
WEECHAT_HDATA_TIME,
WEECHAT_HDATA_HASHTABLE,
WEECHAT_HDATA_SHARED_STRING,
/* number of hdata types */
WEECHAT_NUM_HDATA_TYPES,
};
/* flags for hdata lists */
#define WEECHAT_HDATA_LIST_CHECK_POINTERS 1
@@ -1213,6 +1219,8 @@ struct t_weechat_plugin
const char *name);
long (*hdata_long) (struct t_hdata *hdata, void *pointer,
const char *name);
long long (*hdata_longlong) (struct t_hdata *hdata, void *pointer,
const char *name);
const char *(*hdata_string) (struct t_hdata *hdata, void *pointer,
const char *name);
void *(*hdata_pointer) (struct t_hdata *hdata, void *pointer,
@@ -2305,6 +2313,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
(weechat_plugin->hdata_integer)(__hdata, __pointer, __name)
#define weechat_hdata_long(__hdata, __pointer, __name) \
(weechat_plugin->hdata_long)(__hdata, __pointer, __name)
#define weechat_hdata_longlong(__hdata, __pointer, __name) \
(weechat_plugin->hdata_longlong)(__hdata, __pointer, __name)
#define weechat_hdata_string(__hdata, __pointer, __name) \
(weechat_plugin->hdata_string)(__hdata, __pointer, __name)
#define weechat_hdata_pointer(__hdata, __pointer, __name) \