seed r194 - trunk/libseed



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

Log:
Exceptions for gobject comparison.


Modified:
   trunk/libseed/seed-closure.h
   trunk/libseed/seed-engine.c
   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 04:12:22 2008
@@ -24,12 +24,12 @@
 #include "seed-private.h"
 
 typedef struct _SeedClosure {
-	GClosure closure;
-	JSObjectRef function;
-	JSObjectRef object;
-	JSObjectRef this;
-  
-	JSValueRef user_data;
+    GClosure closure;
+    JSObjectRef function;
+    JSObjectRef object;
+    JSObjectRef this;
+
+    JSValueRef user_data;
 } SeedClosure;
 
 typedef struct _SeedNativeClosure {

Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c	(original)
+++ trunk/libseed/seed-engine.c	Sat Nov  8 04:12:22 2008
@@ -87,33 +87,33 @@
 
     type = (GType) JSObjectGetPrivate(constructor);
     if (!type)
-			return 0;
+	return 0;
 
     oclass = g_type_class_ref(type);
 
     if (argumentCount > 1)
     {
-	    gchar * mes = g_strdup_printf("Constructor expects"
-					  " 1 argument, got %d", argumentCount);
-	    seed_make_exception(exception, "ArgumentError", mes);
-	    g_free(mes);
-	    
-	    return (JSObjectRef)JSValueMakeNull(eng->context);
+	gchar *mes = g_strdup_printf("Constructor expects"
+				     " 1 argument, got %d", argumentCount);
+	seed_make_exception(exception, "ArgumentError", mes);
+	g_free(mes);
+
+	return (JSObjectRef) JSValueMakeNull(eng->context);
     }
 
     if (argumentCount == 1)
     {
-	    if (!JSValueIsObject(eng->context, arguments[0]))
-		{
-				seed_make_exception(exception, "ArgmuentError",
-									"Constructor expects object as argument");
-                g_type_class_unref(oclass);
-				return (JSObjectRef)JSValueMakeNull(eng->context);
-		}
-		
-		jsprops = JSObjectCopyPropertyNames(eng->context,
-											(JSObjectRef) arguments[0]);
-		nparams = JSPropertyNameArrayGetCount(jsprops);
+	if (!JSValueIsObject(eng->context, arguments[0]))
+	{
+	    seed_make_exception(exception, "ArgmuentError",
+				"Constructor expects object as argument");
+	    g_type_class_unref(oclass);
+	    return (JSObjectRef) JSValueMakeNull(eng->context);
+	}
+
+	jsprops = JSObjectCopyPropertyNames(eng->context,
+					    (JSObjectRef) arguments[0]);
+	nparams = JSPropertyNameArrayGetCount(jsprops);
     }
     i = 0;
 
@@ -192,7 +192,15 @@
 {
     GObject *this, *that;
 
-    g_assert(argumentCount == 1);
+    if (argumentCount != 1)
+    {
+	gchar *mes = g_strdup_printf("GObject equals comparison expected"
+				     " 1 argument, got %d", argumentCount);
+	seed_make_exception(exception, "ArgumentError", mes);
+	g_free(mes);
+
+	return JSValueMakeNull(eng->context);
+    }
 
     this = seed_value_to_object((JSValueRef) this_object, exception);
     that = seed_value_to_object(arguments[0], exception);
@@ -514,9 +522,8 @@
 
     seed_add_signals_to_object(object, gobject);
     if (!base)
-    {
 	return;
-    }
+
     g_assert(g_base_info_get_type(base) == GI_INFO_TYPE_OBJECT);
 
 }

Modified: trunk/libseed/seed-signals.c
==============================================================================
--- trunk/libseed/seed-signals.c	(original)
+++ trunk/libseed/seed-signals.c	Sat Nov  8 04:12:22 2008
@@ -112,9 +112,8 @@
     SeedClosure *seed_closure = (SeedClosure *) closure;
     JSValueRef *args;
     gint i;
-    
 
-    args = g_newa(JSValueRef, n_param_values+1);
+    args = g_newa(JSValueRef, n_param_values + 1);
 
     for (i = 0; i < n_param_values; i++)
     {
@@ -128,12 +127,12 @@
     }
 
     if (seed_closure->user_data)
-      args[i] = seed_closure->user_data;
+	args[i] = seed_closure->user_data;
     else
-      args[i] = JSValueMakeNull(eng->context);
+	args[i] = JSValueMakeNull(eng->context);
 
     JSObjectCallAsFunction(eng->context, seed_closure->function,
-			   seed_closure->this, n_param_values+1, args, 0);
+			   seed_closure->this, n_param_values + 1, args, 0);
 }
 
 static JSValueRef
@@ -154,8 +153,7 @@
 
     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);
 
     ((SeedClosure *) closure)->function = (JSObjectRef) arguments[0];
@@ -168,11 +166,11 @@
     }
     else
 	((SeedClosure *) closure)->this = 0;
-    
+
     if (argumentCount == 3)
     {
-	    ((SeedClosure *) closure)->user_data = arguments[2];
-	    JSValueProtect(eng->context, arguments[2]);
+	((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 04:12:22 2008
@@ -25,10 +25,10 @@
 #include "seed-private.h"
 
 void seed_signal_marshal_func(GClosure * closure,
-			 GValue * return_value,
-			 guint n_param_values,
-			 const GValue * param_values,
-			 gpointer invocation_hint, gpointer marshall_data);
+			      GValue * return_value,
+			      guint n_param_values,
+			      const GValue * param_values,
+			      gpointer invocation_hint, gpointer marshall_data);
 
 void seed_add_signals_to_object(JSObjectRef object_ref, GObject * obj);
 JSClassDefinition *seed_get_signal_class(void);



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