seed r180 - in trunk: extensions libseed tests



Author: racarr
Date: Sat Nov  8 01:27:33 2008
New Revision: 180
URL: http://svn.gnome.org/viewvc/seed?rev=180&view=rev

Log:
Add GError test.


Added:
   trunk/tests/gerror.js   (contents, props changed)
Modified:
   trunk/extensions/Gio.js
   trunk/libseed/seed-engine.c

Modified: trunk/extensions/Gio.js
==============================================================================
--- trunk/extensions/Gio.js	(original)
+++ trunk/extensions/Gio.js	Sat Nov  8 01:27:33 2008
@@ -12,11 +12,6 @@
     Gio.simple_write = function(file, name)
     {
 	    var file = Gio.file_new_for_path(file);
-	    var info = file.query_info("standard::type");
-	    var type = info.get_file_type();
-	    if ((type != Gio.FileType.regular) 
-		&& (type != Gio.FileType.symbolic_link))
-		return;
 	    var fstream = file.replace();
 	    var dstream = Gio.DataOutputStream._new(fstream);
 		    
@@ -27,14 +22,11 @@
     Gio.simple_read = function(name)
     {
 	    var file = Gio.file_new_for_path(name);
-	    var info = file.query_info("standard::type");
-	    var type = info.get_file_type();
-	    if ((type != Gio.FileType.regular) 
-		&& (type != Gio.FileType.symbolic_link))
-		return null;
+
 	    var fstream = file.read();
 	    var dstream = Gio.DataInputStream._new(fstream);
 	    var line = dstream.read_until("", 0);
+
 	    fstream.close();
 	    return line;
     }

Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c	(original)
+++ trunk/libseed/seed-engine.c	Sat Nov  8 01:27:33 2008
@@ -268,28 +268,31 @@
 			    seed_gi_argument_make_js(&retval, type_info, exception);
 		g_base_info_unref((GIBaseInfo *) type_info);
 	} else {
-			GString * string = g_string_new(g_quark_to_string(error->domain));
-		int w;
-		
-		*(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);
+			const gchar * domain = g_quark_to_string(error->domain);
+			GString * string = g_string_new(domain);
+			int w;
+			
+			*(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);
 
-		}
-		seed_make_exception(exception, string->str,
-							error->message);
-		g_free(in_args);
-		g_free(out_args);
-		
-		return JSValueMakeNull(eng->context);
+			g_string_free(string, TRUE);
+			g_free(in_args);
+			g_free(out_args);
+			
+			return JSValueMakeNull(eng->context);
 	}
 
 	g_free(in_args);

Added: trunk/tests/gerror.js
==============================================================================
--- (empty file)
+++ trunk/tests/gerror.js	Sat Nov  8 01:27:33 2008
@@ -0,0 +1,18 @@
+#!/usr/local/bin/seed
+// Returns: 0
+// STDIN:
+// STDOUT:GIoError Error opening file .* Is a directory
+// STDERR:
+// Returns: 0
+// STDIN:
+// STDOUT:
+// STDERR:
+Seed.import_namespace("Gio")
+try
+{
+	Gio.simple_write(".", "test");
+}
+catch (e)
+{
+	Seed.print(e.name+" "+e.message);
+}



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