seed r214 - in trunk: libseed tests



Author: racarr
Date: Sat Nov  8 12:13:39 2008
New Revision: 214
URL: http://svn.gnome.org/viewvc/seed?rev=214&view=rev

Log:
Support out arguments. Add a test for out arguments.


Added:
   trunk/tests/out-test.js   (contents, props changed)
Modified:
   trunk/libseed/seed-engine.c
   trunk/tests/Makefile.am

Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c	(original)
+++ trunk/libseed/seed-engine.c	Sat Nov  8 12:13:39 2008
@@ -224,6 +224,7 @@
     GArgument retval;
     GArgument *in_args;
     GArgument *out_args;
+    GArgument * out_values;
     gint n_args, n_in_args, n_out_args, i;
     GIArgInfo *arg_info;
     GITypeInfo *type_info;
@@ -244,10 +245,12 @@
 
     in_args = g_new0(GArgument, n_args + 1);
     out_args = g_new0(GArgument, n_args + 1);
+    out_values = g_new0(GArgument, n_args + 1);
     n_in_args = n_out_args = 0;
 
     if (instance_method)
         in_args[n_in_args++].v_pointer = object;
+
     for (i = 0; (i < (n_args)); i++)
     {
         arg_info = g_callable_info_get_arg((GICallableInfo *) info, i);
@@ -281,14 +284,15 @@
             }
             if (dir == GI_DIRECTION_INOUT)
             {
-                n_out_args++;
+                GArgument * out_value = &out_values[n_out_args];
+                out_args[n_out_args++].v_pointer = out_value;
             }
 
         }
         else if (dir == GI_DIRECTION_OUT)
         {
-            printf("%p\n",(gpointer)&out_args[i]);
-            n_out_args++;
+            GArgument * out_value = &out_values[n_out_args];
+            out_args[n_out_args++].v_pointer = out_value;
         }
 
         g_base_info_unref((GIBaseInfo *) type_info);
@@ -334,28 +338,39 @@
 
         return JSValueMakeNull(eng->context);
     }
+    
     if (n_out_args != 0)
     {
-        for (i = 0; i < n_args; i++)
+        for (i = 0; (i < n_args); i++)
         {
+            JSValueRef jsout_val;
             arg_info = g_callable_info_get_arg((GICallableInfo *) info, i);
             dir = g_arg_info_get_direction(arg_info);
-            if (dir == GI_DIRECTION_OUT)
+            if (dir == GI_DIRECTION_IN)
             {
-                type_info = g_arg_info_get_type(arg_info);
-                if (!JSValueIsNull(eng->context, arguments[i]) && 
-                    JSValueIsObject(eng->context, arguments[i]))
-                {
-                    JSValueRef out_val = seed_gi_argument_make_js(&out_args[i], type_info, exception);
-                    seed_value_set_property((JSObjectRef)arguments[i], "value", out_val);
-                }
+                g_base_info_unref((GIBaseInfo*)arg_info);
+                continue;
             }
-
+            type_info = g_arg_info_get_type(arg_info);
+            jsout_val = seed_gi_argument_make_js(&out_values[i], 
+                                                 type_info, 
+                                                 exception);
+            if (!JSValueIsNull(eng->context, arguments[i]) &&
+                JSValueIsObject(eng->context, arguments[i]))
+            {
+                seed_value_set_property((JSObjectRef)arguments[i], 
+                                        "value",
+                                        jsout_val);
+            }
+            
+            g_base_info_unref((GIBaseInfo *)arg_info);
+            g_base_info_unref((GIBaseInfo *)type_info);
         }
     }
 
     g_free(in_args);
     g_free(out_args);
+    g_free(out_values);
     return retval_ref;
 }
 

Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am	(original)
+++ trunk/tests/Makefile.am	Sat Nov  8 12:13:39 2008
@@ -4,6 +4,7 @@
     constructor-args.js \
     signal-this.js \
     signal-userdata.js \
+    out-test.js \
     signal-expects.js \
     gtype.js \
     json.js \

Added: trunk/tests/out-test.js
==============================================================================
--- (empty file)
+++ trunk/tests/out-test.js	Sat Nov  8 12:13:39 2008
@@ -0,0 +1,13 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:5 100
+// STDERR:
+Seed.import_namespace("Gtk");
+Gtk.init(null, null)
+w = new Gtk.Window({width_request: 5, height_request: 100});
+o1 = new Object();
+o2 = new Object();
+
+w.get_size_request(o1, o2);
+Seed.print(o1.value + " " +  o2.value);



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