gjs r59 - trunk/gi



Author: lucasr
Date: Fri Oct 24 15:20:04 2008
New Revision: 59
URL: http://svn.gnome.org/viewvc/gjs?rev=59&view=rev

Log:
Bug 557772 - gjs_invoke_c_function should work with union and boxed as well

    * gi/function.c (gjs_invoke_c_function): check type info to define how
    to retrieve native type from the js object.


Modified:
   trunk/gi/function.c

Modified: trunk/gi/function.c
==============================================================================
--- trunk/gi/function.c	(original)
+++ trunk/gi/function.c	Fri Oct 24 15:20:04 2008
@@ -26,6 +26,8 @@
 #include "function.h"
 #include "arg.h"
 #include "object.h"
+#include "boxed.h"
+#include "union.h"
 #include <gjs/gjs.h>
 
 #include <util/log.h>
@@ -161,7 +163,16 @@
     argv_pos = 0; /* index into argv */
 
     if (is_method) {
-        in_args[0].v_pointer = gjs_g_object_from_object(context, obj);
+        GIBaseInfo *container = g_base_info_get_container((GIBaseInfo *) info);
+        GIInfoType type = g_base_info_get_type(container);
+
+        if (type == GI_INFO_TYPE_STRUCT || type == GI_INFO_TYPE_BOXED) {
+            in_args[0].v_pointer = gjs_g_boxed_from_boxed(context, obj);
+        } else if (type == GI_INFO_TYPE_UNION) {
+            in_args[0].v_pointer = gjs_g_boxed_from_union(context, obj);
+        } else { /* by fallback is always object */
+            in_args[0].v_pointer = gjs_g_object_from_object(context, obj);
+        }
         ++in_args_pos;
     }
 



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