summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Carr <racarr@src.gnome.org>2009-01-29 10:32:25 +0000
committerRobert Carr <racarr@src.gnome.org>2009-01-29 10:32:25 +0000
commit7e95d35b3e0eae081ae0ce34ff9620ebcd2a813d (patch)
tree949f21641e40679b56bbe3d07bfd6299ab5d6410
parent60330a261e75e372c71cdbfbc4e0b31654178328 (diff)
downloadgobject-introspection-7e95d35b3e0eae081ae0ce34ff9620ebcd2a813d.tar.gz
post_filter_varargs_functions should also filter callbacks. Add tests of
* girepository/girparser.c: post_filter_varargs_functions should also filter callbacks. * tests/scanner/foo.h: Add tests of varargs callbacks. svn path=/trunk/; revision=1075
-rw-r--r--ChangeLog6
-rw-r--r--girepository/girparser.c83
-rw-r--r--tests/scanner/foo.h6
3 files changed, 84 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index e3a418c0..dde0bcb3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2009-01-28 Robert Carr <carrr@rpi.edu>
+
+ * girepository/girparser.c: post_filter_varargs_functions
+ should also filter callbacks.
+ * tests/scanner/foo.h: Add tests of varargs callbacks.
+
2009-01-28 Johan Bilien <jobi@via.ecp.fr>
* tests/scanner/annotation-1.0-expected.gir: add missing
diff --git a/girepository/girparser.c b/girepository/girparser.c
index 381c334f..76795366 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -2976,18 +2976,19 @@ cleanup (GMarkupParseContext *context,
}
static GList *
-post_filter_varargs_functions (GList *list)
+post_filter_varargs_functions (GList *list, GList ** varargs_callbacks_out)
{
GList *iter;
-
+ GList *varargs_callbacks = *varargs_callbacks_out;
+
iter = list;
while (iter)
{
GList *link = iter;
GIrNode *node = iter->data;
-
+
iter = iter->next;
-
+
if (node->type == G_IR_NODE_FUNCTION)
{
if (((GIrNodeFunction*)node)->is_varargs)
@@ -2995,7 +2996,60 @@ post_filter_varargs_functions (GList *list)
list = g_list_delete_link (list, link);
}
}
+ if (node->type == G_IR_NODE_CALLBACK)
+ {
+ if (((GIrNodeFunction*)node)->is_varargs)
+ {
+ varargs_callbacks = g_list_append(varargs_callbacks,
+ node);
+ list = g_list_delete_link (list, link);
+ }
+ }
}
+ iter = list;
+ while (iter)
+ {
+ GList *link = iter;
+ GIrNode *node = iter->data;
+
+ iter = iter->next;
+
+ if (node->type == G_IR_NODE_FUNCTION)
+ {
+ GList *param;
+ gboolean function_done = FALSE;
+
+ for (param = ((GIrNodeFunction *)node)->parameters;
+ param;
+ param = param->next)
+ {
+ GIrNodeParam *node = (GIrNodeParam *)param->data;
+
+ if (function_done)
+ break;
+
+ if (node->type->is_interface)
+ {
+ GList *callback;
+ for (callback = varargs_callbacks;
+ callback;
+ callback = callback->next)
+ {
+ if (!strcmp(node->type->interface,
+ ((GIrNode *)varargs_callbacks->data)->name))
+ {
+ list = g_list_delete_link (list, link);
+ function_done = TRUE;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ *varargs_callbacks_out = varargs_callbacks;
+
return list;
}
@@ -3003,37 +3057,44 @@ static void
post_filter (GIrModule *module)
{
GList *iter;
-
- module->entries = post_filter_varargs_functions (module->entries);
+ GList *varargs_callbacks = NULL;
+
+ module->entries = post_filter_varargs_functions (module->entries,
+ &varargs_callbacks);
iter = module->entries;
while (iter)
{
GIrNode *node = iter->data;
-
+
iter = iter->next;
if (node->type == G_IR_NODE_OBJECT ||
node->type == G_IR_NODE_INTERFACE)
{
GIrNodeInterface *iface = (GIrNodeInterface*)node;
- iface->members = post_filter_varargs_functions (iface->members);
+ iface->members = post_filter_varargs_functions (iface->members,
+ &varargs_callbacks);
}
else if (node->type == G_IR_NODE_BOXED)
{
GIrNodeBoxed *boxed = (GIrNodeBoxed*)node;
- boxed->members = post_filter_varargs_functions (boxed->members);
+ boxed->members = post_filter_varargs_functions (boxed->members,
+ &varargs_callbacks);
}
else if (node->type == G_IR_NODE_STRUCT)
{
GIrNodeStruct *iface = (GIrNodeStruct*)node;
- iface->members = post_filter_varargs_functions (iface->members);
+ iface->members = post_filter_varargs_functions (iface->members,
+ &varargs_callbacks);
}
else if (node->type == G_IR_NODE_UNION)
{
GIrNodeUnion *iface = (GIrNodeUnion*)node;
- iface->members = post_filter_varargs_functions (iface->members);
+ iface->members = post_filter_varargs_functions (iface->members,
+ &varargs_callbacks);
}
}
+ g_list_free(varargs_callbacks);
}
/**
diff --git a/tests/scanner/foo.h b/tests/scanner/foo.h
index b3614f35..ee45cf67 100644
--- a/tests/scanner/foo.h
+++ b/tests/scanner/foo.h
@@ -293,6 +293,12 @@ const FooStruct * foo_test_const_struct_retval (void);
void foo_test_const_char_param (const char * param);
void foo_test_const_struct_param (const FooStruct * param);
+typedef void (*FooVarargsCallback) (const char * param, ...);
+void foo_test_varargs_callback (gint i, FooVarargsCallback callback);
+void foo_test_varargs_callback2 (FooVarargsCallback callback);
+void foo_test_varargs_callback3 (FooVarargsCallback callback,
+ FooVarargsCallback callback2);
+
typedef enum {
FOO_ERROR_GOOD,
FOO_ERROR_BAD,