mirror of
https://github.com/weechat/weechat.git
synced 2026-06-27 05:16:38 +02:00
api: add arraylist functions
New functions: - arraylist_new - arraylist_size - arraylist_get - arraylist_search - arraylist_insert - arraylist_add - arraylist_remove - arraylist_clear - arraylist_free
This commit is contained in:
@@ -689,6 +689,16 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
|
||||
new_plugin->list_remove_all = &weelist_remove_all;
|
||||
new_plugin->list_free = &weelist_free;
|
||||
|
||||
new_plugin->arraylist_new = arraylist_new;
|
||||
new_plugin->arraylist_size = arraylist_size;
|
||||
new_plugin->arraylist_get = arraylist_get;
|
||||
new_plugin->arraylist_search = arraylist_search;
|
||||
new_plugin->arraylist_insert = arraylist_insert;
|
||||
new_plugin->arraylist_add = arraylist_add;
|
||||
new_plugin->arraylist_remove = arraylist_remove;
|
||||
new_plugin->arraylist_clear = arraylist_clear;
|
||||
new_plugin->arraylist_free = arraylist_free;
|
||||
|
||||
new_plugin->hashtable_new = &hashtable_new;
|
||||
new_plugin->hashtable_set_with_size = &hashtable_set_with_size;
|
||||
new_plugin->hashtable_set = &hashtable_set;
|
||||
|
||||
@@ -44,6 +44,7 @@ struct t_gui_completion;
|
||||
struct t_infolist;
|
||||
struct t_infolist_item;
|
||||
struct t_weelist;
|
||||
struct t_arraylist;
|
||||
struct t_hashtable;
|
||||
struct t_hdata;
|
||||
struct timeval;
|
||||
@@ -58,7 +59,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 "20170303-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20170312-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@@ -391,6 +392,30 @@ struct t_weechat_plugin
|
||||
void (*list_remove_all) (struct t_weelist *weelist);
|
||||
void (*list_free) (struct t_weelist *weelist);
|
||||
|
||||
/* array lists */
|
||||
struct t_arraylist *(*arraylist_new) (int initial_size,
|
||||
int sorted,
|
||||
int allow_duplicates,
|
||||
int (*callback_cmp)(void *data,
|
||||
struct t_arraylist *arraylist,
|
||||
void *pointer1,
|
||||
void *pointer2),
|
||||
void *callback_cmp_data,
|
||||
void (*callback_free)(void *data,
|
||||
struct t_arraylist *arraylist,
|
||||
void *pointer),
|
||||
void *callback_free_data);
|
||||
int (*arraylist_size) (struct t_arraylist *arraylist);
|
||||
void *(*arraylist_get) (struct t_arraylist *arraylist, int index);
|
||||
void *(*arraylist_search) (struct t_arraylist *arraylist, void *pointer,
|
||||
int *index, int *index_insert);
|
||||
int (*arraylist_insert) (struct t_arraylist *arraylist, int index,
|
||||
void *pointer);
|
||||
int (*arraylist_add) (struct t_arraylist *arraylist, void *pointer);
|
||||
int (*arraylist_remove) (struct t_arraylist *arraylist, int index);
|
||||
int (*arraylist_clear) (struct t_arraylist *arraylist);
|
||||
void (*arraylist_free) (struct t_arraylist *arraylist);
|
||||
|
||||
/* hash tables */
|
||||
struct t_hashtable *(*hashtable_new) (int size,
|
||||
const char *type_keys,
|
||||
@@ -1292,6 +1317,34 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
#define weechat_list_free(__list) \
|
||||
(weechat_plugin->list_free)(__list)
|
||||
|
||||
/* array lists */
|
||||
#define weechat_arraylist_new(__initial_size, __sorted, \
|
||||
__allow_duplicates, __callback_cmp, \
|
||||
__callback_cmp_data, __callback_free, \
|
||||
__callback_free_data) \
|
||||
(weechat_plugin->arraylist_new)(__initial_size, __sorted, \
|
||||
__allow_duplicates, __callback_cmp, \
|
||||
__callback_cmp_data, __callback_free, \
|
||||
__callback_free_data)
|
||||
#define weechat_arraylist_size(__arraylist) \
|
||||
(weechat_plugin->arraylist_size)(__arraylist)
|
||||
#define weechat_arraylist_get(__arraylist, __index) \
|
||||
(weechat_plugin->arraylist_get)(__arraylist, __index)
|
||||
#define weechat_arraylist_search(__arraylist, __pointer, __index, \
|
||||
__index_insert) \
|
||||
(weechat_plugin->arraylist_search)(__arraylist, __pointer, __index, \
|
||||
__index_insert)
|
||||
#define weechat_arraylist_insert(__arraylist, __index, __pointer) \
|
||||
(weechat_plugin->arraylist_insert)(__arraylist, __index, __pointer)
|
||||
#define weechat_arraylist_add(__arraylist, __pointer) \
|
||||
(weechat_plugin->arraylist_add)(__arraylist, __pointer)
|
||||
#define weechat_arraylist_remove(__arraylist, __index) \
|
||||
(weechat_plugin->arraylist_remove)(__arraylist, __index)
|
||||
#define weechat_arraylist_clear(__arraylist) \
|
||||
(weechat_plugin->arraylist_clear)(__arraylist)
|
||||
#define weechat_arraylist_free(__arraylist) \
|
||||
(weechat_plugin->arraylist_free)(__arraylist)
|
||||
|
||||
/* hash tables */
|
||||
#define weechat_hashtable_new(__size, __type_keys, __type_values, \
|
||||
__callback_hash_key, __callback_keycmp) \
|
||||
|
||||
Reference in New Issue
Block a user