SF.net SVN: geany:[3997] trunk
ntrel at users.sourceforge.net
ntrel at xxxxx
Mon Jul 20 12:25:32 UTC 2009
Revision: 3997
http://geany.svn.sourceforge.net/geany/?rev=3997&view=rev
Author: ntrel
Date: 2009-07-20 12:25:24 +0000 (Mon, 20 Jul 2009)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/keyfile.c
trunk/src/prefs.c
trunk/src/symbols.c
trunk/src/utils.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-07-20 12:00:06 UTC (rev 3996)
+++ trunk/ChangeLog 2009-07-20 12:25:24 UTC (rev 3997)
@@ -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>
Modified: trunk/src/keyfile.c
===================================================================
--- trunk/src/keyfile.c 2009-07-20 12:00:06 UTC (rev 3996)
+++ trunk/src/keyfile.c 2009-07-20 12:25:24 UTC (rev 3997)
@@ -192,10 +192,10 @@
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_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);
Modified: trunk/src/prefs.c
===================================================================
--- trunk/src/prefs.c 2009-07-20 12:00:06 UTC (rev 3996)
+++ trunk/src/prefs.c 2009-07-20 12:25:24 UTC (rev 3997)
@@ -103,9 +103,9 @@
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)
{
Modified: trunk/src/symbols.c
===================================================================
--- trunk/src/symbols.c 2009-07-20 12:00:06 UTC (rev 3996)
+++ trunk/src/symbols.c 2009-07-20 12:25:24 UTC (rev 3997)
@@ -1159,10 +1159,10 @@
* 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;
Modified: trunk/src/utils.h
===================================================================
--- trunk/src/utils.h 2009-07-20 12:00:06 UTC (rev 3996)
+++ trunk/src/utils.h 2009-07-20 12:25:24 UTC (rev 3997)
@@ -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)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list