SF.net SVN: geany-plugins:[1263] trunk/geanygendoc/src
colombanw at users.sourceforge.net
colombanw at xxxxx
Wed Apr 21 13:21:52 UTC 2010
Revision: 1263
http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1263&view=rev
Author: colombanw
Date: 2010-04-21 13:21:51 +0000 (Wed, 21 Apr 2010)
Log Message:
-----------
GeanyGenDoc: Move GGD_PTR_ARRAY_FOR() to ggd-utils
Modified Paths:
--------------
trunk/geanygendoc/src/ggd-tag-utils.c
trunk/geanygendoc/src/ggd-utils.h
Modified: trunk/geanygendoc/src/ggd-tag-utils.c
===================================================================
--- trunk/geanygendoc/src/ggd-tag-utils.c 2010-04-20 20:56:12 UTC (rev 1262)
+++ trunk/geanygendoc/src/ggd-tag-utils.c 2010-04-21 13:21:51 UTC (rev 1263)
@@ -23,28 +23,10 @@
#include <geanyplugin.h>
#include <glib.h>
+#include "ggd-utils.h"
#include "ggd-plugin.h" /* to access Geany data/funcs */
-/* a `for` header to walk on an GPtrArray
- * @array: the array to traverse
- * @idx: A guint variable to use as iterator (may be modified)
- * @el: a TMTag pointer to fill with the current element in the array
- *
- * usage:
- *
- * guint i;
- * TMTag *tag;
- *
- * PTR_ARRAY_FOR (ptr_array, i, tag) {
- * // use @tag here...
- * }
- */
-#define PTR_ARRAY_FOR(array, idx, el) \
- for ((idx) = 0; ((el) = g_ptr_array_index ((array), (idx)), \
- (idx) < (array)->len); (idx)++)
-
-
/* Compare function for g_ptr_array_sort() to compare two TMTag by their
* lines */
static gint
@@ -88,7 +70,7 @@
g_return_val_if_fail (tags != NULL, NULL);
- PTR_ARRAY_FOR (tags, i, el) {
+ GGD_PTR_ARRAY_FOR (tags, i, el) {
if (! (el->type & tm_tag_file_t)) {
if (el->atts.entry.line <= line &&
(! tag || el->atts.entry.line > tag->atts.entry.line)) {
@@ -144,7 +126,7 @@
}
/*g_debug ("%s: parent_name = %s", G_STRFUNC, parent_name);
g_debug ("%s: parent_scope = %s", G_STRFUNC, parent_scope);*/
- PTR_ARRAY_FOR (tags, i, el) {
+ GGD_PTR_ARRAY_FOR (tags, i, el) {
if (! (el->type & tm_tag_file_t) &&
(utils_str_equal (el->name, parent_name) &&
utils_str_equal (el->atts.entry.scope, parent_scope))) {
@@ -293,7 +275,7 @@
g_return_val_if_fail (tags != NULL, NULL);
g_return_val_if_fail (name != NULL, NULL);
- PTR_ARRAY_FOR (tags, i, el) {
+ GGD_PTR_ARRAY_FOR (tags, i, el) {
if (! (el->type & tm_tag_file_t) &&
utils_str_equal (el->name, name)) {
tag = el;
@@ -383,7 +365,7 @@
} else {
fake_scope = g_strdup (parent->name);
}
- PTR_ARRAY_FOR (tags, i, el) {
+ GGD_PTR_ARRAY_FOR (tags, i, el) {
if (scope_child_matches (fake_scope, el->atts.entry.scope, depth)) {
children = g_list_append (children, el);
}
Modified: trunk/geanygendoc/src/ggd-utils.h
===================================================================
--- trunk/geanygendoc/src/ggd-utils.h 2010-04-20 20:56:12 UTC (rev 1262)
+++ trunk/geanygendoc/src/ggd-utils.h 2010-04-21 13:21:51 UTC (rev 1263)
@@ -21,6 +21,7 @@
#define H_GGD_UTILS
#include <glib.h>
+#include <geanyplugin.h> /* Geany's utils for some wrappers */
G_BEGIN_DECLS
@@ -38,7 +39,19 @@
GgdPerms perms_req,
GError **error);
+/**
+ * GGD_PTR_ARRAY_FOR:
+ * @ptr_array: A #GPtrArray
+ * @idx: A guint variable to use as the index of the current element in the
+ * array
+ * @item: A pointer to set to the array's current element
+ *
+ * <code>for</code> header to iterate over a #GPtrArray.
+ */
+#define GGD_PTR_ARRAY_FOR(ptr_array, idx, item) \
+ foreach_ptr_array ((item), (idx), (ptr_array))
+
G_END_DECLS
#endif /* guard */
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Plugins-Commits
mailing list