Re: libseed-list handling gpointer args/returns



This quick'n'dirty patch actually seems to work. I only tested it with async_queue_push() and _pop().

I uncommented these strange hacks in seed_gi_make_argument:

//        GObject *gobject;
//        if (JSValueIsString (ctx, value))
//          {
          /*
            things like gio.outputstream.write use void pointers
            might need a few other types here..
not very well memory managed. - should be solved by bytearrays when
            introspection implements it.
          */
//          arg->v_string = seed_value_to_string (ctx, value, exception);
//          break;
//        }
/* gtk_statusicon_position_menu / gtk_menu_popup use the userdata for the Gobject */
//        gobject = seed_value_to_object (ctx, value, exception);
//        if (!gobject)
//          return FALSE;

//        arg->v_pointer = gobject;

Are they really needed?
Why put a string or gobject in the value when the tag says void-pointer?

/J

On 07/28/2010 09:02 PM, Jonatan Liljedahl wrote:
many functions in GLib take gpointer as args or return values, for
example GLib.async_queue_push(queue, data).

but this doesn't work currently, it gives errors like "ArgumentError
Unable to make argument 2 for function: async_queue_push."

There is a hack in seed_gi_make_argument() that allows strings to be
passed, but this doesn't seem to work either (async_queue_pop() don't
seem to return a pushed string, but undefined)

it should be possible and perhaps even simple to just wrap seed
objects/values in these cases.

what function does the gvalue-to-seed conversion of the return value?

/Jonatan
_______________________________________________
libseed-list mailing list
libseed-list gnome org
http://mail.gnome.org/mailman/listinfo/libseed-list

diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c
index 4240d36..44cf889 100644
--- a/libseed/seed-engine.c
+++ b/libseed/seed-engine.c
@@ -670,6 +670,10 @@ seed_gobject_method_invoked (JSContextRef ctx,
           // if we have no out args - returns undefined
           // otherwise we return an object, and put the return values into that
           // along with supporting the old object.value way
+          if(g_type_info_is_pointer(type_info)) {
+          	retval_ref = (JSValueRef) retval.v_pointer;
+          	JSValueUnprotect(ctx, retval_ref);
+          } else
           if (n_out_args < 1) 
               retval_ref = JSValueMakeUndefined (ctx);
           else 
diff --git a/libseed/seed-types.c b/libseed/seed-types.c
index 1548909..e4d3960 100644
--- a/libseed/seed-types.c
+++ b/libseed/seed-types.c
@@ -496,24 +496,26 @@ seed_gi_make_argument (JSContextRef ctx,
       
       if (g_type_info_is_pointer (type_info))
       {
-        GObject *gobject;
-        if (JSValueIsString (ctx, value)) 
-          {
+//        GObject *gobject;
+//        if (JSValueIsString (ctx, value)) 
+//          {
           /* 
             things like gio.outputstream.write use void pointers 
             might need a few other types here.. 
             not very well memory managed. - should be solved by bytearrays when
             introspection implements it.  
           */
-          arg->v_string = seed_value_to_string (ctx, value, exception); 
-          break;
-        }
+//          arg->v_string = seed_value_to_string (ctx, value, exception); 
+//          break;
+//        }
         /* gtk_statusicon_position_menu / gtk_menu_popup use the userdata for the Gobject */
-        gobject = seed_value_to_object (ctx, value, exception);
-        if (!gobject)
-          return FALSE;
+//        gobject = seed_value_to_object (ctx, value, exception);
+//        if (!gobject)
+//          return FALSE;
 
-        arg->v_pointer = gobject;
+//        arg->v_pointer = gobject;
+	arg->v_pointer = (gpointer) value;
+	JSValueProtect(ctx, value);
       }
       break;
 


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