summaryrefslogtreecommitdiff
path: root/girepository/girparser.c
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2010-05-04 16:57:51 +0200
committerTomeu Vizoso <tomeu@sugarlabs.org>2010-05-04 16:58:15 +0200
commitf84400b39b966289d6a98548f606b247b05fb6c1 (patch)
tree4d56b0cdee22ca172da53614ce68db1faa33cd25 /girepository/girparser.c
parent39f2997b9f32598fa2288cdac36f513fcab590b5 (diff)
downloadgobject-introspection-f84400b39b966289d6a98548f606b247b05fb6c1.tar.gz
Add support for GArrays: add g_type_info_get_array_type() and properly scan GArray args
Based on a previous patch by C. Scott Ananian <cscott@litl.com> https://bugzilla.gnome.org/show_bug.cgi?id=581687
Diffstat (limited to 'girepository/girparser.c')
-rw-r--r--girepository/girparser.c48
1 files changed, 33 insertions, 15 deletions
diff --git a/girepository/girparser.c b/girepository/girparser.c
index 5b24604a..125bd171 100644
--- a/girepository/girparser.c
+++ b/girepository/girparser.c
@@ -1717,22 +1717,40 @@ start_type (GMarkupParseContext *context,
typenode->is_pointer = TRUE;
typenode->is_array = TRUE;
- zero = find_attribute ("zero-terminated", attribute_names, attribute_values);
- len = find_attribute ("length", attribute_names, attribute_values);
- size = find_attribute ("fixed-size", attribute_names, attribute_values);
-
- typenode->zero_terminated = !(zero && strcmp (zero, "1") != 0);
- typenode->has_length = len != NULL;
- typenode->length = typenode->has_length ? atoi (len) : -1;
-
- typenode->has_size = size != NULL;
- typenode->size = typenode->has_size ? atoi (size) : -1;
+ name = find_attribute ("name", attribute_names, attribute_values);
+ if (name && strcmp (name, "GLib.Array") == 0) {
+ typenode->array_type = GI_ARRAY_TYPE_ARRAY;
+ } else if (name && strcmp (name, "GLib.ByteArray") == 0) {
+ typenode->array_type = GI_ARRAY_TYPE_BYTE_ARRAY;
+ } else if (name && strcmp (name, "GLib.PtrArray") == 0) {
+ typenode->array_type = GI_ARRAY_TYPE_PTR_ARRAY;
+ } else {
+ typenode->array_type = GI_ARRAY_TYPE_C;
+ }
- if (zero)
- typenode->zero_terminated = strcmp(zero, "1") == 0;
- else
- /* If neither zero-terminated nor length nor fixed-size is given, assume zero-terminated. */
- typenode->zero_terminated = !(typenode->has_length || typenode->has_size);
+ if (typenode->array_type == GI_ARRAY_TYPE_C) {
+ zero = find_attribute ("zero-terminated", attribute_names, attribute_values);
+ len = find_attribute ("length", attribute_names, attribute_values);
+ size = find_attribute ("fixed-size", attribute_names, attribute_values);
+
+ typenode->has_length = len != NULL;
+ typenode->length = typenode->has_length ? atoi (len) : -1;
+
+ typenode->has_size = size != NULL;
+ typenode->size = typenode->has_size ? atoi (size) : -1;
+
+ if (zero)
+ typenode->zero_terminated = strcmp(zero, "1") == 0;
+ else
+ /* If neither zero-terminated nor length nor fixed-size is given, assume zero-terminated. */
+ typenode->zero_terminated = !(typenode->has_length || typenode->has_size);
+ } else {
+ typenode->zero_terminated = FALSE;
+ typenode->has_length = FALSE;
+ typenode->length = -1;
+ typenode->has_size = FALSE;
+ typenode->size = -1;
+ }
}
else
{