Make foreach_ptr_array() use an integer argument for its
implementation, as this is more useful potentially than a gpointer* argument, and more straightforward. Add foreach_c_array(), foreach_ptr_array() to API. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3997 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
parent
20c66a6816
commit
84f8db733d
@ -5,6 +5,11 @@
|
||||
Add stash_group_add_widget_property() so we can save any widget's
|
||||
read/write properties.
|
||||
Use Stash for ui_prefs.sidebar_page setting.
|
||||
* src/utils.h, src/prefs.c, src/keyfile.c, src/symbols.c:
|
||||
Make foreach_ptr_array() use an integer argument for its
|
||||
implementation, as this is more useful potentially than a gpointer*
|
||||
argument, and more straightforward.
|
||||
Add foreach_c_array(), foreach_ptr_array() to API.
|
||||
|
||||
|
||||
2009-07-19 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
|
||||
|
@ -192,10 +192,10 @@ SettingAction;
|
||||
|
||||
static void settings_action(GKeyFile *config, SettingAction action)
|
||||
{
|
||||
gpointer *ptr;
|
||||
guint i;
|
||||
GeanyPrefGroup *group;
|
||||
|
||||
foreach_ptr_array(group, ptr, keyfile_groups)
|
||||
foreach_ptr_array(group, i, keyfile_groups)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
@ -1139,10 +1139,10 @@ void configuration_init(void)
|
||||
|
||||
void configuration_finalize(void)
|
||||
{
|
||||
gpointer *ptr;
|
||||
guint i;
|
||||
GeanyPrefGroup *group;
|
||||
|
||||
foreach_ptr_array(group, ptr, keyfile_groups)
|
||||
foreach_ptr_array(group, i, keyfile_groups)
|
||||
stash_group_free(group);
|
||||
|
||||
g_ptr_array_free(keyfile_groups, TRUE);
|
||||
|
@ -103,9 +103,9 @@ PrefCallbackAction;
|
||||
static void prefs_action(PrefCallbackAction action)
|
||||
{
|
||||
GeanyPrefGroup *group;
|
||||
gpointer *ptr;
|
||||
guint i;
|
||||
|
||||
foreach_ptr_array(group, ptr, pref_groups)
|
||||
foreach_ptr_array(group, i, pref_groups)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
|
@ -1159,10 +1159,10 @@ static void add_tree_tags(GeanyDocument *doc, const GList *tags)
|
||||
* is not stable, so the order is already lost. */
|
||||
static gint compare_top_level_names(const gchar *a, const gchar *b)
|
||||
{
|
||||
gpointer *ptr;
|
||||
guint i;
|
||||
const gchar *name;
|
||||
|
||||
foreach_ptr_array(name, ptr, top_level_iter_names)
|
||||
foreach_ptr_array(name, i, top_level_iter_names)
|
||||
{
|
||||
if (utils_str_equal(name, a))
|
||||
return -1;
|
||||
|
23
src/utils.h
23
src/utils.h
@ -57,23 +57,30 @@
|
||||
#define utils_strdupa(str) \
|
||||
strcpy(g_alloca(strlen(str) + 1), str)
|
||||
|
||||
/** Iterates all the items in @a array using pointers.
|
||||
* @param item pointer to an item in @a array.
|
||||
* @param array C array to traverse.
|
||||
* @param len Length of the array. */
|
||||
#define foreach_c_array(item, array, len) \
|
||||
for (item = array; item < &array[len]; item++)
|
||||
|
||||
/* @param ptr should be a (gpointer*), needed for implementation. */
|
||||
#define foreach_ptr_array(item, ptr, ptr_array) \
|
||||
for (ptr = ptr_array->pdata, item = *ptr; \
|
||||
ptr < &ptr_array->pdata[ptr_array->len]; ++ptr, item = *ptr)
|
||||
/** Iterates all the pointers in @a ptr_array.
|
||||
* @param item pointer in @a ptr_array.
|
||||
* @param idx @c guint index into @a ptr_array.
|
||||
* @param ptr_array @c GPtrArray to traverse. */
|
||||
#define foreach_ptr_array(item, idx, ptr_array) \
|
||||
for (idx = 0, item = g_ptr_array_index(ptr_array, 0); \
|
||||
idx < ptr_array->len; ++idx, item = g_ptr_array_index(ptr_array, idx))
|
||||
|
||||
/** Iterates all the nodes in @a list.
|
||||
* @param node should be a (GList*).
|
||||
* @param list List to traverse. */
|
||||
* @param node should be a (@c GList*).
|
||||
* @param list @c GList to traverse. */
|
||||
#define foreach_list(node, list) \
|
||||
for (node = list; node != NULL; node = node->next)
|
||||
|
||||
/** Iterates all the nodes in @a list.
|
||||
* @param node should be a (GSList*).
|
||||
* @param list List to traverse. */
|
||||
* @param node should be a (@c GSList*).
|
||||
* @param list @c GSList to traverse. */
|
||||
#define foreach_slist(node, list) \
|
||||
foreach_list(node, list)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user