seed r219 - trunk/libseed



Author: racarr
Date: Sun Nov  9 07:47:46 2008
New Revision: 219
URL: http://svn.gnome.org/viewvc/seed?rev=219&view=rev

Log:
Abstract out GError->Exception logic from function invocation.


Modified:
   trunk/libseed/seed-engine.c
   trunk/libseed/seed-exceptions.c
   trunk/libseed/seed-exceptions.h

Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c	(original)
+++ trunk/libseed/seed-engine.c	Sun Nov  9 07:47:46 2008
@@ -280,28 +280,12 @@
     }
     else
     {
-        const gchar *domain = g_quark_to_string(error->domain);
-        GString *string = g_string_new(domain);
-        int w;
+	seed_make_exception_from_gerror(exception, error);
 
-        *(string->str) = g_unichar_toupper(*(string->str));
-        for (w = 0; w < string->len; w++)
-        {
-            if (*(string->str + w) == '-')
-            {
-                *(string->str + w + 1) =
-                    g_unichar_toupper(*(string->str + w + 1));
-                g_string_erase(string, w, 1);
-            }
-            else if (!strcmp(string->str + w - 1, "Quark"))
-                g_string_truncate(string, w - 1);
-
-        }
-        seed_make_exception(exception, string->str, error->message);
 
-        g_string_free(string, TRUE);
         g_free(in_args);
         g_free(out_args);
+	g_error_free(error);
 
         return JSValueMakeNull(eng->context);
     }
@@ -658,6 +642,7 @@
                          const JSValueRef arguments[], JSValueRef * exception)
 {
     GIBaseInfo *info;
+    GError * e = 0;
     const gchar *namespace;
     const gchar *extension;
     const gchar *version = 0;
@@ -681,7 +666,7 @@
     }
 
     if (!g_irepository_require(g_irepository_get_default(), namespace,
-                               version, 0, NULL))
+                               version, 0, &e))
     {
         gchar *mes;
         if (!version)

Modified: trunk/libseed/seed-exceptions.c
==============================================================================
--- trunk/libseed/seed-exceptions.c	(original)
+++ trunk/libseed/seed-exceptions.c	Sun Nov  9 07:47:46 2008
@@ -55,6 +55,32 @@
     JSStringRelease(js_message);
 }
 
+void seed_make_exception_from_gerror(JSValueRef * exception,
+				     GError * error)
+{
+    const gchar * domain = g_quark_to_string(error->domain);
+    GString *string = g_string_new(domain);
+    int i;
+    
+
+    *(string->str) = g_unichar_toupper(*(string->str));
+    for (i = 0; i < string->len; i++)
+    {
+	if (*(string->str + i) == '-')
+	{
+	    *(string->str + i + 1) =
+		g_unichar_toupper(*(string->str + i + 1));
+	    g_string_erase(string, i, 1);
+	}
+	else if (!strcmp(string->str + i - 1, "Quark"))
+	    g_string_truncate(string, i - 1);
+	
+    }
+    seed_make_exception(exception, string->str, error->message);
+    
+    g_string_free(string, TRUE);
+}
+
 gchar *seed_exception_get_name(JSValueRef e)
 {
     SeedValue name;

Modified: trunk/libseed/seed-exceptions.h
==============================================================================
--- trunk/libseed/seed-exceptions.h	(original)
+++ trunk/libseed/seed-exceptions.h	Sun Nov  9 07:47:46 2008
@@ -26,6 +26,9 @@
 void seed_make_exception(JSValueRef * exception,
 			 const gchar * name, const gchar * message);
 
+void seed_make_exception_from_gerror(JSValueRef * exception,
+				     GError * e);
+
 gchar *seed_exception_get_name(JSValueRef e);
 gchar *seed_exception_get_message(JSValueRef e);
 guint seed_exception_get_line(JSValueRef e);



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