[pygobject/gsoc2009: 80/160] Add release support for generic value



commit 7bf685e087a8803933bb58886795e5518b670f8c
Author: Simon van der Linden <svdlinden src gnome org>
Date:   Wed Jul 29 21:18:08 2009 +0200

    Add release support for generic value

 gi/pygargument.c |   27 +++++++++++++++++++++++++++
 gi/pygiinfo.c    |   41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 67 insertions(+), 1 deletions(-)
---
diff --git a/gi/pygargument.c b/gi/pygargument.c
index 330d1a2..3c607be 100644
--- a/gi/pygargument.c
+++ b/gi/pygargument.c
@@ -1480,6 +1480,33 @@ pygi_g_argument_release(GArgument *arg, GITypeInfo *type_info, GITransfer transf
             info_type = g_base_info_get_type(info);
 
             switch (info_type) {
+                case GI_INFO_TYPE_STRUCT:
+                {
+                    GType type;
+
+                    type = g_registered_type_info_get_g_type((GIRegisteredTypeInfo *)info);
+
+                    if (g_type_is_a(type, G_TYPE_VALUE)) {
+                        GValue *value;
+
+                        value = arg->v_pointer;
+
+                        if ((direction == GI_DIRECTION_IN && transfer != GI_TRANSFER_EVERYTHING)
+                                || (direction == GI_DIRECTION_OUT && transfer == GI_TRANSFER_EVERYTHING)) {
+                            g_value_unset(value);
+                        }
+
+                        if ((direction == GI_DIRECTION_IN && transfer == GI_TRANSFER_NOTHING)
+                                || (direction == GI_DIRECTION_OUT && transfer != GI_TRANSFER_NOTHING)) {
+                            g_slice_free(GValue, value);
+                        }
+                        break;
+                    }
+
+                    /* TODO */
+
+                    break;
+                }
                 case GI_INFO_TYPE_OBJECT:
                 {
                     GObject *object;
diff --git a/gi/pygiinfo.c b/gi/pygiinfo.c
index ebfb6cc..da89ae7 100644
--- a/gi/pygiinfo.c
+++ b/gi/pygiinfo.c
@@ -782,8 +782,47 @@ _wrap_g_function_info_invoke(PyGIBaseInfo *self, PyObject *py_args)
                             containers[containers_pos].v_pointer = g_array_copy(args[i]->v_pointer);
                             break;
                         case GI_TYPE_TAG_INTERFACE:
-                            /* TODO */
+                        {
+                            GIBaseInfo *info;
+                            GIInfoType info_type;
+
+                            info = g_type_info_get_interface(arg_type_infos[i]);
+                            g_assert(info != NULL);
+
+                            info_type = g_base_info_get_type(info);
+
+                            switch (info_type) {
+                                case GI_INFO_TYPE_STRUCT:
+                                {
+                                    GType type;
+
+                                    type = g_registered_type_info_get_g_type((GIRegisteredTypeInfo *)info);
+
+                                    if (g_type_is_a(type, G_TYPE_VALUE)) {
+                                        GValue *value;
+                                        GValue *new_value;
+
+                                        value = args[i]->v_pointer;
+                                        new_value = g_slice_new0(GValue);
+
+                                        g_value_init(new_value, G_VALUE_TYPE(value));
+                                        g_value_copy(value, new_value);
+
+                                        containers[containers_pos].v_pointer = new_value;
+                                        break;
+                                    }
+
+                                    /* TODO */
+
+                                    break;
+                                }
+                                default:
+                                    break;
+                            }
+
+                            g_base_info_unref(info);
                             break;
+                        }
                         case GI_TYPE_TAG_GLIST:
                             containers[containers_pos].v_pointer = g_list_copy(args[i]->v_pointer);
                             break;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]