seed r186 - trunk/libseed



Author: racarr
Date: Sat Nov  8 03:07:50 2008
New Revision: 186
URL: http://svn.gnome.org/viewvc/seed?rev=186&view=rev

Log:
Some signal rework.


Modified:
   trunk/libseed/seed-closure.h
   trunk/libseed/seed-signals.c
   trunk/libseed/seed-signals.h

Modified: trunk/libseed/seed-closure.h
==============================================================================
--- trunk/libseed/seed-closure.h	(original)
+++ trunk/libseed/seed-closure.h	Sat Nov  8 03:07:50 2008
@@ -24,10 +24,12 @@
 #include "seed-private.h"
 
 typedef struct _SeedClosure {
-    GClosure closure;
-    JSObjectRef function;
-    JSObjectRef object;
-    JSObjectRef this;
+	GClosure closure;
+	JSObjectRef function;
+	JSObjectRef object;
+	JSObjectRef this;
+  
+	JSValueRef user_data;
 } SeedClosure;
 
 typedef struct _SeedNativeClosure {

Modified: trunk/libseed/seed-signals.c
==============================================================================
--- trunk/libseed/seed-signals.c	(original)
+++ trunk/libseed/seed-signals.c	Sat Nov  8 03:07:50 2008
@@ -112,8 +112,9 @@
     SeedClosure *seed_closure = (SeedClosure *) closure;
     JSValueRef *args;
     gint i;
+    
 
-    args = g_newa(JSValueRef, n_param_values);
+    args = g_newa(JSValueRef, n_param_values+1);
 
     for (i = 0; i < n_param_values; i++)
     {
@@ -126,8 +127,10 @@
 
     }
 
+    args[i] = seed_closure->user_data;
+
     JSObjectCallAsFunction(eng->context, seed_closure->function,
-			   seed_closure->this, n_param_values, args, 0);
+			   seed_closure->this, n_param_values+1, args, 0);
 }
 
 static JSValueRef
@@ -146,22 +149,28 @@
 	g_error("Signal constructed with invalid parameters"
 		"in namespace import \n");
 
-    g_assert((argumentCount <= 2));
+    g_assert((argumentCount <= 3));
 
-    closure = g_closure_new_simple(sizeof(SeedClosure), 0);
+    closure = g_closure_new_simple(sizeof(SeedClosure), 
+				   0);
     g_closure_set_marshal(closure, seed_signal_marshal_func);
-    // Losing a ref here. Fix please.
-    // g_closure_add_finalize_notifier(closure, NULL, NULL);
+
     ((SeedClosure *) closure)->function = (JSObjectRef) arguments[0];
     ((SeedClosure *) closure)->object =
 	g_object_get_data(privates->object, "js-ref");
-    if (argumentCount == 2 && !JSValueIsNull(eng->context, arguments[1]))
+    if (argumentCount >= 2 && !JSValueIsNull(eng->context, arguments[1]))
     {
 	JSValueProtect(eng->context, (JSObjectRef) arguments[1]);
 	((SeedClosure *) closure)->this = (JSObjectRef) arguments[1];
     }
     else
 	((SeedClosure *) closure)->this = 0;
+    
+    if (argumentCount == 3)
+    {
+	    ((SeedClosure *) closure)->user_data = arguments[2];
+	    JSValueProtect(eng->context, arguments[2]);
+    }
 
     JSValueProtect(eng->context, (JSObjectRef) arguments[0]);
 

Modified: trunk/libseed/seed-signals.h
==============================================================================
--- trunk/libseed/seed-signals.h	(original)
+++ trunk/libseed/seed-signals.h	Sat Nov  8 03:07:50 2008
@@ -24,10 +24,7 @@
 
 #include "seed-private.h"
 
-void
-
-
-seed_signal_marshal_func(GClosure * closure,
+void seed_signal_marshal_func(GClosure * closure,
 			 GValue * return_value,
 			 guint n_param_values,
 			 const GValue * param_values,



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