seed r184 - trunk/libseed



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

Log:
Change indentation to 4 spaces.


Modified:
   trunk/libseed/indent.sh
   trunk/libseed/seed-builtins.c
   trunk/libseed/seed-closure.c
   trunk/libseed/seed-closure.h
   trunk/libseed/seed-engine.c
   trunk/libseed/seed-engine.h
   trunk/libseed/seed-gtype.c
   trunk/libseed/seed-private.h
   trunk/libseed/seed-signals.c
   trunk/libseed/seed-structs.c
   trunk/libseed/seed-types.c

Modified: trunk/libseed/indent.sh
==============================================================================
--- trunk/libseed/indent.sh	(original)
+++ trunk/libseed/indent.sh	Sat Nov  8 01:42:29 2008
@@ -1,5 +1,5 @@
 indent     -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -nce -ci4 \
-            -cli0 -d0 -di1 -nfc1 -i8 -ip0 -l80 -lp -npcs -nprs -npsl -sai \
+            -cli0 -d0 -di1 -nfc1 -i4 -ip0 -l80 -lp -npcs -nprs -npsl -sai \
             -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -ts8 -il1 -bl -bli0 *.c *.h
 
 

Modified: trunk/libseed/seed-builtins.c
==============================================================================
--- trunk/libseed/seed-builtins.c	(original)
+++ trunk/libseed/seed-builtins.c	Sat Nov  8 01:42:29 2008
@@ -34,52 +34,51 @@
 	     size_t argumentCount,
 	     const JSValueRef arguments[], JSValueRef * exception)
 {
-	JSStringRef file_contents, file_name;
-	const gchar *import_file;
-	gchar *buffer, *walk;
-
-	if (argumentCount != 1)
-	{
-		gchar *mes =
-		    g_strdup_printf("Seed.include expected 1 argument, "
-				    "got %d", argumentCount);
-		seed_make_exception(exception, "ArgumentError", mes);
-		g_free(mes);
-		return JSValueMakeNull(ctx);
-	}
-	import_file = seed_value_to_string(arguments[0], exception);
-
-	g_file_get_contents(import_file, &buffer, 0, 0);
-
-	if (!buffer)
-	{
-		gchar *mes =
-		    g_strdup_printf("File not found: %s.\n", import_file);
-		seed_make_exception(exception, "FileNotFound", mes);
-		g_free(mes);
-		return JSValueMakeNull(ctx);
-	}
-
-	walk = buffer;
-
-	if (*walk == '#')
-	{
-		while (*walk != '\n')
-			walk++;
-		walk++;
-	}
-
-	walk = strdup(walk);
-	g_free(buffer);
-
-	file_contents = JSStringCreateWithUTF8CString(walk);
-	file_name = JSStringCreateWithUTF8CString(import_file);
-	JSEvaluateScript(ctx, file_contents, NULL, file_name, 0, NULL);
+    JSStringRef file_contents, file_name;
+    const gchar *import_file;
+    gchar *buffer, *walk;
+
+    if (argumentCount != 1)
+    {
+	gchar *mes =
+	    g_strdup_printf("Seed.include expected 1 argument, "
+			    "got %d", argumentCount);
+	seed_make_exception(exception, "ArgumentError", mes);
+	g_free(mes);
+	return JSValueMakeNull(ctx);
+    }
+    import_file = seed_value_to_string(arguments[0], exception);
 
-	JSStringRelease(file_contents);
-	JSStringRelease(file_name);
+    g_file_get_contents(import_file, &buffer, 0, 0);
 
+    if (!buffer)
+    {
+	gchar *mes = g_strdup_printf("File not found: %s.\n", import_file);
+	seed_make_exception(exception, "FileNotFound", mes);
+	g_free(mes);
 	return JSValueMakeNull(ctx);
+    }
+
+    walk = buffer;
+
+    if (*walk == '#')
+    {
+	while (*walk != '\n')
+	    walk++;
+	walk++;
+    }
+
+    walk = strdup(walk);
+    g_free(buffer);
+
+    file_contents = JSStringCreateWithUTF8CString(walk);
+    file_name = JSStringCreateWithUTF8CString(import_file);
+    JSEvaluateScript(ctx, file_contents, NULL, file_name, 0, NULL);
+
+    JSStringRelease(file_contents);
+    JSStringRelease(file_name);
+
+    return JSValueMakeNull(ctx);
 }
 
 JSValueRef
@@ -89,21 +88,21 @@
 	   size_t argumentCount,
 	   const JSValueRef arguments[], JSValueRef * exception)
 {
-	if (argumentCount != 1)
-	{
-		gchar *mes =
-		    g_strdup_printf("Seed.print Expected 1 argument," " got %d",
-				    argumentCount);
-		seed_make_exception(exception, "ArgumentError", mes);
-		g_free(mes);
-		return JSValueMakeNull(ctx);
-	}
-
-	gchar *buf = seed_value_to_string(arguments[0], exception);
-	printf("%s\n", buf);
-	g_free(buf);
-
+    if (argumentCount != 1)
+    {
+	gchar *mes =
+	    g_strdup_printf("Seed.print Expected 1 argument," " got %d",
+			    argumentCount);
+	seed_make_exception(exception, "ArgumentError", mes);
+	g_free(mes);
 	return JSValueMakeNull(ctx);
+    }
+
+    gchar *buf = seed_value_to_string(arguments[0], exception);
+    printf("%s\n", buf);
+    g_free(buf);
+
+    return JSValueMakeNull(ctx);
 }
 
 JSValueRef
@@ -113,40 +112,40 @@
 	      size_t argumentCount,
 	      const JSValueRef arguments[], JSValueRef * exception)
 {
-	// TODO: Should add an interface to rl_bind_key
-	// Perhaps Seed.readline_bind('a', function)
-	// Then automagically do function stuff and make it happen!
-
-	JSValueRef valstr = 0;
-	gchar *str = 0;
-	gchar *buf;
-
-	if (argumentCount != 1)
-	{
-		gchar *mes =
-		    g_strdup_printf("Seed.readline Expected 1 argument, "
-				    "got %d", argumentCount);
-		seed_make_exception(exception, "ArgumentError", mes);
-		g_free(mes);
-		return JSValueMakeNull(ctx);
-	}
-
-	buf = seed_value_to_string(arguments[0], exception);
-
-	str = readline(buf);
-	if (str && *str)
-	{
-		add_history(str);
-		valstr = seed_value_from_string(str, exception);
-		g_free(str);
-	}
+    // TODO: Should add an interface to rl_bind_key
+    // Perhaps Seed.readline_bind('a', function)
+    // Then automagically do function stuff and make it happen!
+
+    JSValueRef valstr = 0;
+    gchar *str = 0;
+    gchar *buf;
+
+    if (argumentCount != 1)
+    {
+	gchar *mes =
+	    g_strdup_printf("Seed.readline Expected 1 argument, "
+			    "got %d", argumentCount);
+	seed_make_exception(exception, "ArgumentError", mes);
+	g_free(mes);
+	return JSValueMakeNull(ctx);
+    }
+
+    buf = seed_value_to_string(arguments[0], exception);
 
-	g_free(buf);
+    str = readline(buf);
+    if (str && *str)
+    {
+	add_history(str);
+	valstr = seed_value_from_string(str, exception);
+	g_free(str);
+    }
 
-	if (valstr == 0)
-		valstr = JSValueMakeNull(ctx);
+    g_free(buf);
 
-	return valstr;
+    if (valstr == 0)
+	valstr = JSValueMakeNull(ctx);
+
+    return valstr;
 }
 
 JSValueRef
@@ -156,43 +155,43 @@
 	       size_t argumentCount,
 	       const JSValueRef arguments[], JSValueRef * exception)
 {
-	GType type;
+    GType type;
 
-	if (argumentCount != 1)
-	{
-		gchar *mes =
-		    g_strdup_printf("Seed.prototype Expected 1 argument, "
-				    "got %d", argumentCount);
-		seed_make_exception(exception, "ArgumentError", mes);
-		g_free(mes);
-		return JSValueMakeNull(eng->context);
-	}
-	if (!JSValueIsObject(eng->context, arguments[0]))
-		return JSValueMakeNull(eng->context);
+    if (argumentCount != 1)
+    {
+	gchar *mes =
+	    g_strdup_printf("Seed.prototype Expected 1 argument, "
+			    "got %d", argumentCount);
+	seed_make_exception(exception, "ArgumentError", mes);
+	g_free(mes);
+	return JSValueMakeNull(eng->context);
+    }
+    if (!JSValueIsObject(eng->context, arguments[0]))
+	return JSValueMakeNull(eng->context);
 
-	type = (GType) JSObjectGetPrivate((JSObjectRef) arguments[0]);
+    type = (GType) JSObjectGetPrivate((JSObjectRef) arguments[0]);
 
-	return seed_gobject_get_prototype_for_gtype(type);
+    return seed_gobject_get_prototype_for_gtype(type);
 }
 
 const gchar *seed_g_type_name_to_string(GITypeInfo * type)
 {
-	GITypeTag type_tag = g_type_info_get_tag(type);
+    GITypeTag type_tag = g_type_info_get_tag(type);
 
-	const gchar *type_name;
+    const gchar *type_name;
 
-	if (type_tag == GI_TYPE_TAG_INTERFACE)
-	{
-		GIBaseInfo *interface = g_type_info_get_interface(type);
-		type_name = g_base_info_get_name(interface);
-		g_base_info_unref(interface);
-	}
-	else
-	{
-		type_name = g_type_tag_to_string(type_tag);
-	}
+    if (type_tag == GI_TYPE_TAG_INTERFACE)
+    {
+	GIBaseInfo *interface = g_type_info_get_interface(type);
+	type_name = g_base_info_get_name(interface);
+	g_base_info_unref(interface);
+    }
+    else
+    {
+	type_name = g_type_tag_to_string(type_tag);
+    }
 
-	return type_name;
+    return type_name;
 }
 
 JSValueRef
@@ -202,63 +201,60 @@
 		size_t argumentCount,
 		const JSValueRef arguments[], JSValueRef * exception)
 {
-	// TODO: LEAKY!
+    // TODO: LEAKY!
+
+    GICallableInfo *info;
+    JSObjectRef data_obj, args_obj;
+    gint i;
+
+    if (argumentCount != 1)
+    {
+	gchar *mes =
+	    g_strdup_printf("Seed.introspection Expected 1 argument, "
+			    "got %d", argumentCount);
+	seed_make_exception(exception, "ArgumentError", mes);
+	g_free(mes);
+	return JSValueMakeNull(ctx);
+    }
+
+    if (!JSValueIsObject(ctx, arguments[0]))
+	return JSValueMakeNull(ctx);
+    if (!JSValueIsObjectOfClass(ctx, arguments[0], gobject_method_class))
+	return JSValueMakeNull(ctx);
 
-	GICallableInfo *info;
-	JSObjectRef data_obj, args_obj;
-	gint i;
-
-	if (argumentCount != 1)
-	{
-		gchar *mes =
-		    g_strdup_printf("Seed.introspection Expected 1 argument, "
-				    "got %d", argumentCount);
-		seed_make_exception(exception, "ArgumentError", mes);
-		g_free(mes);
-		return JSValueMakeNull(ctx);
-	}
-
-	if (!JSValueIsObject(ctx, arguments[0]))
-		return JSValueMakeNull(ctx);
-	if (!JSValueIsObjectOfClass(ctx, arguments[0], gobject_method_class))
-		return JSValueMakeNull(ctx);
-
-	info =
-	    (GICallableInfo *) JSObjectGetPrivate((JSObjectRef) arguments[0]);
-	data_obj = JSObjectMake(ctx, NULL, NULL);
-
-	seed_value_set_property(data_obj, "name", (JSValueRef)
-				seed_value_from_string(g_base_info_get_name
-						       ((GIBaseInfo *) info),
-						       exception));
-
-	seed_value_set_property(data_obj, "return_type",
-				seed_value_from_string
-				(seed_g_type_name_to_string
-				 (g_callable_info_get_return_type(info)),
-				 exception));
-
-	args_obj = JSObjectMake(eng->context, NULL, NULL);
-
-	seed_value_set_property(data_obj, "args", args_obj);
-
-	for (i = 0; i < g_callable_info_get_n_args(info); ++i)
-	{
-		JSObjectRef argument = JSObjectMake(ctx, NULL, NULL);
-
-		const gchar *arg_name =
-		    seed_g_type_name_to_string(g_arg_info_get_type
-					       (g_callable_info_get_arg
-						(info, i)));
-
-		seed_value_set_property(argument, "type",
-					seed_value_from_string(arg_name,
-							       exception));
+    info = (GICallableInfo *) JSObjectGetPrivate((JSObjectRef) arguments[0]);
+    data_obj = JSObjectMake(ctx, NULL, NULL);
 
-		JSObjectSetPropertyAtIndex(ctx, args_obj, i, argument, NULL);
-	}
+    seed_value_set_property(data_obj, "name", (JSValueRef)
+			    seed_value_from_string(g_base_info_get_name
+						   ((GIBaseInfo *) info),
+						   exception));
 
-	return data_obj;
+    seed_value_set_property(data_obj, "return_type",
+			    seed_value_from_string
+			    (seed_g_type_name_to_string
+			     (g_callable_info_get_return_type(info)),
+			     exception));
+
+    args_obj = JSObjectMake(eng->context, NULL, NULL);
+
+    seed_value_set_property(data_obj, "args", args_obj);
+
+    for (i = 0; i < g_callable_info_get_n_args(info); ++i)
+    {
+	JSObjectRef argument = JSObjectMake(ctx, NULL, NULL);
+
+	const gchar *arg_name =
+	    seed_g_type_name_to_string(g_arg_info_get_type
+				       (g_callable_info_get_arg(info, i)));
+
+	seed_value_set_property(argument, "type",
+				seed_value_from_string(arg_name, exception));
+
+	JSObjectSetPropertyAtIndex(ctx, args_obj, i, argument, NULL);
+    }
+
+    return data_obj;
 }
 
 JSValueRef
@@ -268,24 +264,24 @@
 		  size_t argumentCount,
 		  const JSValueRef arguments[], JSValueRef * exception)
 {
-	if (argumentCount != 0)
-	{
-		JSStringRef jsstr = JSValueToStringCopy(ctx,
-							arguments[0],
-							exception);
-		JSCheckScriptSyntax(ctx, jsstr, 0, 0, exception);
-		if (jsstr)
-			JSStringRelease(jsstr);
-	}
-	else
-	{
-		gchar *mes = g_strdup_printf("Seed.check_syntax expected"
-					     "0 argument, got %d",
-					     argumentCount);
-		seed_make_exception(exception, "ArgumentError", mes);
-		g_free(mes);
-	}
-	return JSValueMakeNull(ctx);
+    if (argumentCount != 0)
+    {
+	JSStringRef jsstr = JSValueToStringCopy(ctx,
+						arguments[0],
+						exception);
+	JSCheckScriptSyntax(ctx, jsstr, 0, 0, exception);
+	if (jsstr)
+	    JSStringRelease(jsstr);
+    }
+    else
+    {
+	gchar *mes = g_strdup_printf("Seed.check_syntax expected"
+				     "0 argument, got %d",
+				     argumentCount);
+	seed_make_exception(exception, "ArgumentError", mes);
+	g_free(mes);
+    }
+    return JSValueMakeNull(ctx);
 }
 
 JSValueRef
@@ -295,21 +291,21 @@
 	  size_t argumentCount,
 	  const JSValueRef arguments[], JSValueRef * exception)
 {
-	pid_t child;
+    pid_t child;
 
-	child = fork();
-	return seed_value_from_int(child, exception);
+    child = fork();
+    return seed_value_from_int(child, exception);
 }
 
 static gboolean seed_timeout_function(gpointer user_data)
 {
-	// Evaluate timeout script
+    // Evaluate timeout script
 
-	const JSStringRef script = (const JSStringRef)user_data;
-	JSEvaluateScript(eng->context, script, NULL, NULL, 0, NULL);
-	JSStringRelease(script);
+    const JSStringRef script = (const JSStringRef)user_data;
+    JSEvaluateScript(eng->context, script, NULL, NULL, 0, NULL);
+    JSStringRelease(script);
 
-	return FALSE;		// remove timeout from main loop
+    return FALSE;		// remove timeout from main loop
 }
 
 JSValueRef
@@ -319,30 +315,30 @@
 		 size_t argumentCount,
 		 const JSValueRef arguments[], JSValueRef * exception)
 {
-	// TODO: check if a main loop is running. if not, return failure.
+    // TODO: check if a main loop is running. if not, return failure.
 
-	// GMainLoop* loop = g_main_loop_new(NULL,FALSE);
-	// if (!g_main_loop_is_running(loop))
-	// return JSValueMakeBoolean(ctx, 0);
-
-	if (argumentCount != 2)
-	{
-		gchar *mes =
-		    g_strdup_printf("Seed.set_timeout expected 2 arguments, "
-				    "got %d", argumentCount);
-		seed_make_exception(exception, "ArgumentError", mes);
-		g_free(mes);
-		return JSValueMakeBoolean(ctx, 0);
-	}
+    // GMainLoop* loop = g_main_loop_new(NULL,FALSE);
+    // if (!g_main_loop_is_running(loop))
+    // return JSValueMakeBoolean(ctx, 0);
+
+    if (argumentCount != 2)
+    {
+	gchar *mes =
+	    g_strdup_printf("Seed.set_timeout expected 2 arguments, "
+			    "got %d", argumentCount);
+	seed_make_exception(exception, "ArgumentError", mes);
+	g_free(mes);
+	return JSValueMakeBoolean(ctx, 0);
+    }
+
+    JSStringRef jsstr = JSValueToStringCopy(ctx,
+					    arguments[0],
+					    exception);
 
-	JSStringRef jsstr = JSValueToStringCopy(ctx,
-						arguments[0],
-						exception);
+    guint interval = seed_value_to_uint(arguments[1], exception);
+    g_timeout_add(interval, &seed_timeout_function, jsstr);
 
-	guint interval = seed_value_to_uint(arguments[1], exception);
-	g_timeout_add(interval, &seed_timeout_function, jsstr);
-
-	return JSValueMakeBoolean(ctx, 1);
+    return JSValueMakeBoolean(ctx, 1);
 }
 
 JSValueRef
@@ -352,27 +348,26 @@
 	     size_t argumentCount,
 	     const JSValueRef arguments[], JSValueRef * exception)
 {
-	SeedClosure *closure;
+    SeedClosure *closure;
+
+    if (argumentCount < 1 || argumentCount > 2)
+    {
+	gchar *mes =
+	    g_strdup_printf("Seed.closure expected 1 or 2" "arguments, got %d",
+			    argumentCount);
+	seed_make_exception(exception, "ArgumentError", mes);
+	g_free(mes);
+	return JSValueMakeNull(ctx);
+    }
 
-	if (argumentCount < 1 || argumentCount > 2)
-	{
-		gchar *mes =
-		    g_strdup_printf("Seed.closure expected 1 or 2"
-				    "arguments, got %d",
-				    argumentCount);
-		seed_make_exception(exception, "ArgumentError", mes);
-		g_free(mes);
-		return JSValueMakeNull(ctx);
-	}
-
-	if (argumentCount == 2)
-		closure =
-		    seed_make_gclosure((JSObjectRef) arguments[0],
-				       (JSObjectRef) arguments[1]);
-	else
-		closure = seed_make_gclosure((JSObjectRef) arguments[0], 0);
+    if (argumentCount == 2)
+	closure =
+	    seed_make_gclosure((JSObjectRef) arguments[0],
+			       (JSObjectRef) arguments[1]);
+    else
+	closure = seed_make_gclosure((JSObjectRef) arguments[0], 0);
 
-	return (JSValueRef) seed_make_struct(closure, 0);
+    return (JSValueRef) seed_make_struct(closure, 0);
 }
 
 JSValueRef
@@ -382,70 +377,68 @@
 		    size_t argumentCount,
 		    const JSValueRef arguments[], JSValueRef * exception)
 {
-	ffi_cif *cif;
-	ffi_closure *closure;
-	ffi_type **arg_types;
-	ffi_arg result;
-	ffi_status status;
-	GICallableInfo *info;
-	GITypeInfo *return_type;
-	GIArgInfo *arg_info;
-	gint num_args, i;
-	SeedNativeClosure *privates;
-
-	if (argumentCount != 2)
-	{
-		gchar *mes =
-		    g_strdup_printf("Seed.closure_native expected"
-				    " 2 arguments, got %d",
-				    argumentCount);
-
-		seed_make_exception(exception, "ArgumentError", mes);
-		g_free(mes);
-
-		return JSValueMakeNull(eng->context);
-	}
+    ffi_cif *cif;
+    ffi_closure *closure;
+    ffi_type **arg_types;
+    ffi_arg result;
+    ffi_status status;
+    GICallableInfo *info;
+    GITypeInfo *return_type;
+    GIArgInfo *arg_info;
+    gint num_args, i;
+    SeedNativeClosure *privates;
+
+    if (argumentCount != 2)
+    {
+	gchar *mes =
+	    g_strdup_printf("Seed.closure_native expected"
+			    " 2 arguments, got %d",
+			    argumentCount);
+
+	seed_make_exception(exception, "ArgumentError", mes);
+	g_free(mes);
+
+	return JSValueMakeNull(eng->context);
+    }
 
-	info = (GICallableInfo *)
-	    JSObjectGetPrivate((JSObjectRef) arguments[1]);
+    info = (GICallableInfo *) JSObjectGetPrivate((JSObjectRef) arguments[1]);
 
-	privates = seed_make_native_closure(info, arguments[0]);
+    privates = seed_make_native_closure(info, arguments[0]);
 
-	return JSObjectMake(eng->context, seed_native_callback_class, privates);
+    return JSObjectMake(eng->context, seed_native_callback_class, privates);
 }
 
 void seed_init_builtins(gint * argc, gchar *** argv)
 {
-	guint i;
-	JSObjectRef arrayObj;
-	JSValueRef argcref;
-	JSObjectRef obj =
-	    (JSObjectRef) seed_value_get_property(eng->global, "Seed");
-
-	seed_create_function("include", &seed_include, obj);
-	seed_create_function("print", &seed_print, obj);
-	seed_create_function("readline", &seed_readline, obj);
-	seed_create_function("prototype", &seed_prototype, obj);
-	seed_create_function("check_syntax", &seed_check_syntax, obj);
-	seed_create_function("introspect", &seed_introspect, obj);
-	seed_create_function("fork", &seed_fork, obj);
-	seed_create_function("closure", &seed_closure, obj);
-	seed_create_function("setTimeout", &seed_set_timeout, obj);
-	seed_create_function("closure_native", &seed_closure_native, obj);
-
-	arrayObj = JSObjectMake(eng->context, NULL, NULL);
-
-	for (i = 0; i < *argc; ++i)
-	{
-		// TODO: exceptions!
-
-		JSObjectSetPropertyAtIndex(eng->context, arrayObj, i,
-					   seed_value_from_string((*argv)[i],
-								  0), NULL);
-	}
+    guint i;
+    JSObjectRef arrayObj;
+    JSValueRef argcref;
+    JSObjectRef obj =
+	(JSObjectRef) seed_value_get_property(eng->global, "Seed");
+
+    seed_create_function("include", &seed_include, obj);
+    seed_create_function("print", &seed_print, obj);
+    seed_create_function("readline", &seed_readline, obj);
+    seed_create_function("prototype", &seed_prototype, obj);
+    seed_create_function("check_syntax", &seed_check_syntax, obj);
+    seed_create_function("introspect", &seed_introspect, obj);
+    seed_create_function("fork", &seed_fork, obj);
+    seed_create_function("closure", &seed_closure, obj);
+    seed_create_function("setTimeout", &seed_set_timeout, obj);
+    seed_create_function("closure_native", &seed_closure_native, obj);
+
+    arrayObj = JSObjectMake(eng->context, NULL, NULL);
+
+    for (i = 0; i < *argc; ++i)
+    {
+	// TODO: exceptions!
+
+	JSObjectSetPropertyAtIndex(eng->context, arrayObj, i,
+				   seed_value_from_string((*argv)[i], 0), NULL);
+    }
 
-	argcref = seed_value_from_int(*argc, 0);
+    argcref = seed_value_from_int(*argc, 0);
 
-	seed_value_set_property(arrayObj, "length", argcref);
-	seed_value_set_property(obj, "argv", arrayObj);
+    seed_value_set_property(arrayObj, "length", argcref);
+    seed_value_set_property(obj, "argv", arrayObj);
 }

Modified: trunk/libseed/seed-closure.c
==============================================================================
--- trunk/libseed/seed-closure.c	(original)
+++ trunk/libseed/seed-closure.c	Sat Nov  8 01:42:29 2008
@@ -23,402 +23,401 @@
 
 static ffi_type *get_ffi_type(GITypeInfo * info)
 {
-	ffi_type *rettype;
+    ffi_type *rettype;
 
-	if (g_type_info_is_pointer(info))
-		rettype = &ffi_type_pointer;
-	else
-		switch (g_type_info_get_tag(info))
-		{
-		case GI_TYPE_TAG_VOID:
-			rettype = &ffi_type_void;
-			break;
-		case GI_TYPE_TAG_BOOLEAN:
-			rettype = &ffi_type_uint;
-			break;
-		case GI_TYPE_TAG_INT8:
-			rettype = &ffi_type_sint8;
-			break;
-		case GI_TYPE_TAG_UINT8:
-			rettype = &ffi_type_uint8;
-			break;
-		case GI_TYPE_TAG_INT16:
-			rettype = &ffi_type_sint16;
-			break;
-		case GI_TYPE_TAG_UINT16:
-			rettype = &ffi_type_uint16;
-			break;
-		case GI_TYPE_TAG_INT32:
-			rettype = &ffi_type_sint32;
-			break;
-		case GI_TYPE_TAG_UINT32:
-			rettype = &ffi_type_uint32;
-			break;
-		case GI_TYPE_TAG_INT64:
-			rettype = &ffi_type_sint64;
-			break;
-		case GI_TYPE_TAG_UINT64:
-			rettype = &ffi_type_uint64;
-			break;
-		case GI_TYPE_TAG_INT:
-			rettype = &ffi_type_sint;
-			break;
-		case GI_TYPE_TAG_UINT:
-			rettype = &ffi_type_uint;
-			break;
-		case GI_TYPE_TAG_SSIZE:	/* FIXME */
-		case GI_TYPE_TAG_LONG:
-			rettype = &ffi_type_slong;
-			break;
-		case GI_TYPE_TAG_SIZE:	/* FIXME */
-		case GI_TYPE_TAG_TIME_T:	/* May not be portable */
-		case GI_TYPE_TAG_ULONG:
-			rettype = &ffi_type_ulong;
-			break;
-		case GI_TYPE_TAG_FLOAT:
-			rettype = &ffi_type_float;
-			break;
-		case GI_TYPE_TAG_DOUBLE:
-			rettype = &ffi_type_double;
-			break;
-		case GI_TYPE_TAG_UTF8:
-		case GI_TYPE_TAG_FILENAME:
-		case GI_TYPE_TAG_ARRAY:
-		case GI_TYPE_TAG_INTERFACE:
-		case GI_TYPE_TAG_GLIST:
-		case GI_TYPE_TAG_GSLIST:
-		case GI_TYPE_TAG_GHASH:
-		case GI_TYPE_TAG_ERROR:
-			rettype = &ffi_type_pointer;
-			break;
-		default:
-			g_assert_not_reached();
-		}
+    if (g_type_info_is_pointer(info))
+	rettype = &ffi_type_pointer;
+    else
+	switch (g_type_info_get_tag(info))
+	{
+	case GI_TYPE_TAG_VOID:
+	    rettype = &ffi_type_void;
+	    break;
+	case GI_TYPE_TAG_BOOLEAN:
+	    rettype = &ffi_type_uint;
+	    break;
+	case GI_TYPE_TAG_INT8:
+	    rettype = &ffi_type_sint8;
+	    break;
+	case GI_TYPE_TAG_UINT8:
+	    rettype = &ffi_type_uint8;
+	    break;
+	case GI_TYPE_TAG_INT16:
+	    rettype = &ffi_type_sint16;
+	    break;
+	case GI_TYPE_TAG_UINT16:
+	    rettype = &ffi_type_uint16;
+	    break;
+	case GI_TYPE_TAG_INT32:
+	    rettype = &ffi_type_sint32;
+	    break;
+	case GI_TYPE_TAG_UINT32:
+	    rettype = &ffi_type_uint32;
+	    break;
+	case GI_TYPE_TAG_INT64:
+	    rettype = &ffi_type_sint64;
+	    break;
+	case GI_TYPE_TAG_UINT64:
+	    rettype = &ffi_type_uint64;
+	    break;
+	case GI_TYPE_TAG_INT:
+	    rettype = &ffi_type_sint;
+	    break;
+	case GI_TYPE_TAG_UINT:
+	    rettype = &ffi_type_uint;
+	    break;
+	case GI_TYPE_TAG_SSIZE:	/* FIXME */
+	case GI_TYPE_TAG_LONG:
+	    rettype = &ffi_type_slong;
+	    break;
+	case GI_TYPE_TAG_SIZE:	/* FIXME */
+	case GI_TYPE_TAG_TIME_T:	/* May not be portable */
+	case GI_TYPE_TAG_ULONG:
+	    rettype = &ffi_type_ulong;
+	    break;
+	case GI_TYPE_TAG_FLOAT:
+	    rettype = &ffi_type_float;
+	    break;
+	case GI_TYPE_TAG_DOUBLE:
+	    rettype = &ffi_type_double;
+	    break;
+	case GI_TYPE_TAG_UTF8:
+	case GI_TYPE_TAG_FILENAME:
+	case GI_TYPE_TAG_ARRAY:
+	case GI_TYPE_TAG_INTERFACE:
+	case GI_TYPE_TAG_GLIST:
+	case GI_TYPE_TAG_GSLIST:
+	case GI_TYPE_TAG_GHASH:
+	case GI_TYPE_TAG_ERROR:
+	    rettype = &ffi_type_pointer;
+	    break;
+	default:
+	    g_assert_not_reached();
+	}
 
-	return rettype;
+    return rettype;
 }
 
 static void seed_closure_finalize(JSObjectRef object)
 {
-	SeedNativeClosure *privates =
-	    (SeedNativeClosure *) JSObjectGetPrivate(object);
+    SeedNativeClosure *privates =
+	(SeedNativeClosure *) JSObjectGetPrivate(object);
 
-	g_free(privates->cif->arg_types);
-	g_free(privates->cif);
-	JSValueUnprotect(eng->context, privates->function);
-	munmap(privates->closure, sizeof(ffi_closure));
+    g_free(privates->cif->arg_types);
+    g_free(privates->cif);
+    JSValueUnprotect(eng->context, privates->function);
+    munmap(privates->closure, sizeof(ffi_closure));
 }
 
 static void
 seed_handle_closure(ffi_cif * cif, void *result, void **args, void *userdata)
 {
-	SeedNativeClosure *privates = userdata;
-	gint num_args, i;
-	JSValueRef *jsargs;
-	JSValueRef return_value;
-	GITypeTag return_tag;
-	GIArgInfo *arg_info;
-	GITypeInfo *return_type;
-	GArgument rarg;
-	GArgument *return_arg = g_new0(GArgument, 1);
-
-	num_args = g_callable_info_get_n_args(privates->info);
-	return_type = g_callable_info_get_return_type(privates->info);
-	return_tag = g_type_info_get_tag(return_type);
-	jsargs = (JSValueRef *) g_new0(JSValueRef, num_args);
-
-	for (i = 0; i < num_args; i++)
-	{
-		GITypeInfo *arg_type;
-		GITypeTag tag;
-		GType type;
-		GArgument *arg = &rarg;
-
-		arg_info = g_callable_info_get_arg(privates->info, i);
-		arg_type = g_arg_info_get_type(arg_info);
-		tag = g_type_info_get_tag(arg_type);
-
-		switch (tag)
-		{
-		case GI_TYPE_TAG_BOOLEAN:
-			arg->v_boolean = *(gboolean *) args[i];
-			break;
-		case GI_TYPE_TAG_INT8:
-			arg->v_int8 = *(gint8 *) args[i];
-			break;
-		case GI_TYPE_TAG_UINT8:
-			arg->v_uint8 = *(guint8 *) args[i];
-			break;
-		case GI_TYPE_TAG_INT16:
-			arg->v_int16 = *(gint16 *) args[i];
-			break;
-		case GI_TYPE_TAG_UINT16:
-			arg->v_uint16 = *(guint16 *) args[i];
-			break;
-		case GI_TYPE_TAG_INT32:
-			arg->v_int32 = *(gint32 *) args[i];
-			break;
-		case GI_TYPE_TAG_UINT32:
-			arg->v_uint32 = *(guint32 *) args[i];
-			break;
-		case GI_TYPE_TAG_LONG:
-		case GI_TYPE_TAG_INT64:
-			arg->v_int64 = *(glong *) args[i];
-			break;
-		case GI_TYPE_TAG_ULONG:
-		case GI_TYPE_TAG_UINT64:
-			arg->v_uint64 = *(glong *) args[i];
-			break;
-		case GI_TYPE_TAG_INT:
-		case GI_TYPE_TAG_SSIZE:
-		case GI_TYPE_TAG_SIZE:
-			arg->v_int32 = *(gint *) args[i];
-			break;
-		case GI_TYPE_TAG_UINT:
-			arg->v_uint32 = *(guint *) args[i];
-			break;
-		case GI_TYPE_TAG_FLOAT:
-			arg->v_float = *(gfloat *) args[i];
-			break;
-		case GI_TYPE_TAG_DOUBLE:
-			arg->v_double = *(gdouble *) args[i];
-			break;
-		case GI_TYPE_TAG_UTF8:
-			arg->v_string = *(gchar **) args[i];
-			break;
-		case GI_TYPE_TAG_INTERFACE:
-			{
-				GIBaseInfo *interface;
-				GIInfoType interface_type;
-
-				interface = g_type_info_get_interface(arg_type);
-				interface_type =
-				    g_base_info_get_type(interface);
-
-				if (interface_type == GI_INFO_TYPE_OBJECT ||
-				    interface_type == GI_INFO_TYPE_INTERFACE)
-				{
-					arg->v_pointer = *(gpointer *) args[i];
-					break;
-				}
-
-				else if (interface_type == GI_INFO_TYPE_ENUM ||
-					 interface_type == GI_INFO_TYPE_FLAGS)
-				{
-					arg->v_double = *(double *)args[i];
-					break;
-				}
-				else if (interface_type == GI_INFO_TYPE_STRUCT)
-				{
-					arg->v_pointer = *(gpointer *) args[i];
-					break;
-				}
-			}
-		case GI_TYPE_TAG_GLIST:
-		case GI_TYPE_TAG_GSLIST:
-			arg->v_pointer = *(gpointer *) args[i];
-			break;
-		default:
-			arg->v_pointer = 0;
-		}
-		jsargs[i] = seed_gi_argument_make_js(arg, arg_type, 0);
-	}
+    SeedNativeClosure *privates = userdata;
+    gint num_args, i;
+    JSValueRef *jsargs;
+    JSValueRef return_value;
+    GITypeTag return_tag;
+    GIArgInfo *arg_info;
+    GITypeInfo *return_type;
+    GArgument rarg;
+    GArgument *return_arg = g_new0(GArgument, 1);
+
+    num_args = g_callable_info_get_n_args(privates->info);
+    return_type = g_callable_info_get_return_type(privates->info);
+    return_tag = g_type_info_get_tag(return_type);
+    jsargs = (JSValueRef *) g_new0(JSValueRef, num_args);
+
+    for (i = 0; i < num_args; i++)
+    {
+	GITypeInfo *arg_type;
+	GITypeTag tag;
+	GType type;
+	GArgument *arg = &rarg;
+
+	arg_info = g_callable_info_get_arg(privates->info, i);
+	arg_type = g_arg_info_get_type(arg_info);
+	tag = g_type_info_get_tag(arg_type);
 
-	return_value = (JSValueRef)
-	    JSObjectCallAsFunction(eng->context,
-				   (JSObjectRef) privates->function, 0,
-				   num_args, jsargs, 0);
-
-	seed_gi_make_argument((JSValueRef) return_value, return_type,
-			      return_arg, 0);
-	switch (return_tag)
+	switch (tag)
 	{
-
 	case GI_TYPE_TAG_BOOLEAN:
-		*(gboolean *) result = return_arg->v_boolean;
-		break;
+	    arg->v_boolean = *(gboolean *) args[i];
+	    break;
 	case GI_TYPE_TAG_INT8:
-		*(gint8 *) result = return_arg->v_int8;
-		break;
+	    arg->v_int8 = *(gint8 *) args[i];
+	    break;
 	case GI_TYPE_TAG_UINT8:
-		*(guint8 *) result = return_arg->v_uint8;
-		break;
+	    arg->v_uint8 = *(guint8 *) args[i];
+	    break;
 	case GI_TYPE_TAG_INT16:
-		*(gint16 *) result = return_arg->v_int16;
-		break;
+	    arg->v_int16 = *(gint16 *) args[i];
+	    break;
 	case GI_TYPE_TAG_UINT16:
-		return_arg->v_uint16 = *(guint16 *) args[i];
-		break;
+	    arg->v_uint16 = *(guint16 *) args[i];
+	    break;
 	case GI_TYPE_TAG_INT32:
-		*(gint32 *) result = return_arg->v_int32;
-		break;
+	    arg->v_int32 = *(gint32 *) args[i];
+	    break;
 	case GI_TYPE_TAG_UINT32:
-		*(guint32 *) result = return_arg->v_uint32;
-		break;
+	    arg->v_uint32 = *(guint32 *) args[i];
+	    break;
 	case GI_TYPE_TAG_LONG:
 	case GI_TYPE_TAG_INT64:
-		*(glong *) result = return_arg->v_int64;
-		break;
+	    arg->v_int64 = *(glong *) args[i];
+	    break;
 	case GI_TYPE_TAG_ULONG:
 	case GI_TYPE_TAG_UINT64:
-		*(glong *) result = return_arg->v_uint64;
-		break;
+	    arg->v_uint64 = *(glong *) args[i];
+	    break;
 	case GI_TYPE_TAG_INT:
 	case GI_TYPE_TAG_SSIZE:
 	case GI_TYPE_TAG_SIZE:
-		*(gint *) result = return_arg->v_int32;
-		break;
+	    arg->v_int32 = *(gint *) args[i];
+	    break;
 	case GI_TYPE_TAG_UINT:
-		*(guint *) result = return_arg->v_uint32;
-		break;
+	    arg->v_uint32 = *(guint *) args[i];
+	    break;
 	case GI_TYPE_TAG_FLOAT:
-		*(gfloat *) result = return_arg->v_float;
-		break;
+	    arg->v_float = *(gfloat *) args[i];
+	    break;
 	case GI_TYPE_TAG_DOUBLE:
-		*(gdouble *) result = return_arg->v_double;
-		break;
+	    arg->v_double = *(gdouble *) args[i];
+	    break;
 	case GI_TYPE_TAG_UTF8:
-		*(gchar **) result = return_arg->v_string;
-		break;
+	    arg->v_string = *(gchar **) args[i];
+	    break;
 	case GI_TYPE_TAG_INTERFACE:
-		{
-			GIBaseInfo *interface;
-			GIInfoType interface_type;
+	    {
+		GIBaseInfo *interface;
+		GIInfoType interface_type;
 
-			interface = g_type_info_get_interface(return_type);
-			interface_type = g_base_info_get_type(interface);
+		interface = g_type_info_get_interface(arg_type);
+		interface_type = g_base_info_get_type(interface);
 
-			if (interface_type == GI_INFO_TYPE_OBJECT ||
-			    interface_type == GI_INFO_TYPE_INTERFACE)
-			{
-				*(gpointer *) result = return_arg->v_pointer;
-				break;
-			}
-
-			else if (interface_type == GI_INFO_TYPE_ENUM ||
-				 interface_type == GI_INFO_TYPE_FLAGS)
-			{
-				*(double *)result = return_arg->v_double;
-				break;
-			}
-			else if (interface_type == GI_INFO_TYPE_STRUCT)
-			{
-				*(gpointer *) result = return_arg->v_pointer;
-				break;
-			}
+		if (interface_type == GI_INFO_TYPE_OBJECT ||
+		    interface_type == GI_INFO_TYPE_INTERFACE)
+		{
+		    arg->v_pointer = *(gpointer *) args[i];
+		    break;
+		}
+
+		else if (interface_type == GI_INFO_TYPE_ENUM ||
+			 interface_type == GI_INFO_TYPE_FLAGS)
+		{
+		    arg->v_double = *(double *)args[i];
+		    break;
 		}
+		else if (interface_type == GI_INFO_TYPE_STRUCT)
+		{
+		    arg->v_pointer = *(gpointer *) args[i];
+		    break;
+		}
+	    }
 	case GI_TYPE_TAG_GLIST:
 	case GI_TYPE_TAG_GSLIST:
-		*(gpointer *) result = return_arg->v_pointer;
-		break;
+	    arg->v_pointer = *(gpointer *) args[i];
+	    break;
 	default:
-		*(gpointer *) result = 0;
+	    arg->v_pointer = 0;
 	}
-}
+	jsargs[i] = seed_gi_argument_make_js(arg, arg_type, 0);
+    }
 
-SeedNativeClosure *seed_make_native_closure(GICallableInfo * info,
-					    JSValueRef function)
-{
-	ffi_cif *cif;
-	ffi_closure *closure;
-	ffi_type **arg_types;
-	ffi_arg result;
-	ffi_status status;
-	GITypeInfo *return_type;
-	GIArgInfo *arg_info;
-	gint num_args, i;
-	SeedNativeClosure *privates;
-	JSObjectRef cached;
-
-	cached =
-	    (JSObjectRef) seed_value_get_property(function,
-						  "__seed_native_closure");
-	if (cached
-	    && JSValueIsObjectOfClass(eng->context, cached,
-				      seed_native_callback_class))
+    return_value = (JSValueRef)
+	JSObjectCallAsFunction(eng->context,
+			       (JSObjectRef) privates->function, 0,
+			       num_args, jsargs, 0);
+
+    seed_gi_make_argument((JSValueRef) return_value, return_type,
+			  return_arg, 0);
+    switch (return_tag)
+    {
+
+    case GI_TYPE_TAG_BOOLEAN:
+	*(gboolean *) result = return_arg->v_boolean;
+	break;
+    case GI_TYPE_TAG_INT8:
+	*(gint8 *) result = return_arg->v_int8;
+	break;
+    case GI_TYPE_TAG_UINT8:
+	*(guint8 *) result = return_arg->v_uint8;
+	break;
+    case GI_TYPE_TAG_INT16:
+	*(gint16 *) result = return_arg->v_int16;
+	break;
+    case GI_TYPE_TAG_UINT16:
+	return_arg->v_uint16 = *(guint16 *) args[i];
+	break;
+    case GI_TYPE_TAG_INT32:
+	*(gint32 *) result = return_arg->v_int32;
+	break;
+    case GI_TYPE_TAG_UINT32:
+	*(guint32 *) result = return_arg->v_uint32;
+	break;
+    case GI_TYPE_TAG_LONG:
+    case GI_TYPE_TAG_INT64:
+	*(glong *) result = return_arg->v_int64;
+	break;
+    case GI_TYPE_TAG_ULONG:
+    case GI_TYPE_TAG_UINT64:
+	*(glong *) result = return_arg->v_uint64;
+	break;
+    case GI_TYPE_TAG_INT:
+    case GI_TYPE_TAG_SSIZE:
+    case GI_TYPE_TAG_SIZE:
+	*(gint *) result = return_arg->v_int32;
+	break;
+    case GI_TYPE_TAG_UINT:
+	*(guint *) result = return_arg->v_uint32;
+	break;
+    case GI_TYPE_TAG_FLOAT:
+	*(gfloat *) result = return_arg->v_float;
+	break;
+    case GI_TYPE_TAG_DOUBLE:
+	*(gdouble *) result = return_arg->v_double;
+	break;
+    case GI_TYPE_TAG_UTF8:
+	*(gchar **) result = return_arg->v_string;
+	break;
+    case GI_TYPE_TAG_INTERFACE:
 	{
-		return (SeedNativeClosure *) JSObjectGetPrivate(cached);
-	}
+	    GIBaseInfo *interface;
+	    GIInfoType interface_type;
 
-	num_args = g_callable_info_get_n_args(info);
-	return_type = g_callable_info_get_return_type(info);
-	arg_types = (ffi_type **) g_new0(ffi_type *, num_args + 1);
-	cif = g_new0(ffi_cif, 1);
-
-	privates = g_new0(SeedNativeClosure, 1);
-	privates->info = info;
-	privates->function = function;
-	privates->cif = cif;
-	JSValueProtect(eng->context, privates->function);
+	    interface = g_type_info_get_interface(return_type);
+	    interface_type = g_base_info_get_type(interface);
 
-	for (i = 0; i < num_args; i++)
-	{
-		arg_info = g_callable_info_get_arg(info, i);
-		arg_types[i] = get_ffi_type(g_arg_info_get_type(arg_info));
+	    if (interface_type == GI_INFO_TYPE_OBJECT ||
+		interface_type == GI_INFO_TYPE_INTERFACE)
+	    {
+		*(gpointer *) result = return_arg->v_pointer;
+		break;
+	    }
+
+	    else if (interface_type == GI_INFO_TYPE_ENUM ||
+		     interface_type == GI_INFO_TYPE_FLAGS)
+	    {
+		*(double *)result = return_arg->v_double;
+		break;
+	    }
+	    else if (interface_type == GI_INFO_TYPE_STRUCT)
+	    {
+		*(gpointer *) result = return_arg->v_pointer;
+		break;
+	    }
 	}
-	arg_types[num_args] = 0;
+    case GI_TYPE_TAG_GLIST:
+    case GI_TYPE_TAG_GSLIST:
+	*(gpointer *) result = return_arg->v_pointer;
+	break;
+    default:
+	*(gpointer *) result = 0;
+    }
+}
 
-	closure = mmap(0, sizeof(ffi_closure), PROT_READ | PROT_WRITE |
-		       PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
-	privates->closure = closure;
-
-	ffi_prep_cif(cif, FFI_DEFAULT_ABI, num_args,
-		     get_ffi_type(return_type), arg_types);
-	ffi_prep_closure(closure, cif, seed_handle_closure, privates);
-
-	seed_value_set_property((JSObjectRef) function,
-				"__seed_native_closure",
-				(JSValueRef) JSObjectMake(eng->context,
-							  seed_native_callback_class,
-							  privates));
+SeedNativeClosure *seed_make_native_closure(GICallableInfo * info,
+					    JSValueRef function)
+{
+    ffi_cif *cif;
+    ffi_closure *closure;
+    ffi_type **arg_types;
+    ffi_arg result;
+    ffi_status status;
+    GITypeInfo *return_type;
+    GIArgInfo *arg_info;
+    gint num_args, i;
+    SeedNativeClosure *privates;
+    JSObjectRef cached;
+
+    cached =
+	(JSObjectRef) seed_value_get_property(function,
+					      "__seed_native_closure");
+    if (cached
+	&& JSValueIsObjectOfClass(eng->context, cached,
+				  seed_native_callback_class))
+    {
+	return (SeedNativeClosure *) JSObjectGetPrivate(cached);
+    }
+
+    num_args = g_callable_info_get_n_args(info);
+    return_type = g_callable_info_get_return_type(info);
+    arg_types = (ffi_type **) g_new0(ffi_type *, num_args + 1);
+    cif = g_new0(ffi_cif, 1);
+
+    privates = g_new0(SeedNativeClosure, 1);
+    privates->info = info;
+    privates->function = function;
+    privates->cif = cif;
+    JSValueProtect(eng->context, privates->function);
+
+    for (i = 0; i < num_args; i++)
+    {
+	arg_info = g_callable_info_get_arg(info, i);
+	arg_types[i] = get_ffi_type(g_arg_info_get_type(arg_info));
+    }
+    arg_types[num_args] = 0;
+
+    closure = mmap(0, sizeof(ffi_closure), PROT_READ | PROT_WRITE |
+		   PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
+    privates->closure = closure;
+
+    ffi_prep_cif(cif, FFI_DEFAULT_ABI, num_args,
+		 get_ffi_type(return_type), arg_types);
+    ffi_prep_closure(closure, cif, seed_handle_closure, privates);
+
+    seed_value_set_property((JSObjectRef) function,
+			    "__seed_native_closure",
+			    (JSValueRef) JSObjectMake(eng->context,
+						      seed_native_callback_class,
+						      privates));
 
-	return privates;
+    return privates;
 }
 
 SeedClosure *seed_make_gclosure(JSObjectRef function, JSObjectRef this)
 {
-	GClosure *closure;
+    GClosure *closure;
 
-	closure = g_closure_new_simple(sizeof(SeedClosure), 0);
-	g_closure_set_marshal(closure, seed_signal_marshal_func);
+    closure = g_closure_new_simple(sizeof(SeedClosure), 0);
+    g_closure_set_marshal(closure, seed_signal_marshal_func);
 
-	((SeedClosure *) closure)->function = function;
-	((SeedClosure *) closure)->object = 0;
-	if (this && !JSValueIsNull(eng->context, this))
-	{
-		JSValueProtect(eng->context, this);
-		((SeedClosure *) closure)->this = this;
-	}
-	else
-		((SeedClosure *) closure)->this = 0;
+    ((SeedClosure *) closure)->function = function;
+    ((SeedClosure *) closure)->object = 0;
+    if (this && !JSValueIsNull(eng->context, this))
+    {
+	JSValueProtect(eng->context, this);
+	((SeedClosure *) closure)->this = this;
+    }
+    else
+	((SeedClosure *) closure)->this = 0;
 
-	JSValueProtect(eng->context, function);
+    JSValueProtect(eng->context, function);
 
-	return (SeedClosure *) closure;
+    return (SeedClosure *) closure;
 }
 
 JSClassDefinition seed_native_callback_def = {
-	0,			/* Version, always 0 */
-	0,
-	"seed_native_callback",	/* Class Name */
-	0,			/* Parent Class */
-	NULL,			/* Static Values */
-	NULL,			/* Static Functions */
-	NULL,
-	seed_closure_finalize,	/* Finalize */
-	NULL,			/* Has Property */
-	NULL,			/* Get Property */
-	NULL,			/* Set Property */
-	NULL,			/* Delete Property */
-	NULL,			/* Get Property Names */
-	NULL,			/* Call As Function */
-	NULL,			/* Call As Constructor */
-	NULL,			/* Has Instance */
-	NULL			/* Convert To Type */
+    0,				/* Version, always 0 */
+    0,
+    "seed_native_callback",	/* Class Name */
+    0,				/* Parent Class */
+    NULL,			/* Static Values */
+    NULL,			/* Static Functions */
+    NULL,
+    seed_closure_finalize,	/* Finalize */
+    NULL,			/* Has Property */
+    NULL,			/* Get Property */
+    NULL,			/* Set Property */
+    NULL,			/* Delete Property */
+    NULL,			/* Get Property Names */
+    NULL,			/* Call As Function */
+    NULL,			/* Call As Constructor */
+    NULL,			/* Has Instance */
+    NULL			/* Convert To Type */
 };
 
 void seed_closures_init(void)
 {
-	seed_native_callback_class = JSClassCreate(&seed_native_callback_def);
-	JSClassRetain(seed_native_callback_class);
+    seed_native_callback_class = JSClassCreate(&seed_native_callback_def);
+    JSClassRetain(seed_native_callback_class);
 }

Modified: trunk/libseed/seed-closure.h
==============================================================================
--- trunk/libseed/seed-closure.h	(original)
+++ trunk/libseed/seed-closure.h	Sat Nov  8 01:42:29 2008
@@ -24,18 +24,18 @@
 #include "seed-private.h"
 
 typedef struct _SeedClosure {
-	GClosure closure;
-	JSObjectRef function;
-	JSObjectRef object;
-	JSObjectRef this;
+    GClosure closure;
+    JSObjectRef function;
+    JSObjectRef object;
+    JSObjectRef this;
 } SeedClosure;
 
 typedef struct _SeedNativeClosure {
-	GICallableInfo *info;
-	JSValueRef function;
+    GICallableInfo *info;
+    JSValueRef function;
 
-	ffi_closure *closure;
-	ffi_cif *cif;
+    ffi_closure *closure;
+    ffi_cif *cif;
 } SeedNativeClosure;
 
 extern JSClassRef seed_native_callback_class;

Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c	(original)
+++ trunk/libseed/seed-engine.c	Sat Nov  8 01:42:29 2008
@@ -36,33 +36,33 @@
 seed_make_exception(JSValueRef * exception,
 		    const gchar * name, const gchar * message)
 {
-	JSStringRef js_name = 0;
-	JSStringRef js_message = 0;
-	JSValueRef js_name_ref = 0, js_message_ref = 0;
-	JSObjectRef exception_obj;
+    JSStringRef js_name = 0;
+    JSStringRef js_message = 0;
+    JSValueRef js_name_ref = 0, js_message_ref = 0;
+    JSObjectRef exception_obj;
+
+    if (!exception)
+	return;
+
+    if (name)
+    {
+	js_name = JSStringCreateWithUTF8CString(name);
+	js_name_ref = JSValueMakeString(eng->context, js_name);
+    }
+    if (message)
+    {
+	js_message = JSStringCreateWithUTF8CString(message);
+	js_message_ref = JSValueMakeString(eng->context, js_message);
+    }
+
+    exception_obj = JSObjectMake(eng->context, 0, NULL);
+    seed_value_set_property(exception_obj, "message", js_message_ref);
+    seed_value_set_property(exception_obj, "name", js_name_ref);
 
-	if (!exception)
-		return;
+    *exception = exception_obj;
 
-	if (name)
-	{
-		js_name = JSStringCreateWithUTF8CString(name);
-		js_name_ref = JSValueMakeString(eng->context, js_name);
-	}
-	if (message)
-	{
-		js_message = JSStringCreateWithUTF8CString(message);
-		js_message_ref = JSValueMakeString(eng->context, js_message);
-	}
-
-	exception_obj = JSObjectMake(eng->context, 0, NULL);
-	seed_value_set_property(exception_obj, "message", js_message_ref);
-	seed_value_set_property(exception_obj, "name", js_name_ref);
-
-	*exception = exception_obj;
-
-	JSStringRelease(js_name);
-	JSStringRelease(js_message);
+    JSStringRelease(js_name);
+    JSStringRelease(js_message);
 }
 
 static JSObjectRef
@@ -72,102 +72,101 @@
 				 const JSValueRef arguments[],
 				 JSValueRef * exception)
 {
-	GType type;
-	GParameter *params;
-	GObjectClass *oclass;
-	GObject *gobject;
-	// Do we free GParamSpecs...? It's not clear.
-	GParamSpec *param_spec;
-	gchar *prop_name;
-	gint i, nparams = 0, length;
-	JSObjectRef ret;
-	JSPropertyNameArrayRef jsprops = 0;
-	JSStringRef jsprop_name;
-	JSValueRef jsprop_value;
-
-	type = (GType) JSObjectGetPrivate(constructor);
-	if (!type)
-		return 0;
-	oclass = g_type_class_ref(type);
+    GType type;
+    GParameter *params;
+    GObjectClass *oclass;
+    GObject *gobject;
+    // Do we free GParamSpecs...? It's not clear.
+    GParamSpec *param_spec;
+    gchar *prop_name;
+    gint i, nparams = 0, length;
+    JSObjectRef ret;
+    JSPropertyNameArrayRef jsprops = 0;
+    JSStringRef jsprop_name;
+    JSValueRef jsprop_value;
+
+    type = (GType) JSObjectGetPrivate(constructor);
+    if (!type)
+	return 0;
+    oclass = g_type_class_ref(type);
+
+    g_assert(argumentCount <= 1);
+
+    if (argumentCount == 1)
+    {
+	jsprops = JSObjectCopyPropertyNames(eng->context,
+					    (JSObjectRef) arguments[0]);
+	nparams = JSPropertyNameArrayGetCount(jsprops);
+    }
+    i = 0;
 
-	g_assert(argumentCount <= 1);
+    params = g_new0(GParameter, nparams + 1);
 
-	if (argumentCount == 1)
-	{
-		jsprops = JSObjectCopyPropertyNames(eng->context,
-						    (JSObjectRef) arguments[0]);
-		nparams = JSPropertyNameArrayGetCount(jsprops);
-	}
-	i = 0;
+    // TODO: make sure we don't die if we get passed something other than
+    // an object
 
-	params = g_new0(GParameter, nparams + 1);
+    while (i < nparams)
+    {
+	GType type;
+	jsprop_name = JSPropertyNameArrayGetNameAtIndex(jsprops, i);
 
-	// TODO: make sure we don't die if we get passed something other than
-	// an object
+	length = JSStringGetMaximumUTF8CStringSize(jsprop_name);
+	prop_name = g_malloc(length * sizeof(gchar));
+	JSStringGetUTF8CString(jsprop_name, prop_name, length);
 
-	while (i < nparams)
+	param_spec = g_object_class_find_property(oclass, prop_name);
+	if (param_spec == NULL)
 	{
-		GType type;
-		jsprop_name = JSPropertyNameArrayGetNameAtIndex(jsprops, i);
+	    gchar *mes =
+		g_strdup_printf("Invalid property for construction: %s",
+				prop_name);
+	    seed_make_exception(exception, "PropertyError", mes);
 
-		length = JSStringGetMaximumUTF8CStringSize(jsprop_name);
-		prop_name = g_malloc(length * sizeof(gchar));
-		JSStringGetUTF8CString(jsprop_name, prop_name, length);
+	    g_free(mes);
+	    g_free(params);
 
-		param_spec = g_object_class_find_property(oclass, prop_name);
-		if (param_spec == NULL)
-		{
-			gchar *mes =
-			    g_strdup_printf
-			    ("Invalid property for construction: %s",
-			     prop_name);
-			seed_make_exception(exception, "PropertyError", mes);
-
-			g_free(mes);
-			g_free(params);
-
-			return (JSObjectRef) JSValueMakeNull(eng->context);
-		}
-		// TODO: exception handling
-		jsprop_value = JSObjectGetProperty(eng->context,
-						   (JSObjectRef) arguments[0],
-						   jsprop_name, NULL);
-
-		if (g_type_is_a(param_spec->value_type, G_TYPE_ENUM))
-			type = G_TYPE_INT;
-		else
-			type = param_spec->value_type;
+	    return (JSObjectRef) JSValueMakeNull(eng->context);
+	}
+	// TODO: exception handling
+	jsprop_value = JSObjectGetProperty(eng->context,
+					   (JSObjectRef) arguments[0],
+					   jsprop_name, NULL);
 
-		seed_gvalue_from_seed_value(jsprop_value,
-					    type, &params[i].value, exception);
+	if (g_type_is_a(param_spec->value_type, G_TYPE_ENUM))
+	    type = G_TYPE_INT;
+	else
+	    type = param_spec->value_type;
 
-		if (*exception)
-		{
+	seed_gvalue_from_seed_value(jsprop_value,
+				    type, &params[i].value, exception);
 
-			g_free(prop_name);
-			g_free(params);
-			return 0;
-		}
-		params[i].name = prop_name;
+	if (*exception)
+	{
 
-		++i;
+	    g_free(prop_name);
+	    g_free(params);
+	    return 0;
 	}
+	params[i].name = prop_name;
 
-	if (jsprops)
-		JSPropertyNameArrayRelease(jsprops);
+	++i;
+    }
 
-	gobject = g_object_newv(type, nparams, params);
+    if (jsprops)
+	JSPropertyNameArrayRelease(jsprops);
 
-	if (!gobject)
-		JSValueMakeNull(eng->context);
+    gobject = g_object_newv(type, nparams, params);
 
-	ret = (JSObjectRef) seed_value_from_object(gobject, 0);
+    if (!gobject)
+	JSValueMakeNull(eng->context);
 
-	g_type_class_unref(oclass);
+    ret = (JSObjectRef) seed_value_from_object(gobject, 0);
 
-	g_free(params);
+    g_type_class_unref(oclass);
 
-	return ret;
+    g_free(params);
+
+    return ret;
 }
 
 static JSValueRef
@@ -177,16 +176,16 @@
 		    size_t argumentCount,
 		    const JSValueRef arguments[], JSValueRef * exception)
 {
-	GObject *this, *that;
+    GObject *this, *that;
 
-	g_assert(argumentCount == 1);
+    g_assert(argumentCount == 1);
 
-	this = seed_value_to_object((JSValueRef) this_object, exception);
-	that = seed_value_to_object(arguments[0], exception);
+    this = seed_value_to_object((JSValueRef) this_object, exception);
+    that = seed_value_to_object(arguments[0], exception);
 
-	if (this == that)
-		return seed_value_from_boolean(1, 0);
-	return seed_value_from_boolean(0, 0);
+    if (this == that)
+	return seed_value_from_boolean(1, 0);
+    return seed_value_from_boolean(0, 0);
 }
 
 static JSValueRef
@@ -197,128 +196,123 @@
 			    const JSValueRef arguments[],
 			    JSValueRef * exception)
 {
-	GIBaseInfo *info;
-	GObject *object;
-	gboolean instance_method = TRUE;
-	GArgument retval;
-	GArgument *in_args;
-	GArgument *out_args;
-	gint n_args, n_in_args, n_out_args, i;
-	GIArgInfo *arg_info;
-	GITypeInfo *type_info;
-	GIDirection dir;
-	JSValueRef retval_ref;
-	GError *error = 0;
-
-	info = JSObjectGetPrivate(function);
-	// We just want to check if there IS an object, not actually throw an
-	// exception if we don't
-	// get it.
-	if (!
-	    ((object = seed_value_to_object(this_object, 0)) ||
-	     (object = seed_struct_get_pointer(this_object))))
-		instance_method = FALSE;
-
-	n_args = g_callable_info_get_n_args((GICallableInfo *) info);
-
-	in_args = g_new0(GArgument, n_args + 1);
-	out_args = 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);
-		dir = g_arg_info_get_direction(arg_info);
-		type_info = g_arg_info_get_type(arg_info);
-		if (i + 1 > argumentCount)
-		{
-			in_args[n_in_args++].v_pointer = 0;
-		}
-		else if (dir == GI_DIRECTION_IN || dir == GI_DIRECTION_INOUT)
-		{
-
-			if (!seed_gi_make_argument(arguments[i],
-						   type_info,
-						   &in_args[n_in_args++],
-						   exception))
-			{
-				gchar *mes =
-				    g_strdup_printf
-				    ("Unable to make argument %d for"
-				     " function: %s. \n",
-				     i + 1,
-				     g_base_info_get_name((GIBaseInfo *) info));
-				seed_make_exception(exception, "ArgumentError",
-						    mes);
-
-				g_free(mes);
-				g_base_info_unref((GIBaseInfo *) type_info);
-				g_base_info_unref((GIBaseInfo *) arg_info);
-				g_free(in_args);
-				g_free(out_args);
-
-				return JSValueMakeNull(eng->context);
-			}
-			if (dir == GI_DIRECTION_INOUT)
-				n_out_args++;
-
-		}
-		else if (dir == GI_DIRECTION_OUT)
-		{
-			n_out_args++;
-		}
+    GIBaseInfo *info;
+    GObject *object;
+    gboolean instance_method = TRUE;
+    GArgument retval;
+    GArgument *in_args;
+    GArgument *out_args;
+    gint n_args, n_in_args, n_out_args, i;
+    GIArgInfo *arg_info;
+    GITypeInfo *type_info;
+    GIDirection dir;
+    JSValueRef retval_ref;
+    GError *error = 0;
+
+    info = JSObjectGetPrivate(function);
+    // We just want to check if there IS an object, not actually throw an
+    // exception if we don't
+    // get it.
+    if (!
+	((object = seed_value_to_object(this_object, 0)) ||
+	 (object = seed_struct_get_pointer(this_object))))
+	instance_method = FALSE;
+
+    n_args = g_callable_info_get_n_args((GICallableInfo *) info);
+
+    in_args = g_new0(GArgument, n_args + 1);
+    out_args = 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);
+	dir = g_arg_info_get_direction(arg_info);
+	type_info = g_arg_info_get_type(arg_info);
+	if (i + 1 > argumentCount)
+	{
+	    in_args[n_in_args++].v_pointer = 0;
+	}
+	else if (dir == GI_DIRECTION_IN || dir == GI_DIRECTION_INOUT)
+	{
+
+	    if (!seed_gi_make_argument(arguments[i],
+				       type_info,
+				       &in_args[n_in_args++], exception))
+	    {
+		gchar *mes =
+		    g_strdup_printf
+		    ("Unable to make argument %d for" " function: %s. \n",
+		     i + 1,
+		     g_base_info_get_name((GIBaseInfo *) info));
+		seed_make_exception(exception, "ArgumentError", mes);
 
+		g_free(mes);
 		g_base_info_unref((GIBaseInfo *) type_info);
 		g_base_info_unref((GIBaseInfo *) arg_info);
-	}
-	if (g_function_info_invoke((GIFunctionInfo *) info,
-				   in_args,
-				   n_in_args,
-				   out_args, n_out_args, &retval, &error))
-	{
-		type_info = g_callable_info_get_return_type((GICallableInfo *)
-							    info);
-		if (g_type_info_get_tag(type_info) == GI_TYPE_TAG_VOID)
-			retval_ref = JSValueMakeNull(eng->context);
-		else
-			retval_ref =
-			    seed_gi_argument_make_js(&retval, type_info,
-						     exception);
-		g_base_info_unref((GIBaseInfo *) type_info);
-	}
-	else
-	{
-		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);
-
-		g_string_free(string, TRUE);
 		g_free(in_args);
 		g_free(out_args);
 
 		return JSValueMakeNull(eng->context);
+	    }
+	    if (dir == GI_DIRECTION_INOUT)
+		n_out_args++;
+
+	}
+	else if (dir == GI_DIRECTION_OUT)
+	{
+	    n_out_args++;
+	}
+
+	g_base_info_unref((GIBaseInfo *) type_info);
+	g_base_info_unref((GIBaseInfo *) arg_info);
+    }
+    if (g_function_info_invoke((GIFunctionInfo *) info,
+			       in_args,
+			       n_in_args,
+			       out_args, n_out_args, &retval, &error))
+    {
+	type_info = g_callable_info_get_return_type((GICallableInfo *) info);
+	if (g_type_info_get_tag(type_info) == GI_TYPE_TAG_VOID)
+	    retval_ref = JSValueMakeNull(eng->context);
+	else
+	    retval_ref =
+		seed_gi_argument_make_js(&retval, type_info, exception);
+	g_base_info_unref((GIBaseInfo *) type_info);
+    }
+    else
+    {
+	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);
 
+	g_string_free(string, TRUE);
 	g_free(in_args);
 	g_free(out_args);
-	return retval_ref;
+
+	return JSValueMakeNull(eng->context);
+    }
+
+    g_free(in_args);
+    g_free(out_args);
+    return retval_ref;
 }
 
 void
@@ -326,27 +320,27 @@
 						JSObjectRef object,
 						gboolean instance)
 {
-	GIFunctionInfoFlags flags;
-	SeedValue method_ref;
-	const gchar *name;
-
-	// if (g_base_info_is_deprecated ((GIBaseInfo *) info))
-	// g_printf("Not defining deprecated symbol: %s \n",
-	// g_base_info_get_name((GIBaseInfo *)info));
-
-	flags = g_function_info_get_flags(info);
-
-	if (instance && (flags & GI_FUNCTION_IS_CONSTRUCTOR))
-	{
-		return;
-	}
-
-	method_ref = JSObjectMake(eng->context, gobject_method_class, info);
-
-	name = g_base_info_get_name((GIBaseInfo *) info);
-	if (!strcmp(name, "new"))
-		name = "_new";
-	seed_value_set_property(object, name, method_ref);
+    GIFunctionInfoFlags flags;
+    SeedValue method_ref;
+    const gchar *name;
+
+    // if (g_base_info_is_deprecated ((GIBaseInfo *) info))
+    // g_printf("Not defining deprecated symbol: %s \n",
+    // g_base_info_get_name((GIBaseInfo *)info));
+
+    flags = g_function_info_get_flags(info);
+
+    if (instance && (flags & GI_FUNCTION_IS_CONSTRUCTOR))
+    {
+	return;
+    }
+
+    method_ref = JSObjectMake(eng->context, gobject_method_class, info);
+
+    name = g_base_info_get_name((GIBaseInfo *) info);
+    if (!strcmp(name, "new"))
+	name = "_new";
+    seed_value_set_property(object, name, method_ref);
 
 }
 
@@ -354,168 +348,162 @@
 seed_gobject_add_methods_for_interfaces(GIObjectInfo * oinfo,
 					JSObjectRef object)
 {
-	GIInterfaceInfo *interface;
-	gint n_interfaces, i;
-
-	n_interfaces = g_object_info_get_n_interfaces(oinfo);
+    GIInterfaceInfo *interface;
+    gint n_interfaces, i;
 
-	for (i = 0; i < n_interfaces; i++)
-	{
-		GIFunctionInfo *function;
-		gint n_functions, k;
-		interface = g_object_info_get_interface(oinfo, i);
+    n_interfaces = g_object_info_get_n_interfaces(oinfo);
 
-		n_functions = g_interface_info_get_n_methods(interface);
-		for (k = 0; k < n_functions; k++)
-		{
-			function = g_interface_info_get_method(interface, k);
-			seed_gobject_define_property_from_function_info
-			    (function, object, TRUE);
-		}
-		// g_base_info_unref((GIBaseInfo*)interface);
+    for (i = 0; i < n_interfaces; i++)
+    {
+	GIFunctionInfo *function;
+	gint n_functions, k;
+	interface = g_object_info_get_interface(oinfo, i);
+
+	n_functions = g_interface_info_get_n_methods(interface);
+	for (k = 0; k < n_functions; k++)
+	{
+	    function = g_interface_info_get_method(interface, k);
+	    seed_gobject_define_property_from_function_info
+		(function, object, TRUE);
 	}
+	// g_base_info_unref((GIBaseInfo*)interface);
+    }
 }
 
 static void
 seed_gobject_add_methods_for_type(GIObjectInfo * oinfo, JSObjectRef object)
 {
-	gint n_methods;
-	gint i;
-	GIFunctionInfo *info;
-
-	n_methods = g_object_info_get_n_methods(oinfo);
-
-	for (i = 0; i < n_methods; i++)
-	{
-		info = g_object_info_get_method(oinfo, i);
-		seed_gobject_define_property_from_function_info(info,
-								object, TRUE);
-	}
+    gint n_methods;
+    gint i;
+    GIFunctionInfo *info;
+
+    n_methods = g_object_info_get_n_methods(oinfo);
+
+    for (i = 0; i < n_methods; i++)
+    {
+	info = g_object_info_get_method(oinfo, i);
+	seed_gobject_define_property_from_function_info(info, object, TRUE);
+    }
 }
 
 JSClassRef seed_gobject_get_class_for_gtype(GType type)
 {
-	JSClassDefinition def;
-	GType parent;
-	JSClassRef ref;
-	JSClassRef parent_class = 0;
-	GIBaseInfo *info;
-	JSObjectRef prototype_obj;
-	JSObjectRef parent_prototype;
+    JSClassDefinition def;
+    GType parent;
+    JSClassRef ref;
+    JSClassRef parent_class = 0;
+    GIBaseInfo *info;
+    JSObjectRef prototype_obj;
+    JSObjectRef parent_prototype;
 
-	if ((ref = g_type_get_qdata(type, qname)) != NULL)
-	{
-		return ref;
-	}
-
-	info = g_irepository_find_by_gtype(g_irepository_get_default(), type);
-
-	memset(&def, 0, sizeof(JSClassDefinition));
-
-	def.className = g_type_name(type);
-	if ((parent = g_type_parent(type)))
-		parent_class = seed_gobject_get_class_for_gtype(parent);
-	def.parentClass = parent_class;
-	def.attributes = kJSClassAttributeNoAutomaticPrototype;
-
-	prototype_obj = JSObjectMake(eng->context, 0, 0);
-	if (parent)
-	{
-		parent_prototype = seed_gobject_get_prototype_for_gtype(parent);
-		if (parent_prototype)
-			JSObjectSetPrototype(eng->context,
-					     prototype_obj, parent_prototype);
-	}
+    if ((ref = g_type_get_qdata(type, qname)) != NULL)
+    {
+	return ref;
+    }
 
-	ref = JSClassCreate(&def);
-	JSClassRetain(ref);
+    info = g_irepository_find_by_gtype(g_irepository_get_default(), type);
 
-	JSValueProtect(eng->context, prototype_obj);
+    memset(&def, 0, sizeof(JSClassDefinition));
 
-	g_type_set_qdata(type, qname, ref);
-	g_type_set_qdata(type, qprototype, prototype_obj);
+    def.className = g_type_name(type);
+    if ((parent = g_type_parent(type)))
+	parent_class = seed_gobject_get_class_for_gtype(parent);
+    def.parentClass = parent_class;
+    def.attributes = kJSClassAttributeNoAutomaticPrototype;
+
+    prototype_obj = JSObjectMake(eng->context, 0, 0);
+    if (parent)
+    {
+	parent_prototype = seed_gobject_get_prototype_for_gtype(parent);
+	if (parent_prototype)
+	    JSObjectSetPrototype(eng->context, prototype_obj, parent_prototype);
+    }
+
+    ref = JSClassCreate(&def);
+    JSClassRetain(ref);
+
+    JSValueProtect(eng->context, prototype_obj);
+
+    g_type_set_qdata(type, qname, ref);
+    g_type_set_qdata(type, qprototype, prototype_obj);
+
+    if (info && (g_base_info_get_type(info) == GI_INFO_TYPE_OBJECT))
+    {
+	seed_gobject_add_methods_for_type((GIObjectInfo *) info, prototype_obj);
+	seed_gobject_add_methods_for_interfaces((GIObjectInfo *) info,
+						prototype_obj);
+    }
+    else
+    {
+	GType *interfaces;
+	GIFunctionInfo *function;
+	GIBaseInfo *interface;
+	gint n_functions, k, i, n;
 
-	if (info && (g_base_info_get_type(info) == GI_INFO_TYPE_OBJECT))
-	{
-		seed_gobject_add_methods_for_type((GIObjectInfo *) info,
-						  prototype_obj);
-		seed_gobject_add_methods_for_interfaces((GIObjectInfo *) info,
-							prototype_obj);
-	}
-	else
+	interfaces = g_type_interfaces(type, &n);
+	for (i = 0; i < n; i++)
 	{
-		GType *interfaces;
-		GIFunctionInfo *function;
-		GIBaseInfo *interface;
-		gint n_functions, k, i, n;
-
-		interfaces = g_type_interfaces(type, &n);
-		for (i = 0; i < n; i++)
-		{
-			interface =
-			    g_irepository_find_by_gtype(0, interfaces[i]);
-			if (!interface)
-				break;
-			n_functions =
-			    g_interface_info_get_n_methods((GIInterfaceInfo *)
-							   interface);
-			for (k = 0; k < n_functions; k++)
-			{
-				function =
-				    g_interface_info_get_method((GIInterfaceInfo
-								 *)
-								interface, k);
-				seed_gobject_define_property_from_function_info
-				    (function, prototype_obj, TRUE);
-			}
-		}
+	    interface = g_irepository_find_by_gtype(0, interfaces[i]);
+	    if (!interface)
+		break;
+	    n_functions =
+		g_interface_info_get_n_methods((GIInterfaceInfo *) interface);
+	    for (k = 0; k < n_functions; k++)
+	    {
+		function =
+		    g_interface_info_get_method((GIInterfaceInfo
+						 *) interface, k);
+		seed_gobject_define_property_from_function_info
+		    (function, prototype_obj, TRUE);
+	    }
 	}
+    }
 
-	return ref;
+    return ref;
 }
 
 JSObjectRef seed_gobject_get_prototype_for_gtype(GType type)
 {
-	JSObjectRef prototype = 0;
-	while (type && !prototype)
-	{
-		prototype = g_type_get_qdata(type, qprototype);
-		type = g_type_parent(type);
-	}
+    JSObjectRef prototype = 0;
+    while (type && !prototype)
+    {
+	prototype = g_type_get_qdata(type, qprototype);
+	type = g_type_parent(type);
+    }
 
-	return prototype;
+    return prototype;
 }
 
 static void seed_gobject_finalize(JSObjectRef object)
 {
-	GObject *gobject;
+    GObject *gobject;
 
-	gobject = seed_value_to_object((JSValueRef) object, 0);
-	if (!gobject)
-		return;
+    gobject = seed_value_to_object((JSValueRef) object, 0);
+    if (!gobject)
+	return;
 
-	g_object_remove_toggle_ref(gobject, seed_toggle_ref, 0);
-	g_object_unref(gobject);
+    g_object_remove_toggle_ref(gobject, seed_toggle_ref, 0);
+    g_object_unref(gobject);
 }
 
 static void seed_gobject_initialize(JSContextRef ctx, JSObjectRef object)
 {
-	GObject *gobject;
-	GIBaseInfo *base;
-
-	gobject = seed_value_to_object((JSValueRef) object, 0);
-	if (!gobject)
-		return;
+    GObject *gobject;
+    GIBaseInfo *base;
 
-	base = g_irepository_find_by_gtype(g_irepository_get_default(),
-					   G_OBJECT_TYPE(gobject));
-
-	seed_add_signals_to_object(object, gobject);
-	if (!base)
-	{
-		return;
-	}
-	g_assert(g_base_info_get_type(base) == GI_INFO_TYPE_OBJECT);
+    gobject = seed_value_to_object((JSValueRef) object, 0);
+    if (!gobject)
+	return;
+
+    base = g_irepository_find_by_gtype(g_irepository_get_default(),
+				       G_OBJECT_TYPE(gobject));
+
+    seed_add_signals_to_object(object, gobject);
+    if (!base)
+    {
+	return;
+    }
+    g_assert(g_base_info_get_type(base) == GI_INFO_TYPE_OBJECT);
 
 }
 
@@ -524,46 +512,45 @@
 			  JSObjectRef object,
 			  JSStringRef property_name, JSValueRef * exception)
 {
-	GParamSpec *spec;
-	GObject *b;
-	GValue gval = { 0 };
-	char *cproperty_name;
-	gint length;
-	SeedValue ret;
-	gint i, len;
-
-	b = seed_value_to_object((JSValueRef) object, exception);
-	if (!b)
-		return 0;
-
-	length = JSStringGetMaximumUTF8CStringSize(property_name);
-	cproperty_name = g_malloc(length * sizeof(gchar));
-	JSStringGetUTF8CString(property_name, cproperty_name, length);
-
-	spec = g_object_class_find_property(G_OBJECT_GET_CLASS(b),
-					    cproperty_name);
-
-	if (!spec)
+    GParamSpec *spec;
+    GObject *b;
+    GValue gval = { 0 };
+    char *cproperty_name;
+    gint length;
+    SeedValue ret;
+    gint i, len;
+
+    b = seed_value_to_object((JSValueRef) object, exception);
+    if (!b)
+	return 0;
+
+    length = JSStringGetMaximumUTF8CStringSize(property_name);
+    cproperty_name = g_malloc(length * sizeof(gchar));
+    JSStringGetUTF8CString(property_name, cproperty_name, length);
+
+    spec = g_object_class_find_property(G_OBJECT_GET_CLASS(b), cproperty_name);
+
+    if (!spec)
+    {
+	len = strlen(cproperty_name);
+	for (i = 0; i < len - 1; i++)
 	{
-		len = strlen(cproperty_name);
-		for (i = 0; i < len - 1; i++)
-		{
-			if (cproperty_name[i] == '_')
-				cproperty_name[i] = '-';
-		}
-		spec = g_object_class_find_property(G_OBJECT_GET_CLASS(b),
-						    cproperty_name);
-		g_free(cproperty_name);
-		return 0;
+	    if (cproperty_name[i] == '_')
+		cproperty_name[i] = '-';
 	}
+	spec = g_object_class_find_property(G_OBJECT_GET_CLASS(b),
+					    cproperty_name);
+	g_free(cproperty_name);
+	return 0;
+    }
 
-	g_value_init(&gval, spec->value_type);
-	g_object_get_property(b, cproperty_name, &gval);
-	ret = seed_value_from_gvalue(&gval, exception);
-	g_value_unset(&gval);
+    g_value_init(&gval, spec->value_type);
+    g_object_get_property(b, cproperty_name, &gval);
+    ret = seed_value_from_gvalue(&gval, exception);
+    g_value_unset(&gval);
 
-	g_free(cproperty_name);
-	return (JSValueRef) ret;
+    g_free(cproperty_name);
+    return (JSValueRef) ret;
 }
 
 static bool
@@ -572,70 +559,70 @@
 			  JSStringRef property_name,
 			  JSValueRef value, JSValueRef * exception)
 {
-	GParamSpec *spec = 0;
-	GObject *obj;
-	GValue gval = { 0 };
-	GType type;
-	gchar *cproperty_name;
-	gint length;
-
-	if (JSValueIsNull(eng->context, value))
-		return 0;
-
-	obj = seed_value_to_object(object, 0);
+    GParamSpec *spec = 0;
+    GObject *obj;
+    GValue gval = { 0 };
+    GType type;
+    gchar *cproperty_name;
+    gint length;
+
+    if (JSValueIsNull(eng->context, value))
+	return 0;
+
+    obj = seed_value_to_object(object, 0);
+
+    length = JSStringGetMaximumUTF8CStringSize(property_name);
+    cproperty_name = g_malloc(length * sizeof(gchar));
+    JSStringGetUTF8CString(property_name, cproperty_name, length);
 
-	length = JSStringGetMaximumUTF8CStringSize(property_name);
-	cproperty_name = g_malloc(length * sizeof(gchar));
-	JSStringGetUTF8CString(property_name, cproperty_name, length);
+    spec = g_object_class_find_property(G_OBJECT_GET_CLASS(obj),
+					cproperty_name);
 
+    if (!spec)
+    {
+	gint i, len;
+	len = strlen(cproperty_name);
+	for (i = 0; i < len; i++)
+	{
+	    if (cproperty_name[i] == '_')
+		cproperty_name[i] = '-';
+	}
 	spec = g_object_class_find_property(G_OBJECT_GET_CLASS(obj),
 					    cproperty_name);
-
 	if (!spec)
 	{
-		gint i, len;
-		len = strlen(cproperty_name);
-		for (i = 0; i < len; i++)
-		{
-			if (cproperty_name[i] == '_')
-				cproperty_name[i] = '-';
-		}
-		spec = g_object_class_find_property(G_OBJECT_GET_CLASS(obj),
-						    cproperty_name);
-		if (!spec)
-		{
-			g_free(cproperty_name);
-			return 0;
-		}
-	}
-
-	if (g_type_is_a(spec->value_type, G_TYPE_ENUM))
-		type = G_TYPE_INT;
-	else
-		type = spec->value_type;
-
-	seed_gvalue_from_seed_value(value, type, &gval, exception);
-	if (*exception)
-	{
-		g_free(cproperty_name);
-		return 0;
-	}
-
-	if (glib_message)
-	{
-		g_free(glib_message);
-		glib_message = 0;
+	    g_free(cproperty_name);
+	    return 0;
 	}
-	g_object_set_property(obj, cproperty_name, &gval);
-	if (glib_message != 0)
-	{
-		seed_make_exception(exception, "PropertyError", glib_message);
+    }
 
-		return FALSE;
-	}
+    if (g_type_is_a(spec->value_type, G_TYPE_ENUM))
+	type = G_TYPE_INT;
+    else
+	type = spec->value_type;
+
+    seed_gvalue_from_seed_value(value, type, &gval, exception);
+    if (*exception)
+    {
 	g_free(cproperty_name);
+	return 0;
+    }
+
+    if (glib_message)
+    {
+	g_free(glib_message);
+	glib_message = 0;
+    }
+    g_object_set_property(obj, cproperty_name, &gval);
+    if (glib_message != 0)
+    {
+	seed_make_exception(exception, "PropertyError", glib_message);
+
+	return FALSE;
+    }
+    g_free(cproperty_name);
 
-	return TRUE;
+    return TRUE;
 }
 
 static JSValueRef
@@ -645,326 +632,298 @@
 			 size_t argumentCount,
 			 const JSValueRef arguments[], JSValueRef * exception)
 {
-	GIBaseInfo *info;
-	const gchar *namespace;
-	const gchar *extension;
-	const gchar *version = 0;
-	JSObjectRef namespace_ref;
-	JSStringRef extension_script;
-	gint n, i;
+    GIBaseInfo *info;
+    const gchar *namespace;
+    const gchar *extension;
+    const gchar *version = 0;
+    JSObjectRef namespace_ref;
+    JSStringRef extension_script;
+    gint n, i;
+
+    if (argumentCount == 0)
+    {
+	seed_make_exception(exception,
+			    "ArgumentError",
+			    "Seed.import_namespace"
+			    " expected 1 or 2 arguments, got 0");
+	return JSValueMakeNull(eng->context);
+    }
 
-	if (argumentCount == 0)
+    namespace = seed_value_to_string(arguments[0], exception);
+    if (argumentCount == 2)
+    {
+	version = seed_value_to_string(arguments[1], exception);
+    }
+
+    if (!g_irepository_require(g_irepository_get_default(), namespace,
+			       version, 0, NULL))
+    {
+	gchar *mes;
+	if (!version)
 	{
-		seed_make_exception(exception,
-				    "ArgumentError",
-				    "Seed.import_namespace"
-				    " expected 1 or 2 arguments, got 0");
-		return JSValueMakeNull(eng->context);
+	    mes = g_strdup_printf("No such namespace: %s", namespace);
 	}
-
-	namespace = seed_value_to_string(arguments[0], exception);
-	if (argumentCount == 2)
+	else
 	{
-		version = seed_value_to_string(arguments[1], exception);
+	    mes =
+		g_strdup_printf
+		("No such namespace: %s (version %s)", namespace, version);
 	}
+	seed_make_exception(exception, "NamespaceError", mes);
+	return JSValueMakeNull(eng->context);
+    }
 
-	if (!g_irepository_require(g_irepository_get_default(), namespace,
-				   version, 0, NULL))
-	{
-		gchar *mes;
-		if (!version)
-		{
-			mes =
-			    g_strdup_printf("No such namespace: %s", namespace);
-		}
-		else
+    n = g_irepository_get_n_infos(g_irepository_get_default(), namespace);
+
+    namespace_ref = JSObjectMake(eng->context, NULL, NULL);
+    JSValueProtect(eng->context, namespace_ref);
+    seed_value_set_property(eng->global, namespace, namespace_ref);
+
+    for (i = 0; i < n; i++)
+    {
+	info = g_irepository_get_info(g_irepository_get_default(),
+				      namespace, i);
+	if (info && (g_base_info_get_type(info) == GI_INFO_TYPE_FUNCTION))
+	{
+	    seed_gobject_define_property_from_function_info((GIFunctionInfo *)
+							    info, namespace_ref,
+							    FALSE);
+	}
+	else if (info
+		 && (g_base_info_get_type(info) == GI_INFO_TYPE_ENUM
+		     || g_base_info_get_type(info) == GI_INFO_TYPE_FLAGS))
+	{
+	    gint num_vals = g_enum_info_get_n_values((GIEnumInfo *) info);
+	    gint j;
+	    JSObjectRef enum_class = JSObjectMake(eng->context,
+						  0, 0);
+	    JSValueProtect(eng->context, (JSValueRef) enum_class);
+	    seed_value_set_property(namespace_ref,
+				    g_base_info_get_name(info), enum_class);
+
+	    for (j = 0; j < num_vals; j++)
+	    {
+		GIValueInfo *val =
+		    g_enum_info_get_value((GIEnumInfo *) info, j);
+		gint value = g_value_info_get_value(val);
+		gchar *name =
+		    g_strdup(g_base_info_get_name((GIBaseInfo *) val));
+		gint name_len = strlen(name);
+		gint j;
+		JSValueRef value_ref;
+
+		value_ref = JSValueMakeNumber(eng->context, value);
+		JSValueProtect(eng->context, (JSValueRef) value_ref);
+
+		for (j = 0; j < name_len; j++)
 		{
-			mes =
-			    g_strdup_printf
-			    ("No such namespace: %s (version %s)", namespace,
-			     version);
+		    if (name[j] == '-')
+			name[j] = '_';
 		}
-		seed_make_exception(exception, "NamespaceError", mes);
-		return JSValueMakeNull(eng->context);
-	}
 
-	n = g_irepository_get_n_infos(g_irepository_get_default(), namespace);
+		seed_value_set_property(enum_class, name, value_ref);
 
-	namespace_ref = JSObjectMake(eng->context, NULL, NULL);
-	JSValueProtect(eng->context, namespace_ref);
-	seed_value_set_property(eng->global, namespace, namespace_ref);
+		g_free(name);
 
-	for (i = 0; i < n; i++)
+	    }
+	}
+	else if (info && (g_base_info_get_type(info) == GI_INFO_TYPE_OBJECT))
 	{
-		info = g_irepository_get_info(g_irepository_get_default(),
-					      namespace, i);
-		if (info
-		    && (g_base_info_get_type(info) == GI_INFO_TYPE_FUNCTION))
+	    GType type;
+	    JSClassRef class_ref;
+
+	    type =
+		g_registered_type_info_get_g_type((GIRegisteredTypeInfo *)
+						  info);
+
+	    if (type != 0)
+	    {
+		JSObjectRef constructor_ref;
+		gint i, n_methods;
+		GIFunctionInfo *finfo;
+		GIFunctionInfoFlags flags;
+
+		class_ref = seed_gobject_get_class_for_gtype(type);
+
+		constructor_ref =
+		    JSObjectMake(eng->context,
+				 gobject_constructor_class, (gpointer) type);
+
+		n_methods = g_object_info_get_n_methods((GIObjectInfo *) info);
+		for (i = 0; i < n_methods; i++)
 		{
-			seed_gobject_define_property_from_function_info((GIFunctionInfo *) info, namespace_ref, FALSE);
+		    finfo = g_object_info_get_method((GIObjectInfo *) info, i);
+		    flags = g_function_info_get_flags(finfo);
+		    if (flags & GI_FUNCTION_IS_CONSTRUCTOR)
+		    {
+			seed_gobject_define_property_from_function_info
+			    (finfo, constructor_ref, FALSE);
+		    }
+		    else
+		    {
+			g_base_info_unref((GIBaseInfo *) finfo);
+		    }
 		}
-		else if (info
-			 && (g_base_info_get_type(info) == GI_INFO_TYPE_ENUM
-			     || g_base_info_get_type(info) ==
-			     GI_INFO_TYPE_FLAGS))
-		{
-			gint num_vals =
-			    g_enum_info_get_n_values((GIEnumInfo *) info);
-			gint j;
-			JSObjectRef enum_class = JSObjectMake(eng->context,
-							      0, 0);
-			JSValueProtect(eng->context, (JSValueRef) enum_class);
-			seed_value_set_property(namespace_ref,
-						g_base_info_get_name(info),
-						enum_class);
-
-			for (j = 0; j < num_vals; j++)
-			{
-				GIValueInfo *val =
-				    g_enum_info_get_value((GIEnumInfo *)
-							  info, j);
-				gint value = g_value_info_get_value(val);
-				gchar *name =
-				    g_strdup(g_base_info_get_name
-					     ((GIBaseInfo *) val));
-				gint name_len = strlen(name);
-				gint j;
-				JSValueRef value_ref;
-
-				value_ref =
-				    JSValueMakeNumber(eng->context, value);
-				JSValueProtect(eng->context,
-					       (JSValueRef) value_ref);
-
-				for (j = 0; j < name_len; j++)
-				{
-					if (name[j] == '-')
-						name[j] = '_';
-				}
 
-				seed_value_set_property(enum_class, name,
-							value_ref);
+		seed_value_set_property(namespace_ref,
+					g_base_info_get_name
+					(info), constructor_ref);
+		JSValueProtect(eng->context, (JSValueRef) constructor_ref);
+	    }
+	}
+	else if (info && (g_base_info_get_type(info) == GI_INFO_TYPE_STRUCT))
+	{
+	    JSObjectRef struct_ref;
+	    gint i, n_methods;
+	    GIFunctionInfo *finfo;
 
-				g_free(name);
+	    struct_ref = JSObjectMake(eng->context, 0, 0);
 
-			}
-		}
-		else if (info &&
-			 (g_base_info_get_type(info) == GI_INFO_TYPE_OBJECT))
-		{
-			GType type;
-			JSClassRef class_ref;
+	    n_methods = g_struct_info_get_n_methods((GIStructInfo *) info);
 
-			type =
-			    g_registered_type_info_get_g_type((GIRegisteredTypeInfo *) info);
+	    for (i = 0; i < n_methods; i++)
+	    {
+		finfo = g_struct_info_get_method((GIStructInfo *) info, i);
+		seed_gobject_define_property_from_function_info
+		    (finfo, struct_ref, FALSE);
 
-			if (type != 0)
-			{
-				JSObjectRef constructor_ref;
-				gint i, n_methods;
-				GIFunctionInfo *finfo;
-				GIFunctionInfoFlags flags;
-
-				class_ref =
-				    seed_gobject_get_class_for_gtype(type);
-
-				constructor_ref =
-				    JSObjectMake(eng->context,
-						 gobject_constructor_class,
-						 (gpointer) type);
-
-				n_methods =
-				    g_object_info_get_n_methods((GIObjectInfo *)
-								info);
-				for (i = 0; i < n_methods; i++)
-				{
-					finfo =
-					    g_object_info_get_method((GIObjectInfo *) info, i);
-					flags =
-					    g_function_info_get_flags(finfo);
-					if (flags & GI_FUNCTION_IS_CONSTRUCTOR)
-					{
-						seed_gobject_define_property_from_function_info
-						    (finfo, constructor_ref,
-						     FALSE);
-					}
-					else
-					{
-						g_base_info_unref((GIBaseInfo *)
-								  finfo);
-					}
-				}
-
-				seed_value_set_property(namespace_ref,
-							g_base_info_get_name
-							(info),
-							constructor_ref);
-				JSValueProtect(eng->context,
-					       (JSValueRef) constructor_ref);
-			}
-		}
-		else if (info &&
-			 (g_base_info_get_type(info) == GI_INFO_TYPE_STRUCT))
-		{
-			JSObjectRef struct_ref;
-			gint i, n_methods;
-			GIFunctionInfo *finfo;
-
-			struct_ref = JSObjectMake(eng->context, 0, 0);
-
-			n_methods =
-			    g_struct_info_get_n_methods((GIStructInfo *) info);
-
-			for (i = 0; i < n_methods; i++)
-			{
-				finfo =
-				    g_struct_info_get_method((GIStructInfo *)
-							     info, i);
-				seed_gobject_define_property_from_function_info
-				    (finfo, struct_ref, FALSE);
-
-			}
-
-			seed_value_set_property(namespace_ref,
-						g_base_info_get_name(info),
-						struct_ref);
+	    }
 
-			JSValueProtect(eng->context, (JSValueRef) struct_ref);
-		}
-		else if (info &&
-			 (g_base_info_get_type(info) == GI_INFO_TYPE_CALLBACK))
-		{
-			JSObjectRef callback_ref = JSObjectMake(eng->context,
-								seed_callback_class,
-								info);
-			seed_value_set_property(namespace_ref,
-						g_base_info_get_name(info),
-						(JSValueRef) callback_ref);
-		}
-		else if (info &&
-			 (g_base_info_get_type(info) == GI_INFO_TYPE_CONSTANT))
-		{
-			GArgument argument;
-			JSValueRef constant_value;
+	    seed_value_set_property(namespace_ref,
+				    g_base_info_get_name(info), struct_ref);
 
-			g_constant_info_get_value((GIConstantInfo *) info,
-						  &argument);
-			constant_value =
-			    seed_gi_argument_make_js(&argument,
-						     g_constant_info_get_type((GIConstantInfo *) info), exception);
-			seed_value_set_property(namespace_ref,
-						g_base_info_get_name(info),
-						constant_value);
+	    JSValueProtect(eng->context, (JSValueRef) struct_ref);
+	}
+	else if (info && (g_base_info_get_type(info) == GI_INFO_TYPE_CALLBACK))
+	{
+	    JSObjectRef callback_ref = JSObjectMake(eng->context,
+						    seed_callback_class,
+						    info);
+	    seed_value_set_property(namespace_ref,
+				    g_base_info_get_name(info),
+				    (JSValueRef) callback_ref);
+	}
+	else if (info && (g_base_info_get_type(info) == GI_INFO_TYPE_CONSTANT))
+	{
+	    GArgument argument;
+	    JSValueRef constant_value;
 
-		}
+	    g_constant_info_get_value((GIConstantInfo *) info, &argument);
+	    constant_value =
+		seed_gi_argument_make_js(&argument,
+					 g_constant_info_get_type((GIConstantInfo *) info), exception);
+	    seed_value_set_property(namespace_ref,
+				    g_base_info_get_name(info), constant_value);
 
 	}
 
-	extension =
-	    g_strdup_printf("Seed.include(\"/usr/local/share/seed/%s.js\")",
-			    namespace);
-	extension_script = JSStringCreateWithUTF8CString(extension);
-	JSEvaluateScript(eng->context, extension_script, NULL, NULL, 0, NULL);
-	JSStringRelease(extension_script);
+    }
 
-	g_free((gchar *) namespace);
+    extension =
+	g_strdup_printf("Seed.include(\"/usr/local/share/seed/%s.js\")",
+			namespace);
+    extension_script = JSStringCreateWithUTF8CString(extension);
+    JSEvaluateScript(eng->context, extension_script, NULL, NULL, 0, NULL);
+    JSStringRelease(extension_script);
 
-	return JSValueMakeNull(eng->context);
+    g_free((gchar *) namespace);
+
+    return JSValueMakeNull(eng->context);
 }
 
 JSStaticFunction gobject_static_funcs[] = {
-	{"equals", seed_gobject_equals, 0}
-	,
-	{0, 0, 0}
+    {"equals", seed_gobject_equals, 0}
+    ,
+    {0, 0, 0}
 };
 
 JSClassDefinition gobject_def = {
-	0,			/* Version, always 0 */
-	kJSClassAttributeNoAutomaticPrototype,	/* JSClassAttributes */
-	"gobject",		/* Class Name */
-	NULL,			/* Parent Class */
-	NULL,			/* Static Values */
-	gobject_static_funcs,	/* Static Functions */
-	seed_gobject_initialize,	/* Initialize */
-	seed_gobject_finalize,	/* Finalize */
-	NULL,			/* Has Property */
-	seed_gobject_get_property,	/* Get Property */
-	seed_gobject_set_property,	/* Set Property */
-	NULL,			/* Delete Property */
-	NULL,			/* Get Property Names */
-	NULL,			/* Call As Function */
-	NULL,			/* Call As Constructor */
-	NULL,			/* Has Instance */
-	NULL			/* Convert To Type */
+    0,				/* Version, always 0 */
+    kJSClassAttributeNoAutomaticPrototype,	/* JSClassAttributes */
+    "gobject",			/* Class Name */
+    NULL,			/* Parent Class */
+    NULL,			/* Static Values */
+    gobject_static_funcs,	/* Static Functions */
+    seed_gobject_initialize,	/* Initialize */
+    seed_gobject_finalize,	/* Finalize */
+    NULL,			/* Has Property */
+    seed_gobject_get_property,	/* Get Property */
+    seed_gobject_set_property,	/* Set Property */
+    NULL,			/* Delete Property */
+    NULL,			/* Get Property Names */
+    NULL,			/* Call As Function */
+    NULL,			/* Call As Constructor */
+    NULL,			/* Has Instance */
+    NULL			/* Convert To Type */
 };
 
 JSClassDefinition gobject_method_def = {
-	0,			/* Version, always 0 */
-	0,
-	"gobject_method",	/* Class Name */
-	NULL,			/* Parent Class */
-	NULL,			/* Static Values */
-	NULL,			/* Static Functions */
-	NULL,
-	NULL,			/* Finalize */
-	NULL,			/* Has Property */
-	NULL,			/* Get Property */
-	NULL,			/* Set Property */
-	NULL,			/* Delete Property */
-	NULL,			/* Get Property Names */
-	seed_gobject_method_invoked,	/* Call As Function */
-	NULL,			/* Call As Constructor */
-	NULL,			/* Has Instance */
-	NULL			/* Convert To Type */
+    0,				/* Version, always 0 */
+    0,
+    "gobject_method",		/* Class Name */
+    NULL,			/* Parent Class */
+    NULL,			/* Static Values */
+    NULL,			/* Static Functions */
+    NULL,
+    NULL,			/* Finalize */
+    NULL,			/* Has Property */
+    NULL,			/* Get Property */
+    NULL,			/* Set Property */
+    NULL,			/* Delete Property */
+    NULL,			/* Get Property Names */
+    seed_gobject_method_invoked,	/* Call As Function */
+    NULL,			/* Call As Constructor */
+    NULL,			/* Has Instance */
+    NULL			/* Convert To Type */
 };
 
 JSClassDefinition seed_callback_def = {
-	0,			/* Version, always 0 */
-	0,
-	"seed_callback",	/* Class Name */
-	NULL,			/* Parent Class */
-	NULL,			/* Static Values */
-	NULL,			/* Static Functions */
-	NULL,
-	NULL,			/* Finalize */
-	NULL,			/* Has Property */
-	NULL,			/* Get Property */
-	NULL,			/* Set Property */
-	NULL,			/* Delete Property */
-	NULL,			/* Get Property Names */
-	NULL,			/* Call As Function */
-	NULL,			/* Call As Constructor */
-	NULL,			/* Has Instance */
-	NULL			/* Convert To Type */
+    0,				/* Version, always 0 */
+    0,
+    "seed_callback",		/* Class Name */
+    NULL,			/* Parent Class */
+    NULL,			/* Static Values */
+    NULL,			/* Static Functions */
+    NULL,
+    NULL,			/* Finalize */
+    NULL,			/* Has Property */
+    NULL,			/* Get Property */
+    NULL,			/* Set Property */
+    NULL,			/* Delete Property */
+    NULL,			/* Get Property Names */
+    NULL,			/* Call As Function */
+    NULL,			/* Call As Constructor */
+    NULL,			/* Has Instance */
+    NULL			/* Convert To Type */
 };
 
 JSClassDefinition gobject_constructor_def = {
-	0,			/* Version, always 0 */
-	0,
-	"gobject_constructor",	/* Class Name */
-	NULL,			/* Parent Class */
-	NULL,			/* Static Values */
-	NULL,			/* Static Functions */
-	NULL,
-	NULL,			/* Finalize */
-	NULL,			/* Has Property */
-	NULL,			/* Get Property */
-	NULL,			/* Set Property */
-	NULL,			/* Delete Property */
-	NULL,			/* Get Property Names */
-	NULL,			/* Call As Function */
-	seed_gobject_constructor_invoked,	/* Call As Constructor */
-	NULL,			/* Has Instance */
-	NULL			/* Convert To Type */
+    0,				/* Version, always 0 */
+    0,
+    "gobject_constructor",	/* Class Name */
+    NULL,			/* Parent Class */
+    NULL,			/* Static Values */
+    NULL,			/* Static Functions */
+    NULL,
+    NULL,			/* Finalize */
+    NULL,			/* Has Property */
+    NULL,			/* Get Property */
+    NULL,			/* Set Property */
+    NULL,			/* Delete Property */
+    NULL,			/* Get Property Names */
+    NULL,			/* Call As Function */
+    seed_gobject_constructor_invoked,	/* Call As Constructor */
+    NULL,			/* Has Instance */
+    NULL			/* Convert To Type */
 };
 
 void seed_create_function(gchar * name, gpointer func, JSObjectRef obj)
 {
-	JSObjectRef oref;
+    JSObjectRef oref;
 
-	oref = JSObjectMakeFunctionWithCallback(eng->context, NULL, func);
-	JSValueProtect(eng->context, oref);
-	seed_value_set_property(obj, name, oref);
+    oref = JSObjectMakeFunctionWithCallback(eng->context, NULL, func);
+    JSValueProtect(eng->context, oref);
+    seed_value_set_property(obj, name, oref);
 }
 
 static void
@@ -972,133 +931,132 @@
 		 GLogLevelFlags log_level,
 		 const gchar * message, gpointer user_data)
 {
-	glib_message = g_strdup(message);
+    glib_message = g_strdup(message);
 }
 
 gboolean seed_init(gint * argc, gchar *** argv)
 {
-	JSObjectRef seed_obj_ref;
-	JSStringRef defaults_script;
+    JSObjectRef seed_obj_ref;
+    JSStringRef defaults_script;
+
+    g_type_init();
+    g_log_set_handler("GLib-GObject", G_LOG_LEVEL_WARNING, seed_log_handler, 0);
+
+    qname = g_quark_from_static_string("js-type");
+    qprototype = g_quark_from_static_string("js-prototype");
 
-	g_type_init();
-	g_log_set_handler("GLib-GObject", G_LOG_LEVEL_WARNING,
-			  seed_log_handler, 0);
-
-	qname = g_quark_from_static_string("js-type");
-	qprototype = g_quark_from_static_string("js-prototype");
-
-	eng = (SeedEngine *) g_malloc(sizeof(SeedEngine));
-
-	eng->context = JSGlobalContextCreateInGroup(NULL, NULL);
-	eng->global = JSContextGetGlobalObject(eng->context);
-	gobject_class = JSClassCreate(&gobject_def);
-	JSClassRetain(gobject_class);
-	gobject_method_class = JSClassCreate(&gobject_method_def);
-	JSClassRetain(gobject_method_class);
-	gobject_constructor_class = JSClassCreate(&gobject_constructor_def);
-	JSClassRetain(gobject_constructor_class);
-	gobject_signal_class = JSClassCreate(seed_get_signal_class());
-	JSClassRetain(gobject_signal_class);
-	seed_callback_class = JSClassCreate(&seed_callback_def);
-	JSClassRetain(seed_callback_class);
-
-	g_type_set_qdata(G_TYPE_OBJECT, qname, gobject_class);
-
-	seed_obj_ref = JSObjectMake(eng->context, NULL, NULL);
-	seed_value_set_property(eng->global, "Seed", seed_obj_ref);
-	JSValueProtect(eng->context, seed_obj_ref);
-
-	seed_create_function("import_namespace", &seed_gi_import_namespace,
-			     seed_obj_ref);
-	seed_init_builtins(argc, argv);
-	seed_closures_init();
-
-	seed_gtype_init();
-
-	defaults_script =
-	    JSStringCreateWithUTF8CString("Seed.include(\"/usr/local/share"
-					  "/seed/Seed.js\")");
-	JSEvaluateScript(eng->context, defaults_script, NULL, NULL, 0, NULL);
-	JSStringRelease(defaults_script);
+    eng = (SeedEngine *) g_malloc(sizeof(SeedEngine));
+
+    eng->context = JSGlobalContextCreateInGroup(NULL, NULL);
+    eng->global = JSContextGetGlobalObject(eng->context);
+    gobject_class = JSClassCreate(&gobject_def);
+    JSClassRetain(gobject_class);
+    gobject_method_class = JSClassCreate(&gobject_method_def);
+    JSClassRetain(gobject_method_class);
+    gobject_constructor_class = JSClassCreate(&gobject_constructor_def);
+    JSClassRetain(gobject_constructor_class);
+    gobject_signal_class = JSClassCreate(seed_get_signal_class());
+    JSClassRetain(gobject_signal_class);
+    seed_callback_class = JSClassCreate(&seed_callback_def);
+    JSClassRetain(seed_callback_class);
+
+    g_type_set_qdata(G_TYPE_OBJECT, qname, gobject_class);
+
+    seed_obj_ref = JSObjectMake(eng->context, NULL, NULL);
+    seed_value_set_property(eng->global, "Seed", seed_obj_ref);
+    JSValueProtect(eng->context, seed_obj_ref);
+
+    seed_create_function("import_namespace", &seed_gi_import_namespace,
+			 seed_obj_ref);
+    seed_init_builtins(argc, argv);
+    seed_closures_init();
+
+    seed_gtype_init();
+
+    defaults_script =
+	JSStringCreateWithUTF8CString("Seed.include(\"/usr/local/share"
+				      "/seed/Seed.js\")");
+    JSEvaluateScript(eng->context, defaults_script, NULL, NULL, 0, NULL);
+    JSStringRelease(defaults_script);
 
-	return TRUE;
+    return TRUE;
 
 }
 
 SeedScript *seed_make_script(const gchar * js, const gchar * source_url,
 			     gint line_number)
 {
-	SeedScript *ret = g_new0(SeedScript, 1);
+    SeedScript *ret = g_new0(SeedScript, 1);
 
-	ret->script = JSStringCreateWithUTF8CString(js);
+    ret->script = JSStringCreateWithUTF8CString(js);
 
-	if (source_url)
-	{
-		ret->source_url = JSStringCreateWithUTF8CString(source_url);
-	}
-	ret->line_number = line_number;
+    if (source_url)
+    {
+	ret->source_url = JSStringCreateWithUTF8CString(source_url);
+    }
+    ret->line_number = line_number;
 
-	JSCheckScriptSyntax(eng->context, ret->script,
-			    ret->source_url, ret->line_number, &ret->exception);
+    JSCheckScriptSyntax(eng->context, ret->script,
+			ret->source_url, ret->line_number, &ret->exception);
 
-	return ret;
+    return ret;
 }
 
 JSValueRef seed_evaluate(SeedScript * js, JSObjectRef this)
 {
-	JSValueRef ret;
+    JSValueRef ret;
 
-	js->exception = 0;
-	ret = JSEvaluateScript(eng->context,
-			       js->script, this, js->source_url,
-			       js->line_number, &js->exception);
+    js->exception = 0;
+    ret = JSEvaluateScript(eng->context,
+			   js->script, this, js->source_url,
+			   js->line_number, &js->exception);
 
-	return ret;
+    return ret;
 }
 
 SeedValue seed_script_exception(SeedScript * s)
 {
-	return s->exception;
+    return s->exception;
 }
 
 gchar *seed_exception_get_name(JSValueRef e)
 {
-	SeedValue name;
-	g_assert((e));
-	if (!JSValueIsObject(eng->context, e))
-		return 0;
+    SeedValue name;
+    g_assert((e));
+    if (!JSValueIsObject(eng->context, e))
+	return 0;
 
-	name = seed_value_get_property(e, "name");
-	return seed_value_to_string(name, 0);
+    name = seed_value_get_property(e, "name");
+    return seed_value_to_string(name, 0);
 }
 
 gchar *seed_exception_get_message(JSValueRef e)
 {
-	SeedValue name;
-	g_assert((e));
-	if (!JSValueIsObject(eng->context, e))
-		return 0;
+    SeedValue name;
+    g_assert((e));
+    if (!JSValueIsObject(eng->context, e))
+	return 0;
 
-	name = seed_value_get_property(e, "message");
-	return seed_value_to_string(name, 0);
+    name = seed_value_get_property(e, "message");
+    return seed_value_to_string(name, 0);
 }
 
 guint seed_exception_get_line(JSValueRef e)
 {
-	SeedValue line;
-	g_assert((e));
-	if (!JSValueIsObject(eng->context, e))
-		return 0;
-	line = seed_value_get_property(e, "line");
-	return seed_value_to_uint(line, 0);
+    SeedValue line;
+    g_assert((e));
+    if (!JSValueIsObject(eng->context, e))
+	return 0;
+    line = seed_value_get_property(e, "line");
+    return seed_value_to_uint(line, 0);
 }
 
 gchar *seed_exception_get_file(JSValueRef e)
 {
-	SeedValue file;
-	g_assert((e));
-	if (!JSValueIsObject(eng->context, e))
-		return 0;
-	file = seed_value_get_property(e, "sourceURL");
-	return seed_value_to_string(file, 0);
+    SeedValue file;
+    g_assert((e));
+    if (!JSValueIsObject(eng->context, e))
+	return 0;
+    file = seed_value_get_property(e, "sourceURL");
+    return seed_value_to_string(file, 0);
 }

Modified: trunk/libseed/seed-engine.h
==============================================================================
--- trunk/libseed/seed-engine.h	(original)
+++ trunk/libseed/seed-engine.h	Sat Nov  8 01:42:29 2008
@@ -31,11 +31,11 @@
 extern SeedEngine *eng;
 
 typedef struct _SeedScript {
-	JSStringRef script;
-	JSValueRef exception;
+    JSStringRef script;
+    JSValueRef exception;
 
-	JSStringRef source_url;
-	gint line_number;
+    JSStringRef source_url;
+    gint line_number;
 } SeedScript;
 
 JSObjectRef seed_gobject_get_prototype_for_gtype(GType type);

Modified: trunk/libseed/seed-gtype.c
==============================================================================
--- trunk/libseed/seed-gtype.c	(original)
+++ trunk/libseed/seed-gtype.c	Sat Nov  8 01:42:29 2008
@@ -28,83 +28,80 @@
 seed_handle_class_init_closure(ffi_cif * cif,
 			       void *result, void **args, void *userdata)
 {
-	JSObjectRef function = (JSObjectRef) userdata;
-	JSValueRef jsargs[2];
-	GType type;
-
-	type = (GType) JSObjectGetPrivate(*(JSObjectRef *) args[1]);
-	jsargs[0] = seed_make_struct(*(gpointer *) args[0], 0);
-	jsargs[1] = seed_gobject_get_prototype_for_gtype(type);
+    JSObjectRef function = (JSObjectRef) userdata;
+    JSValueRef jsargs[2];
+    GType type;
+
+    type = (GType) JSObjectGetPrivate(*(JSObjectRef *) args[1]);
+    jsargs[0] = seed_make_struct(*(gpointer *) args[0], 0);
+    jsargs[1] = seed_gobject_get_prototype_for_gtype(type);
 
-	JSObjectCallAsFunction(eng->context, function, 0, 2, jsargs, 0);
+    JSObjectCallAsFunction(eng->context, function, 0, 2, jsargs, 0);
 }
 
 static void
 seed_handle_instance_init_closure(ffi_cif * cif,
 				  void *result, void **args, void *userdata)
 {
-	JSObjectRef function = (JSObjectRef) userdata;
-	JSValueRef jsargs;
-	JSObjectRef this_object;
-
-	jsargs = seed_make_struct(*(gpointer *) args[1], 0);
-	this_object =
-	    (JSObjectRef) seed_value_from_object(*(GObject **) args[0], 0);
+    JSObjectRef function = (JSObjectRef) userdata;
+    JSValueRef jsargs;
+    JSObjectRef this_object;
+
+    jsargs = seed_make_struct(*(gpointer *) args[1], 0);
+    this_object =
+	(JSObjectRef) seed_value_from_object(*(GObject **) args[0], 0);
 
-	JSObjectCallAsFunction(eng->context,
-			       function, this_object, 1, &jsargs, 0);
+    JSObjectCallAsFunction(eng->context, function, this_object, 1, &jsargs, 0);
 }
 
 static ffi_closure *seed_make_class_init_closure(JSObjectRef function)
 {
-	ffi_cif *cif;
-	ffi_closure *closure;
-	ffi_type **arg_types;;
-	ffi_arg result;
-	ffi_status status;
-
-	JSValueProtect(eng->context, function);
-
-	cif = g_new0(ffi_cif, 1);
-	arg_types = g_new0(ffi_type *, 3);
-
-	arg_types[0] = &ffi_type_pointer;
-	arg_types[1] = &ffi_type_uint;
-	arg_types[2] = 0;
-
-	closure = mmap(0, sizeof(ffi_closure), PROT_READ | PROT_WRITE |
-		       PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
-
-	ffi_prep_cif(cif, FFI_DEFAULT_ABI, 2, &ffi_type_void, arg_types);
-	ffi_prep_closure(closure, cif, seed_handle_class_init_closure,
-			 function);
-	return closure;
+    ffi_cif *cif;
+    ffi_closure *closure;
+    ffi_type **arg_types;;
+    ffi_arg result;
+    ffi_status status;
+
+    JSValueProtect(eng->context, function);
+
+    cif = g_new0(ffi_cif, 1);
+    arg_types = g_new0(ffi_type *, 3);
+
+    arg_types[0] = &ffi_type_pointer;
+    arg_types[1] = &ffi_type_uint;
+    arg_types[2] = 0;
+
+    closure = mmap(0, sizeof(ffi_closure), PROT_READ | PROT_WRITE |
+		   PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
+
+    ffi_prep_cif(cif, FFI_DEFAULT_ABI, 2, &ffi_type_void, arg_types);
+    ffi_prep_closure(closure, cif, seed_handle_class_init_closure, function);
+    return closure;
 }
 
 static ffi_closure *seed_make_instance_init_closure(JSObjectRef function)
 {
-	ffi_cif *cif;
-	ffi_closure *closure;
-	ffi_type **arg_types;;
-	ffi_arg result;
-	ffi_status status;
-
-	JSValueProtect(eng->context, function);
-
-	cif = g_new0(ffi_cif, 1);
-	arg_types = g_new0(ffi_type *, 3);
-
-	arg_types[0] = &ffi_type_pointer;
-	arg_types[1] = &ffi_type_pointer;
-	arg_types[2] = 0;
-
-	closure = mmap(0, sizeof(ffi_closure), PROT_READ | PROT_WRITE |
-		       PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
-
-	ffi_prep_cif(cif, FFI_DEFAULT_ABI, 2, &ffi_type_void, arg_types);
-	ffi_prep_closure(closure, cif, seed_handle_instance_init_closure,
-			 function);
-	return closure;
+    ffi_cif *cif;
+    ffi_closure *closure;
+    ffi_type **arg_types;;
+    ffi_arg result;
+    ffi_status status;
+
+    JSValueProtect(eng->context, function);
+
+    cif = g_new0(ffi_cif, 1);
+    arg_types = g_new0(ffi_type *, 3);
+
+    arg_types[0] = &ffi_type_pointer;
+    arg_types[1] = &ffi_type_pointer;
+    arg_types[2] = 0;
+
+    closure = mmap(0, sizeof(ffi_closure), PROT_READ | PROT_WRITE |
+		   PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
+
+    ffi_prep_cif(cif, FFI_DEFAULT_ABI, 2, &ffi_type_void, arg_types);
+    ffi_prep_closure(closure, cif, seed_handle_instance_init_closure, function);
+    return closure;
 }
 
 static JSObjectRef
@@ -114,103 +111,101 @@
 			       const JSValueRef arguments[],
 			       JSValueRef * exception)
 {
-	JSValueRef class_init, instance_init, name, parent_ref;
-	GType parent_type, new_type;
-	gchar *new_name;
-	GTypeInfo type_info = {
-		0,
-		(GBaseInitFunc) NULL,
-		(GBaseFinalizeFunc) NULL,
-		(GClassInitFunc) NULL,
-		(GClassFinalizeFunc) NULL,
-		NULL,
-		0,
-		0,
-		NULL
-	};
-	ffi_closure *init_closure = 0;
-	ffi_closure *instance_init_closure = 0;
-	GTypeQuery query;
-	JSObjectRef constructor_ref;
-
-	if (argumentCount != 1)
-	{
-		gchar *mes =
-		    g_strdup_printf("GType constructor expected 1 "
-				    "argument, got %d \n",
-				    argumentCount);
-		seed_make_exception(exception, "ArgumentError", mes);
-		g_free(mes);
-		return (JSObjectRef) JSValueMakeNull(eng->context);
-	}
-	if (!JSValueIsObject(eng->context, arguments[0]))
-	{
-		seed_make_exception(exception, "ArgumentError",
-				    "GType constructor expected a"
-				    "class definition object. Got a nonobject");
-	}
-	parent_ref = seed_value_get_property(arguments[0], "parent");
-	class_init = seed_value_get_property(arguments[0], "class_init");
-	instance_init = seed_value_get_property(arguments[0], "instance_init");
-	name = seed_value_get_property(arguments[0], "name");
-
-	new_name = seed_value_to_string(name, exception);
-	if (!JSValueIsObjectOfClass(eng->context,
-				    parent_ref, gobject_constructor_class))
-	{
-		seed_make_exception(exception, "TypeError",
-				    "GType constructor expected"
-				    " GObject type for parent");
-	}
-	if (!JSValueIsNull(eng->context, class_init) &&
-	    JSValueIsObject(eng->context, class_init) &&
-	    JSObjectIsFunction(eng->context, (JSObjectRef) class_init))
-	{
-		init_closure =
-		    seed_make_class_init_closure((JSObjectRef) class_init);
-	}
-	if (!JSValueIsNull(eng->context, instance_init) &&
-	    JSValueIsObject(eng->context, instance_init) &&
-	    JSObjectIsFunction(eng->context, (JSObjectRef) instance_init))
-	{
-		instance_init_closure =
-		    seed_make_instance_init_closure((JSObjectRef)
-						    instance_init);
-	}
-	parent_type = (GType) JSObjectGetPrivate((JSObjectRef) parent_ref);
-
-	g_type_query(parent_type, &query);
-	type_info.class_size = query.class_size;
-	type_info.instance_size = query.instance_size;
-	type_info.class_init = (GClassInitFunc) init_closure;
-	type_info.instance_init = (GInstanceInitFunc) instance_init_closure;
-
-	constructor_ref = JSObjectMake(eng->context, gobject_constructor_class,
-				       (gpointer) new_type);
-	JSValueProtect(eng->context, constructor_ref);
-
-	type_info.class_data = constructor_ref;
-
-	new_type = g_type_register_static(parent_type, new_name, &type_info, 0);
-	seed_gobject_get_class_for_gtype(new_type);
-	JSObjectSetPrivate(constructor_ref, (gpointer) new_type);
-
-	g_free(new_name);
-	return JSObjectMake(eng->context, gobject_constructor_class,
-			    (gpointer) new_type);
+    JSValueRef class_init, instance_init, name, parent_ref;
+    GType parent_type, new_type;
+    gchar *new_name;
+    GTypeInfo type_info = {
+	0,
+	(GBaseInitFunc) NULL,
+	(GBaseFinalizeFunc) NULL,
+	(GClassInitFunc) NULL,
+	(GClassFinalizeFunc) NULL,
+	NULL,
+	0,
+	0,
+	NULL
+    };
+    ffi_closure *init_closure = 0;
+    ffi_closure *instance_init_closure = 0;
+    GTypeQuery query;
+    JSObjectRef constructor_ref;
+
+    if (argumentCount != 1)
+    {
+	gchar *mes =
+	    g_strdup_printf("GType constructor expected 1 "
+			    "argument, got %d \n",
+			    argumentCount);
+	seed_make_exception(exception, "ArgumentError", mes);
+	g_free(mes);
+	return (JSObjectRef) JSValueMakeNull(eng->context);
+    }
+    if (!JSValueIsObject(eng->context, arguments[0]))
+    {
+	seed_make_exception(exception, "ArgumentError",
+			    "GType constructor expected a"
+			    "class definition object. Got a nonobject");
+    }
+    parent_ref = seed_value_get_property(arguments[0], "parent");
+    class_init = seed_value_get_property(arguments[0], "class_init");
+    instance_init = seed_value_get_property(arguments[0], "instance_init");
+    name = seed_value_get_property(arguments[0], "name");
+
+    new_name = seed_value_to_string(name, exception);
+    if (!JSValueIsObjectOfClass(eng->context,
+				parent_ref, gobject_constructor_class))
+    {
+	seed_make_exception(exception, "TypeError",
+			    "GType constructor expected"
+			    " GObject type for parent");
+    }
+    if (!JSValueIsNull(eng->context, class_init) &&
+	JSValueIsObject(eng->context, class_init) &&
+	JSObjectIsFunction(eng->context, (JSObjectRef) class_init))
+    {
+	init_closure = seed_make_class_init_closure((JSObjectRef) class_init);
+    }
+    if (!JSValueIsNull(eng->context, instance_init) &&
+	JSValueIsObject(eng->context, instance_init) &&
+	JSObjectIsFunction(eng->context, (JSObjectRef) instance_init))
+    {
+	instance_init_closure =
+	    seed_make_instance_init_closure((JSObjectRef) instance_init);
+    }
+    parent_type = (GType) JSObjectGetPrivate((JSObjectRef) parent_ref);
+
+    g_type_query(parent_type, &query);
+    type_info.class_size = query.class_size;
+    type_info.instance_size = query.instance_size;
+    type_info.class_init = (GClassInitFunc) init_closure;
+    type_info.instance_init = (GInstanceInitFunc) instance_init_closure;
+
+    constructor_ref = JSObjectMake(eng->context, gobject_constructor_class,
+				   (gpointer) new_type);
+    JSValueProtect(eng->context, constructor_ref);
+
+    type_info.class_data = constructor_ref;
+
+    new_type = g_type_register_static(parent_type, new_name, &type_info, 0);
+    seed_gobject_get_class_for_gtype(new_type);
+    JSObjectSetPrivate(constructor_ref, (gpointer) new_type);
+
+    g_free(new_name);
+    return JSObjectMake(eng->context, gobject_constructor_class,
+			(gpointer) new_type);
 }
 
 void seed_gtype_init(void)
 {
-	JSClassDefinition def = kJSClassDefinitionEmpty;
-	JSObjectRef gtype_constructor;
+    JSClassDefinition def = kJSClassDefinitionEmpty;
+    JSObjectRef gtype_constructor;
 
-	def.callAsConstructor = seed_gtype_constructor_invoked;
-	seed_gtype_class = JSClassCreate(&def);
-	JSClassRetain(seed_gtype_class);
+    def.callAsConstructor = seed_gtype_constructor_invoked;
+    seed_gtype_class = JSClassCreate(&def);
+    JSClassRetain(seed_gtype_class);
 
-	gtype_constructor = JSObjectMake(eng->context, seed_gtype_class, 0);
+    gtype_constructor = JSObjectMake(eng->context, seed_gtype_class, 0);
 
-	seed_value_set_property(eng->global, "GType", gtype_constructor);
+    seed_value_set_property(eng->global, "GType", gtype_constructor);
 
 }

Modified: trunk/libseed/seed-private.h
==============================================================================
--- trunk/libseed/seed-private.h	(original)
+++ trunk/libseed/seed-private.h	Sat Nov  8 01:42:29 2008
@@ -34,8 +34,8 @@
 typedef JSValueRef SeedValue;
 
 struct _SeedEngine {
-	JSGlobalContextRef context;
-	JSObjectRef global;
+    JSGlobalContextRef context;
+    JSObjectRef global;
 };
 
 #include "seed-engine.h"

Modified: trunk/libseed/seed-signals.c
==============================================================================
--- trunk/libseed/seed-signals.c	(original)
+++ trunk/libseed/seed-signals.c	Sat Nov  8 01:42:29 2008
@@ -24,8 +24,8 @@
 #include "seed-private.h"
 
 typedef struct _signal_privates {
-	guint signal_id;
-	GObject *object;
+    guint signal_id;
+    GObject *object;
 } signal_privates;
 
 JSClassRef signal_holder_class;
@@ -34,73 +34,72 @@
 seed_add_signal_to_object(JSObjectRef object_ref,
 			  GObject * obj, GSignalQuery * signal)
 {
-	guint k;
-	JSObjectRef signal_ref;
-	signal_privates *priv = g_malloc(sizeof(signal_privates));
-	gchar *js_signal_name = g_strdup(signal->signal_name);
-	g_assert(signal);
+    guint k;
+    JSObjectRef signal_ref;
+    signal_privates *priv = g_malloc(sizeof(signal_privates));
+    gchar *js_signal_name = g_strdup(signal->signal_name);
+    g_assert(signal);
+
+    for (k = 0; k < strlen(js_signal_name); k++)
+    {
+	if (js_signal_name[k] == '-')
+	    js_signal_name[k] = '_';
+    }
 
-	for (k = 0; k < strlen(js_signal_name); k++)
-	{
-		if (js_signal_name[k] == '-')
-			js_signal_name[k] = '_';
-	}
+    signal_ref = JSObjectMake(eng->context, gobject_signal_class, priv);
 
-	signal_ref = JSObjectMake(eng->context, gobject_signal_class, priv);
+    priv->signal_id = signal->signal_id;
+    priv->object = obj;
 
-	priv->signal_id = signal->signal_id;
-	priv->object = obj;
-
-	seed_value_set_property(object_ref, js_signal_name, signal_ref);
-	g_free(js_signal_name);
+    seed_value_set_property(object_ref, js_signal_name, signal_ref);
+    g_free(js_signal_name);
 }
 
 static void
 seed_add_signals_for_type(JSObjectRef object_ref, GObject * obj, GType type)
 {
-	guint n, i;
-	guint *signal_ids;
-	GSignalQuery query;
-	signal_ids = g_signal_list_ids(type, &n);
-	for (i = 0; i < n; i++)
+    guint n, i;
+    guint *signal_ids;
+    GSignalQuery query;
+    signal_ids = g_signal_list_ids(type, &n);
+    for (i = 0; i < n; i++)
+    {
+	g_signal_query(signal_ids[i], &query);
+	if (query.signal_id != 0)
 	{
-		g_signal_query(signal_ids[i], &query);
-		if (query.signal_id != 0)
-		{
-			seed_add_signal_to_object(object_ref, obj, &query);
-		}
+	    seed_add_signal_to_object(object_ref, obj, &query);
 	}
-	g_free(signal_ids);
+    }
+    g_free(signal_ids);
 }
 
 void seed_add_signals_to_object(JSObjectRef object_ref, GObject * obj)
 {
-	GType type;
-	GType *interfaces;
-	guint n, i;
-	JSObjectRef signals_ref;
+    GType type;
+    GType *interfaces;
+    guint n, i;
+    JSObjectRef signals_ref;
 
-	g_assert(obj);
+    g_assert(obj);
 
-	type = G_OBJECT_TYPE(obj);
+    type = G_OBJECT_TYPE(obj);
 
-	signals_ref = JSObjectMake(eng->context, signal_holder_class, 0);
+    signals_ref = JSObjectMake(eng->context, signal_holder_class, 0);
 
-	while (type != 0)
-	{
-		seed_add_signals_for_type(signals_ref, obj, type);
+    while (type != 0)
+    {
+	seed_add_signals_for_type(signals_ref, obj, type);
 
-		interfaces = g_type_interfaces(type, &n);
-		for (i = 0; i < n; i++)
-			seed_add_signals_for_type(signals_ref, obj,
-						  interfaces[i]);
+	interfaces = g_type_interfaces(type, &n);
+	for (i = 0; i < n; i++)
+	    seed_add_signals_for_type(signals_ref, obj, interfaces[i]);
 
-		type = g_type_parent(type);
+	type = g_type_parent(type);
 
-		g_free(interfaces);
-	}
+	g_free(interfaces);
+    }
 
-	seed_value_set_property(object_ref, "signal", signals_ref);
+    seed_value_set_property(object_ref, "signal", signals_ref);
 }
 
 void
@@ -110,26 +109,25 @@
 			 const GValue * param_values,
 			 gpointer invocation_hint, gpointer marshall_data)
 {
-	SeedClosure *seed_closure = (SeedClosure *) closure;
-	JSValueRef *args;
-	gint i;
+    SeedClosure *seed_closure = (SeedClosure *) closure;
+    JSValueRef *args;
+    gint i;
 
-	args = g_newa(JSValueRef, n_param_values);
+    args = g_newa(JSValueRef, n_param_values);
 
-	for (i = 0; i < n_param_values; i++)
-	{
-		args[i] =
-		    seed_value_from_gvalue((GValue *) & param_values[i], 0);
+    for (i = 0; i < n_param_values; i++)
+    {
+	args[i] = seed_value_from_gvalue((GValue *) & param_values[i], 0);
 
-		if (!args[i])
-			g_error("Error in signal marshal. "
-				"Unable to convert argument of type: %s \n",
-				g_type_name(param_values[i].g_type));
+	if (!args[i])
+	    g_error("Error in signal marshal. "
+		    "Unable to convert argument of type: %s \n",
+		    g_type_name(param_values[i].g_type));
 
-	}
+    }
 
-	JSObjectCallAsFunction(eng->context, seed_closure->function,
-			       seed_closure->this, n_param_values, args, 0);
+    JSObjectCallAsFunction(eng->context, seed_closure->function,
+			   seed_closure->this, n_param_values, args, 0);
 }
 
 static JSValueRef
@@ -140,36 +138,36 @@
 			    const JSValueRef arguments[],
 			    JSValueRef * exception)
 {
-	signal_privates *privates;
-	GClosure *closure;
-
-	privates = (signal_privates *) JSObjectGetPrivate(thisObject);
-	if (!privates)
-		g_error("Signal constructed with invalid parameters"
-			"in namespace import \n");
-
-	g_assert((argumentCount <= 2));
-
-	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]))
-	{
-		JSValueProtect(eng->context, (JSObjectRef) arguments[1]);
-		((SeedClosure *) closure)->this = (JSObjectRef) arguments[1];
-	}
-	else
-		((SeedClosure *) closure)->this = 0;
-
-	JSValueProtect(eng->context, (JSObjectRef) arguments[0]);
+    signal_privates *privates;
+    GClosure *closure;
 
-	g_signal_connect_closure_by_id(privates->object,
-				       privates->signal_id, 0, closure, FALSE);
-	return 0;
+    privates = (signal_privates *) JSObjectGetPrivate(thisObject);
+    if (!privates)
+	g_error("Signal constructed with invalid parameters"
+		"in namespace import \n");
+
+    g_assert((argumentCount <= 2));
+
+    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]))
+    {
+	JSValueProtect(eng->context, (JSObjectRef) arguments[1]);
+	((SeedClosure *) closure)->this = (JSObjectRef) arguments[1];
+    }
+    else
+	((SeedClosure *) closure)->this = 0;
+
+    JSValueProtect(eng->context, (JSObjectRef) arguments[0]);
+
+    g_signal_connect_closure_by_id(privates->object,
+				   privates->signal_id, 0, closure, FALSE);
+    return 0;
 }
 
 JSStaticFunction signal_static_functions[] =
@@ -179,32 +177,32 @@
 };
 
 JSClassDefinition gobject_signal_def = {
-	0,			/* Version, always 0 */
-	kJSClassAttributeNoAutomaticPrototype,
-	"gobject_signal",	/* Class Name */
-	NULL,			/* Parent Class */
-	NULL,			/* Static Values */
-	signal_static_functions,	/* Static Functions */
-	NULL,
-	NULL,			/* Finalize */
-	NULL,			/* Has Property */
-	NULL,			/* Get Property */
-	NULL,			/* Set Property */
-	NULL,			/* Delete Property */
-	NULL,			/* Get Property Names */
-	NULL,			/* Call As Function */
-	NULL,			/* Call As Constructor */
-	NULL,			/* Has Instance */
-	NULL			/* Convert To Type */
+    0,				/* Version, always 0 */
+    kJSClassAttributeNoAutomaticPrototype,
+    "gobject_signal",		/* Class Name */
+    NULL,			/* Parent Class */
+    NULL,			/* Static Values */
+    signal_static_functions,	/* Static Functions */
+    NULL,
+    NULL,			/* Finalize */
+    NULL,			/* Has Property */
+    NULL,			/* Get Property */
+    NULL,			/* Set Property */
+    NULL,			/* Delete Property */
+    NULL,			/* Get Property Names */
+    NULL,			/* Call As Function */
+    NULL,			/* Call As Constructor */
+    NULL,			/* Has Instance */
+    NULL			/* Convert To Type */
 };
 
 JSClassDefinition *seed_get_signal_class(void)
 {
-	JSClassDefinition signal_holder = kJSClassDefinitionEmpty;
+    JSClassDefinition signal_holder = kJSClassDefinitionEmpty;
 
-	signal_holder.className = "gobject_signals";
-	signal_holder_class = JSClassCreate(&signal_holder);
-	JSClassRetain(signal_holder_class);
+    signal_holder.className = "gobject_signals";
+    signal_holder_class = JSClassCreate(&signal_holder);
+    JSClassRetain(signal_holder_class);
 
-	return &gobject_signal_def;
+    return &gobject_signal_def;
 }

Modified: trunk/libseed/seed-structs.c
==============================================================================
--- trunk/libseed/seed-structs.c	(original)
+++ trunk/libseed/seed-structs.c	Sat Nov  8 01:42:29 2008
@@ -24,82 +24,84 @@
 JSClassRef seed_struct_class = 0;
 
 JSClassDefinition gobject_struct_def = {
-	0,			/* Version, always 0 */
-	0,
-	"seed_struct",		/* Class Name */
-	NULL,			/* Parent Class */
-	NULL,			/* Static Values */
-	NULL,			/* Static Functions */
-	NULL,
-	NULL,
-	NULL,			/* Has Property */
-	0,
-	NULL,			/* Set Property */
-	NULL,			/* Delete Property */
-	NULL,			/* Get Property Names */
-	NULL,			/* Call As Function */
-	NULL,			/* Call As Constructor */
-	NULL,			/* Has Instance */
-	NULL			/* Convert To Type */
+    0,				/* Version, always 0 */
+    0,
+    "seed_struct",		/* Class Name */
+    NULL,			/* Parent Class */
+    NULL,			/* Static Values */
+    NULL,			/* Static Functions */
+    NULL,
+    NULL,
+    NULL,			/* Has Property */
+    0,
+    NULL,			/* Set Property */
+    NULL,			/* Delete Property */
+    NULL,			/* Get Property Names */
+    NULL,			/* Call As Function */
+    NULL,			/* Call As Constructor */
+    NULL,			/* Has Instance */
+    NULL			/* Convert To Type */
 };
 
 gpointer seed_struct_get_pointer(JSValueRef strukt)
 {
-	if (JSValueIsObjectOfClass(eng->context, strukt, seed_struct_class))
-		return JSObjectGetPrivate((JSObjectRef) strukt);
-	return 0;
+    if (JSValueIsObjectOfClass(eng->context, strukt, seed_struct_class))
+	return JSObjectGetPrivate((JSObjectRef) strukt);
+    return 0;
 }
 
 JSObjectRef seed_make_union(gpointer younion, GIBaseInfo * info)
 {
-	JSObjectRef object;
-	gint i, n_methods;
+    JSObjectRef object;
+    gint i, n_methods;
 
-	if (!seed_struct_class)
-		seed_struct_class = JSClassCreate(&gobject_struct_def);
+    if (!seed_struct_class)
+	seed_struct_class = JSClassCreate(&gobject_struct_def);
 
-	object = JSObjectMake(eng->context, seed_struct_class, younion);
+    object = JSObjectMake(eng->context, seed_struct_class, younion);
 
-	if (info)
+    if (info)
+    {
+	n_methods = g_union_info_get_n_methods((GIUnionInfo *) info);
+	for (i = 0; i < n_methods; i++)
 	{
-		n_methods = g_union_info_get_n_methods((GIUnionInfo *) info);
-		for (i = 0; i < n_methods; i++)
-		{
-			GIFunctionInfo *finfo;
+	    GIFunctionInfo *finfo;
 
-			finfo =
-			    g_union_info_get_method((GIUnionInfo *) info, i);
+	    finfo = g_union_info_get_method((GIUnionInfo *) info, i);
 
-			seed_gobject_define_property_from_function_info((GIFunctionInfo *) finfo, object, TRUE);
-		}
+	    seed_gobject_define_property_from_function_info((GIFunctionInfo *)
+							    finfo, object,
+							    TRUE);
 	}
+    }
 
-	return object;
+    return object;
 }
 
 JSObjectRef seed_make_struct(gpointer strukt, GIBaseInfo * info)
 {
-	JSObjectRef object;
-	gint i, n_methods;
+    JSObjectRef object;
+    gint i, n_methods;
 
-	if (!seed_struct_class)
-		seed_struct_class = JSClassCreate(&gobject_struct_def);
+    if (!seed_struct_class)
+	seed_struct_class = JSClassCreate(&gobject_struct_def);
 
-	object = JSObjectMake(eng->context, seed_struct_class, strukt);
+    object = JSObjectMake(eng->context, seed_struct_class, strukt);
 
-	if (info)
+    if (info)
+    {
+	n_methods = g_struct_info_get_n_methods((GIStructInfo *) info);
+	for (i = 0; i < n_methods; i++)
 	{
-		n_methods = g_struct_info_get_n_methods((GIStructInfo *) info);
-		for (i = 0; i < n_methods; i++)
-		{
-			GIFunctionInfo *finfo;
+	    GIFunctionInfo *finfo;
 
-			finfo =
-			    g_struct_info_get_method((GIStructInfo *) info, i);
+	    finfo = g_struct_info_get_method((GIStructInfo *) info, i);
 
-			seed_gobject_define_property_from_function_info((GIFunctionInfo *) finfo, object, TRUE);
-		}
+	    seed_gobject_define_property_from_function_info((GIFunctionInfo *)
+							    finfo, object,
+							    TRUE);
 	}
+    }
 
-	return object;
+    return object;
 }

Modified: trunk/libseed/seed-types.c
==============================================================================
--- trunk/libseed/seed-types.c	(original)
+++ trunk/libseed/seed-types.c	Sat Nov  8 01:42:29 2008
@@ -31,146 +31,145 @@
 
 static gboolean seed_value_is_gobject(SeedValue value)
 {
-	if (!JSValueIsObject(eng->context, value) ||
-	    JSValueIsNull(eng->context, value))
+    if (!JSValueIsObject(eng->context, value) ||
+	JSValueIsNull(eng->context, value))
 
-		return FALSE;
+	return FALSE;
 
-	return JSValueIsObjectOfClass(eng->context, value, gobject_class);
+    return JSValueIsObjectOfClass(eng->context, value, gobject_class);
 }
 
 void seed_toggle_ref(gpointer data, GObject * object, gboolean is_last_ref)
 {
-	JSValueRef wrapper;
+    JSValueRef wrapper;
 
-	wrapper = (JSValueRef) data;
+    wrapper = (JSValueRef) data;
 
-	if (is_last_ref)
-	{
-		JSValueUnprotect(eng->context, wrapper);
-	}
-	else
-	{
-		JSValueProtect(eng->context, wrapper);
-	}
+    if (is_last_ref)
+    {
+	JSValueUnprotect(eng->context, wrapper);
+    }
+    else
+    {
+	JSValueProtect(eng->context, wrapper);
+    }
 
 }
 
 static SeedValue seed_wrap_object(GObject * object)
 {
-	SeedValue user_data;
-	SeedValue js_ref;
-	JSClassRef class;
-	GType type, *interfaces;
-	JSValueRef prototype;
-	guint i, n;
+    SeedValue user_data;
+    SeedValue js_ref;
+    JSClassRef class;
+    GType type, *interfaces;
+    JSValueRef prototype;
+    guint i, n;
 
-	type = G_OBJECT_TYPE(object);
+    type = G_OBJECT_TYPE(object);
 
-	user_data = (SeedValue) g_object_get_data(object, "js-ref");
+    user_data = (SeedValue) g_object_get_data(object, "js-ref");
 
-	if (user_data)
-		return user_data;
+    if (user_data)
+	return user_data;
 
-	class = seed_gobject_get_class_for_gtype(type);
+    class = seed_gobject_get_class_for_gtype(type);
 
-	while (!class && (type = g_type_parent(type)))
-	{
-		class = seed_gobject_get_class_for_gtype(type);
-	}
+    while (!class && (type = g_type_parent(type)))
+    {
+	class = seed_gobject_get_class_for_gtype(type);
+    }
 
-	prototype = seed_gobject_get_prototype_for_gtype(type);
-	js_ref = JSObjectMake(eng->context, class, object);
-	if (prototype)
-		JSObjectSetPrototype(eng->context,
-				     (JSObjectRef) js_ref, prototype);
-	else
-	{
-		g_assert_not_reached();
-	}
+    prototype = seed_gobject_get_prototype_for_gtype(type);
+    js_ref = JSObjectMake(eng->context, class, object);
+    if (prototype)
+	JSObjectSetPrototype(eng->context, (JSObjectRef) js_ref, prototype);
+    else
+    {
+	g_assert_not_reached();
+    }
 
-	g_object_ref_sink(object);
+    g_object_ref_sink(object);
 
-	g_object_set_data(object, "js-ref", (gpointer) js_ref);
+    g_object_set_data(object, "js-ref", (gpointer) js_ref);
 
-	JSValueProtect(eng->context, js_ref);
-	g_object_add_toggle_ref(object, seed_toggle_ref, (gpointer) js_ref);
+    JSValueProtect(eng->context, js_ref);
+    g_object_add_toggle_ref(object, seed_toggle_ref, (gpointer) js_ref);
 
-	g_object_unref(object);
+    g_object_unref(object);
 
-	return js_ref;
+    return js_ref;
 }
 
 GType seed_gi_type_to_gtype(GITypeInfo * type_info, GITypeTag tag)
 {
-	switch (tag)
-	{
-	case GI_TYPE_TAG_VOID:
-		return G_TYPE_NONE;
-	case GI_TYPE_TAG_BOOLEAN:
-		return G_TYPE_BOOLEAN;
-	case GI_TYPE_TAG_INT8:
-		return G_TYPE_CHAR;
-	case GI_TYPE_TAG_UINT8:
-		return G_TYPE_UCHAR;
-	case GI_TYPE_TAG_INT16:
-		return G_TYPE_INT;
-	case GI_TYPE_TAG_UINT16:
-		return G_TYPE_UINT;
-	case GI_TYPE_TAG_INT32:
-		return G_TYPE_INT;
-	case GI_TYPE_TAG_UINT32:
-		return G_TYPE_UINT;
-	case GI_TYPE_TAG_INT64:
-		return G_TYPE_INT64;
-	case GI_TYPE_TAG_UINT64:
-		return G_TYPE_UINT64;
-	case GI_TYPE_TAG_INT:
-		return G_TYPE_INT;
-	case GI_TYPE_TAG_UINT:
-		return G_TYPE_UINT;
-	case GI_TYPE_TAG_LONG:
+    switch (tag)
+    {
+    case GI_TYPE_TAG_VOID:
+	return G_TYPE_NONE;
+    case GI_TYPE_TAG_BOOLEAN:
+	return G_TYPE_BOOLEAN;
+    case GI_TYPE_TAG_INT8:
+	return G_TYPE_CHAR;
+    case GI_TYPE_TAG_UINT8:
+	return G_TYPE_UCHAR;
+    case GI_TYPE_TAG_INT16:
+	return G_TYPE_INT;
+    case GI_TYPE_TAG_UINT16:
+	return G_TYPE_UINT;
+    case GI_TYPE_TAG_INT32:
+	return G_TYPE_INT;
+    case GI_TYPE_TAG_UINT32:
+	return G_TYPE_UINT;
+    case GI_TYPE_TAG_INT64:
+	return G_TYPE_INT64;
+    case GI_TYPE_TAG_UINT64:
+	return G_TYPE_UINT64;
+    case GI_TYPE_TAG_INT:
+	return G_TYPE_INT;
+    case GI_TYPE_TAG_UINT:
+	return G_TYPE_UINT;
+    case GI_TYPE_TAG_LONG:
+	return G_TYPE_LONG;
+    case GI_TYPE_TAG_ULONG:
+	return G_TYPE_ULONG;
+    case GI_TYPE_TAG_SSIZE:
+	return G_TYPE_INT;
+    case GI_TYPE_TAG_SIZE:
+	return G_TYPE_INT;
+    case GI_TYPE_TAG_FLOAT:
+	return G_TYPE_FLOAT;
+    case GI_TYPE_TAG_DOUBLE:
+	return G_TYPE_DOUBLE;
+    case GI_TYPE_TAG_UTF8:
+    case GI_TYPE_TAG_FILENAME:
+	return G_TYPE_STRING;
+    case GI_TYPE_TAG_ARRAY:
+    case GI_TYPE_TAG_GLIST:
+    case GI_TYPE_TAG_GSLIST:
+    case GI_TYPE_TAG_GHASH:
+    case GI_TYPE_TAG_ERROR:
+    case GI_TYPE_TAG_TIME_T:
+    case GI_TYPE_TAG_GTYPE:
+	return G_TYPE_INVALID;
+    case GI_TYPE_TAG_INTERFACE:
+	{
+	    GIBaseInfo *interface;
+	    GIInfoType interface_type;
+
+	    interface = g_type_info_get_interface(type_info);
+	    interface_type = g_base_info_get_type(interface);
+	    if (interface_type == GI_INFO_TYPE_OBJECT ||
+		interface_type == GI_INFO_TYPE_INTERFACE)
+		return G_TYPE_OBJECT;
+	    else if (interface_type == GI_INFO_TYPE_ENUM)
 		return G_TYPE_LONG;
-	case GI_TYPE_TAG_ULONG:
-		return G_TYPE_ULONG;
-	case GI_TYPE_TAG_SSIZE:
-		return G_TYPE_INT;
-	case GI_TYPE_TAG_SIZE:
-		return G_TYPE_INT;
-	case GI_TYPE_TAG_FLOAT:
-		return G_TYPE_FLOAT;
-	case GI_TYPE_TAG_DOUBLE:
-		return G_TYPE_DOUBLE;
-	case GI_TYPE_TAG_UTF8:
-	case GI_TYPE_TAG_FILENAME:
-		return G_TYPE_STRING;
-	case GI_TYPE_TAG_ARRAY:
-	case GI_TYPE_TAG_GLIST:
-	case GI_TYPE_TAG_GSLIST:
-	case GI_TYPE_TAG_GHASH:
-	case GI_TYPE_TAG_ERROR:
-	case GI_TYPE_TAG_TIME_T:
-	case GI_TYPE_TAG_GTYPE:
-		return G_TYPE_INVALID;
-	case GI_TYPE_TAG_INTERFACE:
-		{
-			GIBaseInfo *interface;
-			GIInfoType interface_type;
-
-			interface = g_type_info_get_interface(type_info);
-			interface_type = g_base_info_get_type(interface);
-			if (interface_type == GI_INFO_TYPE_OBJECT ||
-			    interface_type == GI_INFO_TYPE_INTERFACE)
-				return G_TYPE_OBJECT;
-			else if (interface_type == GI_INFO_TYPE_ENUM)
-				return G_TYPE_LONG;
-			else if (interface_type == GI_INFO_TYPE_FLAGS)
-				return G_TYPE_LONG;
-			else if (interface_type == GI_INFO_TYPE_STRUCT)
-				return G_TYPE_POINTER;
-		}
+	    else if (interface_type == GI_INFO_TYPE_FLAGS)
+		return G_TYPE_LONG;
+	    else if (interface_type == GI_INFO_TYPE_STRUCT)
+		return G_TYPE_POINTER;
 	}
-	return 0;
+    }
+    return 0;
 }
 
 gboolean
@@ -178,186 +177,174 @@
 		      GITypeInfo * type_info, GArgument * arg,
 		      JSValueRef * exception)
 {
-	GITypeTag gi_tag = g_type_info_get_tag(type_info);
+    GITypeTag gi_tag = g_type_info_get_tag(type_info);
 
-	if (!value || JSValueIsNull(eng->context, value))
-	{
-		arg->v_pointer = 0;
-		return 1;
-	}
+    if (!value || JSValueIsNull(eng->context, value))
+    {
+	arg->v_pointer = 0;
+	return 1;
+    }
+
+    switch (gi_tag)
+    {
+    case GI_TYPE_TAG_VOID:
+	break;
+    case GI_TYPE_TAG_BOOLEAN:
+	arg->v_boolean = seed_value_to_boolean(value, exception);
+	break;
+    case GI_TYPE_TAG_INT8:
+	arg->v_int8 = seed_value_to_char(value, exception);
+	break;
+    case GI_TYPE_TAG_UINT8:
+	arg->v_uint8 = seed_value_to_uchar(value, exception);
+	break;
+    case GI_TYPE_TAG_INT16:
+	arg->v_int16 = seed_value_to_int(value, exception);
+	break;
+    case GI_TYPE_TAG_UINT16:
+	arg->v_uint16 = seed_value_to_uint(value, exception);
+	break;
+    case GI_TYPE_TAG_INT32:
+	arg->v_int32 = seed_value_to_int(value, exception);
+	break;
+    case GI_TYPE_TAG_UINT32:
+	arg->v_uint32 = seed_value_to_uint(value, exception);
+	break;
+    case GI_TYPE_TAG_LONG:
+    case GI_TYPE_TAG_INT64:
+	arg->v_int64 = seed_value_to_long(value, exception);
+	break;
+    case GI_TYPE_TAG_ULONG:
+    case GI_TYPE_TAG_UINT64:
+	arg->v_uint64 = seed_value_to_ulong(value, exception);
+	break;
+    case GI_TYPE_TAG_INT:
+	arg->v_int = seed_value_to_int(value, exception);
+	break;
+    case GI_TYPE_TAG_UINT:
+	arg->v_uint = seed_value_to_uint(value, exception);
+	break;
+    case GI_TYPE_TAG_SIZE:
+    case GI_TYPE_TAG_SSIZE:
+	arg->v_int = seed_value_to_int(value, exception);
+	break;
+    case GI_TYPE_TAG_FLOAT:
+	arg->v_float = seed_value_to_float(value, exception);
+	break;
+    case GI_TYPE_TAG_DOUBLE:
+	arg->v_double = seed_value_to_double(value, exception);
+	break;
+    case GI_TYPE_TAG_UTF8:
+	arg->v_string = seed_value_to_string(value, exception);
+	break;
+    case GI_TYPE_TAG_INTERFACE:
+	{
+	    GIBaseInfo *interface;
+	    GIInfoType interface_type;
+	    GType required_gtype;
+	    GObject *gobject;
+
+	    interface = g_type_info_get_interface(type_info);
+	    interface_type = g_base_info_get_type(interface);
+
+	    arg->v_pointer = NULL;
+
+	    if (interface_type == GI_INFO_TYPE_OBJECT
+		|| interface_type == GI_INFO_TYPE_INTERFACE)
+	    {
+		gobject = seed_value_to_object(value, exception);
+		required_gtype =
+		    g_registered_type_info_get_g_type((GIRegisteredTypeInfo *)
+						      interface);
+		if (!gobject
+		    || !g_type_is_a(G_OBJECT_TYPE(gobject), required_gtype))
+		{
+		    return FALSE;
+		}
 
-	switch (gi_tag)
-	{
-	case GI_TYPE_TAG_VOID:
-		break;
-	case GI_TYPE_TAG_BOOLEAN:
-		arg->v_boolean = seed_value_to_boolean(value, exception);
-		break;
-	case GI_TYPE_TAG_INT8:
-		arg->v_int8 = seed_value_to_char(value, exception);
-		break;
-	case GI_TYPE_TAG_UINT8:
-		arg->v_uint8 = seed_value_to_uchar(value, exception);
-		break;
-	case GI_TYPE_TAG_INT16:
-		arg->v_int16 = seed_value_to_int(value, exception);
-		break;
-	case GI_TYPE_TAG_UINT16:
-		arg->v_uint16 = seed_value_to_uint(value, exception);
+		arg->v_pointer = gobject;
 		break;
-	case GI_TYPE_TAG_INT32:
-		arg->v_int32 = seed_value_to_int(value, exception);
+	    }
+	    else if (interface_type == GI_INFO_TYPE_ENUM ||
+		     interface_type == GI_INFO_TYPE_FLAGS)
+	    {
+		arg->v_long = JSValueToNumber(eng->context, value, NULL);
 		break;
-	case GI_TYPE_TAG_UINT32:
-		arg->v_uint32 = seed_value_to_uint(value, exception);
-		break;
-	case GI_TYPE_TAG_LONG:
-	case GI_TYPE_TAG_INT64:
-		arg->v_int64 = seed_value_to_long(value, exception);
-		break;
-	case GI_TYPE_TAG_ULONG:
-	case GI_TYPE_TAG_UINT64:
-		arg->v_uint64 = seed_value_to_ulong(value, exception);
-		break;
-	case GI_TYPE_TAG_INT:
-		arg->v_int = seed_value_to_int(value, exception);
-		break;
-	case GI_TYPE_TAG_UINT:
-		arg->v_uint = seed_value_to_uint(value, exception);
-		break;
-	case GI_TYPE_TAG_SIZE:
-	case GI_TYPE_TAG_SSIZE:
-		arg->v_int = seed_value_to_int(value, exception);
-		break;
-	case GI_TYPE_TAG_FLOAT:
-		arg->v_float = seed_value_to_float(value, exception);
-		break;
-	case GI_TYPE_TAG_DOUBLE:
-		arg->v_double = seed_value_to_double(value, exception);
-		break;
-	case GI_TYPE_TAG_UTF8:
-		arg->v_string = seed_value_to_string(value, exception);
-		break;
-	case GI_TYPE_TAG_INTERFACE:
-		{
-			GIBaseInfo *interface;
-			GIInfoType interface_type;
-			GType required_gtype;
-			GObject *gobject;
-
-			interface = g_type_info_get_interface(type_info);
-			interface_type = g_base_info_get_type(interface);
-
-			arg->v_pointer = NULL;
-
-			if (interface_type == GI_INFO_TYPE_OBJECT
-			    || interface_type == GI_INFO_TYPE_INTERFACE)
+	    }
+	    else if (interface_type == GI_INFO_TYPE_STRUCT)
+	    {
+		if (JSValueIsObjectOfClass(eng->context,
+					   value, seed_struct_class))
+		    arg->v_pointer = seed_struct_get_pointer(value);
+		else
+		{
+		    GType type =
+			g_registered_type_info_get_g_type((GIRegisteredTypeInfo
+							   *) interface);
+		    if (!type)
+			return FALSE;
+		    else if (g_type_is_a(type, G_TYPE_CLOSURE))
+		    {
+			if (JSObjectIsFunction
+			    (eng->context, (JSObjectRef) value))
 			{
-				gobject =
-				    seed_value_to_object(value, exception);
-				required_gtype =
-				    g_registered_type_info_get_g_type((GIRegisteredTypeInfo *) interface);
-				if (!gobject
-				    || !g_type_is_a(G_OBJECT_TYPE(gobject),
-						    required_gtype))
-				{
-					return FALSE;
-				}
-
-				arg->v_pointer = gobject;
-				break;
-			}
-			else if (interface_type == GI_INFO_TYPE_ENUM ||
-				 interface_type == GI_INFO_TYPE_FLAGS)
-			{
-				arg->v_long =
-				    JSValueToNumber(eng->context, value, NULL);
-				break;
-			}
-			else if (interface_type == GI_INFO_TYPE_STRUCT)
-			{
-				if (JSValueIsObjectOfClass(eng->context,
-							   value,
-							   seed_struct_class))
-					arg->v_pointer =
-					    seed_struct_get_pointer(value);
-				else
-				{
-					GType type =
-					    g_registered_type_info_get_g_type((GIRegisteredTypeInfo *) interface);
-					if (!type)
-						return FALSE;
-					else if (g_type_is_a
-						 (type, G_TYPE_CLOSURE))
-					{
-						if (JSObjectIsFunction
-						    (eng->context,
-						     (JSObjectRef) value))
-						{
-							arg->v_pointer =
-							    seed_make_gclosure((JSObjectRef) value, 0);
-						}
-					}
-				}
-				break;
-			}
-			else if (interface_type == GI_INFO_TYPE_CALLBACK)
-			{
-				if (JSValueIsObjectOfClass(eng->context,
-							   value,
-							   gobject_method_class))
-				{
-					GIFunctionInfo *info =
-					    JSObjectGetPrivate((JSObjectRef)
-							       value);
-					const gchar *symbol =
-					    g_function_info_get_symbol(info);
-					gchar *error;
-					void *fp;
-
-					dlerror();
-					fp = (void *)dlsym(0, symbol);
-					if ((error = dlerror()) != NULL)
-					{
-						g_critical("dlerror: %s \n",
-							   error);
-					}
-					else
-					{
-						arg->v_pointer = fp;
-						break;
-					}
-				}
-				else if (JSValueIsObjectOfClass(eng->context,
-								value,
-								seed_native_callback_class))
-				{
-					SeedNativeClosure *privates =
-					    (SeedNativeClosure *)
-					    JSObjectGetPrivate((JSObjectRef)
-							       value);
-					arg->v_pointer = privates->closure;
-					break;
-				}
-				else if (JSObjectIsFunction(eng->context,
-							    (JSObjectRef)
-							    value))
-				{
-					SeedNativeClosure *privates =
-					    seed_make_native_closure((GICallableInfo *) interface,
-								     value);
-					arg->v_pointer = privates->closure;
-					break;
-				}
-
+			    arg->v_pointer =
+				seed_make_gclosure((JSObjectRef) value, 0);
 			}
+		    }
+		}
+		break;
+	    }
+	    else if (interface_type == GI_INFO_TYPE_CALLBACK)
+	    {
+		if (JSValueIsObjectOfClass(eng->context,
+					   value, gobject_method_class))
+		{
+		    GIFunctionInfo *info =
+			JSObjectGetPrivate((JSObjectRef) value);
+		    const gchar *symbol = g_function_info_get_symbol(info);
+		    gchar *error;
+		    void *fp;
+
+		    dlerror();
+		    fp = (void *)dlsym(0, symbol);
+		    if ((error = dlerror()) != NULL)
+		    {
+			g_critical("dlerror: %s \n", error);
+		    }
+		    else
+		    {
+			arg->v_pointer = fp;
+			break;
+		    }
+		}
+		else if (JSValueIsObjectOfClass(eng->context,
+						value,
+						seed_native_callback_class))
+		{
+		    SeedNativeClosure *privates =
+			(SeedNativeClosure *)
+			JSObjectGetPrivate((JSObjectRef) value);
+		    arg->v_pointer = privates->closure;
+		    break;
+		}
+		else if (JSObjectIsFunction(eng->context, (JSObjectRef) value))
+		{
+		    SeedNativeClosure *privates =
+			seed_make_native_closure((GICallableInfo *) interface,
+						 value);
+		    arg->v_pointer = privates->closure;
+		    break;
 		}
 
-	default:
-		return FALSE;
-
+	    }
 	}
-	return TRUE;
+
+    default:
+	return FALSE;
+
+    }
+    return TRUE;
 
 }
 
@@ -365,810 +352,761 @@
 seed_gi_argument_make_js(GArgument * arg, GITypeInfo * type_info,
 			 JSValueRef * exception)
 {
-	GITypeTag gi_tag = g_type_info_get_tag(type_info);
-	switch (gi_tag)
-	{
-	case GI_TYPE_TAG_VOID:
-		return 0;
-	case GI_TYPE_TAG_BOOLEAN:
-		return seed_value_from_boolean(arg->v_boolean, exception);
-	case GI_TYPE_TAG_INT8:
-		return seed_value_from_char(arg->v_int8, exception);
-	case GI_TYPE_TAG_UINT8:
-		return seed_value_from_uchar(arg->v_uint8, exception);
-	case GI_TYPE_TAG_INT16:
-		return seed_value_from_int(arg->v_int16, exception);
-	case GI_TYPE_TAG_UINT16:
-		return seed_value_from_uint(arg->v_uint16, exception);
-	case GI_TYPE_TAG_INT32:
-		return seed_value_from_int(arg->v_int32, exception);
-	case GI_TYPE_TAG_UINT32:
-		return seed_value_from_uint(arg->v_uint32, exception);
-	case GI_TYPE_TAG_LONG:
-	case GI_TYPE_TAG_INT64:
-		return seed_value_from_long(arg->v_int64, exception);
-	case GI_TYPE_TAG_ULONG:
-	case GI_TYPE_TAG_UINT64:
-		return seed_value_from_ulong(arg->v_uint64, exception);
-	case GI_TYPE_TAG_INT:
-		return seed_value_from_int(arg->v_int32, exception);
-	case GI_TYPE_TAG_UINT:
-		return seed_value_from_uint(arg->v_uint32, exception);
-	case GI_TYPE_TAG_SSIZE:
-	case GI_TYPE_TAG_SIZE:
-		return seed_value_from_int(arg->v_int, exception);
-	case GI_TYPE_TAG_FLOAT:
-		return seed_value_from_float(arg->v_float, exception);
-	case GI_TYPE_TAG_DOUBLE:
+    GITypeTag gi_tag = g_type_info_get_tag(type_info);
+    switch (gi_tag)
+    {
+    case GI_TYPE_TAG_VOID:
+	return 0;
+    case GI_TYPE_TAG_BOOLEAN:
+	return seed_value_from_boolean(arg->v_boolean, exception);
+    case GI_TYPE_TAG_INT8:
+	return seed_value_from_char(arg->v_int8, exception);
+    case GI_TYPE_TAG_UINT8:
+	return seed_value_from_uchar(arg->v_uint8, exception);
+    case GI_TYPE_TAG_INT16:
+	return seed_value_from_int(arg->v_int16, exception);
+    case GI_TYPE_TAG_UINT16:
+	return seed_value_from_uint(arg->v_uint16, exception);
+    case GI_TYPE_TAG_INT32:
+	return seed_value_from_int(arg->v_int32, exception);
+    case GI_TYPE_TAG_UINT32:
+	return seed_value_from_uint(arg->v_uint32, exception);
+    case GI_TYPE_TAG_LONG:
+    case GI_TYPE_TAG_INT64:
+	return seed_value_from_long(arg->v_int64, exception);
+    case GI_TYPE_TAG_ULONG:
+    case GI_TYPE_TAG_UINT64:
+	return seed_value_from_ulong(arg->v_uint64, exception);
+    case GI_TYPE_TAG_INT:
+	return seed_value_from_int(arg->v_int32, exception);
+    case GI_TYPE_TAG_UINT:
+	return seed_value_from_uint(arg->v_uint32, exception);
+    case GI_TYPE_TAG_SSIZE:
+    case GI_TYPE_TAG_SIZE:
+	return seed_value_from_int(arg->v_int, exception);
+    case GI_TYPE_TAG_FLOAT:
+	return seed_value_from_float(arg->v_float, exception);
+    case GI_TYPE_TAG_DOUBLE:
+	return seed_value_from_double(arg->v_double, exception);
+    case GI_TYPE_TAG_UTF8:
+	return seed_value_from_string(arg->v_string, exception);
+    case GI_TYPE_TAG_INTERFACE:
+	{
+	    GIBaseInfo *interface;
+	    GIInfoType interface_type;
+
+	    interface = g_type_info_get_interface(type_info);
+	    interface_type = g_base_info_get_type(interface);
+
+	    if (interface_type == GI_INFO_TYPE_OBJECT ||
+		interface_type == GI_INFO_TYPE_INTERFACE)
+	    {
+		if (arg->v_pointer == 0)
+		{
+		    return JSValueMakeNull(eng->context);
+		}
+		return seed_value_from_object(arg->v_pointer, exception);
+	    }
+	    else if (interface_type == GI_INFO_TYPE_ENUM
+		     || interface_type == GI_INFO_TYPE_FLAGS)
+	    {
 		return seed_value_from_double(arg->v_double, exception);
-	case GI_TYPE_TAG_UTF8:
-		return seed_value_from_string(arg->v_string, exception);
-	case GI_TYPE_TAG_INTERFACE:
-		{
-			GIBaseInfo *interface;
-			GIInfoType interface_type;
-
-			interface = g_type_info_get_interface(type_info);
-			interface_type = g_base_info_get_type(interface);
-
-			if (interface_type == GI_INFO_TYPE_OBJECT ||
-			    interface_type == GI_INFO_TYPE_INTERFACE)
-			{
-				if (arg->v_pointer == 0)
-				{
-					return JSValueMakeNull(eng->context);
-				}
-				return seed_value_from_object(arg->v_pointer,
-							      exception);
-			}
-			else if (interface_type == GI_INFO_TYPE_ENUM
-				 || interface_type == GI_INFO_TYPE_FLAGS)
-			{
-				return seed_value_from_double(arg->v_double,
-							      exception);
-			}
-			else if (interface_type == GI_INFO_TYPE_STRUCT)
-			{
-				return seed_make_struct(arg->v_pointer,
-							interface);
-			}
-		}
-	case GI_TYPE_TAG_GLIST:
-		{
-			GIBaseInfo *interface;
-			GITypeInfo *list_type;
-			JSObjectRef ret;
-			GArgument larg;
-			gint i = 0;
-			GList *list = arg->v_pointer;
-
-			ret = JSObjectMake(eng->context, NULL, NULL);
-			list_type = g_type_info_get_param_type(type_info, 0);
-
-			for (; list != NULL; list = list->next)
-			{
-				JSValueRef ival;
-
-				larg.v_pointer = list->data;
-				ival =
-				    (JSValueRef) seed_gi_argument_make_js(&larg,
-									  list_type,
-									  exception);
-				JSObjectSetPropertyAtIndex(eng->context, ret, i,
-							   ival, NULL);
-				i++;
-			}
-			return ret;
-
-		}
-	case GI_TYPE_TAG_GSLIST:
-		{
-
-			GIBaseInfo *interface;
-			GITypeInfo *list_type;
-			JSObjectRef ret;
-			GArgument larg;
-			gint i = 0;
-			GSList *list = arg->v_pointer;
-
-			ret = JSObjectMake(eng->context, NULL, NULL);
-			list_type = g_type_info_get_param_type(type_info, 0);
-
-			for (; list != NULL; list = list->next)
-			{
-				JSValueRef ival;
-
-				larg.v_pointer = list->data;
-				ival =
-				    (JSValueRef) seed_gi_argument_make_js(&larg,
-									  list_type,
-									  exception);
-				JSObjectSetPropertyAtIndex(eng->context, ret, i,
-							   ival, NULL);
-				i++;
-			}
-			return ret;
-		}
+	    }
+	    else if (interface_type == GI_INFO_TYPE_STRUCT)
+	    {
+		return seed_make_struct(arg->v_pointer, interface);
+	    }
+	}
+    case GI_TYPE_TAG_GLIST:
+	{
+	    GIBaseInfo *interface;
+	    GITypeInfo *list_type;
+	    JSObjectRef ret;
+	    GArgument larg;
+	    gint i = 0;
+	    GList *list = arg->v_pointer;
+
+	    ret = JSObjectMake(eng->context, NULL, NULL);
+	    list_type = g_type_info_get_param_type(type_info, 0);
+
+	    for (; list != NULL; list = list->next)
+	    {
+		JSValueRef ival;
+
+		larg.v_pointer = list->data;
+		ival =
+		    (JSValueRef) seed_gi_argument_make_js(&larg,
+							  list_type, exception);
+		JSObjectSetPropertyAtIndex(eng->context, ret, i, ival, NULL);
+		i++;
+	    }
+	    return ret;
+
+	}
+    case GI_TYPE_TAG_GSLIST:
+	{
+
+	    GIBaseInfo *interface;
+	    GITypeInfo *list_type;
+	    JSObjectRef ret;
+	    GArgument larg;
+	    gint i = 0;
+	    GSList *list = arg->v_pointer;
+
+	    ret = JSObjectMake(eng->context, NULL, NULL);
+	    list_type = g_type_info_get_param_type(type_info, 0);
+
+	    for (; list != NULL; list = list->next)
+	    {
+		JSValueRef ival;
+
+		larg.v_pointer = list->data;
+		ival =
+		    (JSValueRef) seed_gi_argument_make_js(&larg,
+							  list_type, exception);
+		JSObjectSetPropertyAtIndex(eng->context, ret, i, ival, NULL);
+		i++;
+	    }
+	    return ret;
+	}
 
-	default:
-		return FALSE;
+    default:
+	return FALSE;
 
-	}
-	return 0;
+    }
+    return 0;
 }
 
 gboolean seed_gi_supports_type(GITypeInfo * type_info)
 {
-	GITypeTag type_tag;
+    GITypeTag type_tag;
 
-	type_tag = g_type_info_get_tag(type_info);
+    type_tag = g_type_info_get_tag(type_info);
 
-	switch (type_tag)
-	{
-	case GI_TYPE_TAG_VOID:
-	case GI_TYPE_TAG_BOOLEAN:
-	case GI_TYPE_TAG_INT8:
-	case GI_TYPE_TAG_UINT8:
-	case GI_TYPE_TAG_INT16:
-	case GI_TYPE_TAG_UINT16:
-	case GI_TYPE_TAG_INT32:
-	case GI_TYPE_TAG_UINT32:
-	case GI_TYPE_TAG_INT64:
-	case GI_TYPE_TAG_UINT64:
-	case GI_TYPE_TAG_INT:
-	case GI_TYPE_TAG_UINT:
-	case GI_TYPE_TAG_LONG:
-	case GI_TYPE_TAG_ULONG:
-	case GI_TYPE_TAG_SSIZE:
-	case GI_TYPE_TAG_SIZE:
-	case GI_TYPE_TAG_FLOAT:
-	case GI_TYPE_TAG_DOUBLE:
-	case GI_TYPE_TAG_UTF8:
-	case GI_TYPE_TAG_INTERFACE:
-		return TRUE;
-
-	case GI_TYPE_TAG_FILENAME:
-	case GI_TYPE_TAG_ARRAY:
-	case GI_TYPE_TAG_GLIST:
-	case GI_TYPE_TAG_GSLIST:
-	case GI_TYPE_TAG_GHASH:
-	case GI_TYPE_TAG_ERROR:
-		// We should support time_t easily.
-	case GI_TYPE_TAG_TIME_T:
-	case GI_TYPE_TAG_GTYPE:
-		return FALSE;
+    switch (type_tag)
+    {
+    case GI_TYPE_TAG_VOID:
+    case GI_TYPE_TAG_BOOLEAN:
+    case GI_TYPE_TAG_INT8:
+    case GI_TYPE_TAG_UINT8:
+    case GI_TYPE_TAG_INT16:
+    case GI_TYPE_TAG_UINT16:
+    case GI_TYPE_TAG_INT32:
+    case GI_TYPE_TAG_UINT32:
+    case GI_TYPE_TAG_INT64:
+    case GI_TYPE_TAG_UINT64:
+    case GI_TYPE_TAG_INT:
+    case GI_TYPE_TAG_UINT:
+    case GI_TYPE_TAG_LONG:
+    case GI_TYPE_TAG_ULONG:
+    case GI_TYPE_TAG_SSIZE:
+    case GI_TYPE_TAG_SIZE:
+    case GI_TYPE_TAG_FLOAT:
+    case GI_TYPE_TAG_DOUBLE:
+    case GI_TYPE_TAG_UTF8:
+    case GI_TYPE_TAG_INTERFACE:
+	return TRUE;
 
-	}
+    case GI_TYPE_TAG_FILENAME:
+    case GI_TYPE_TAG_ARRAY:
+    case GI_TYPE_TAG_GLIST:
+    case GI_TYPE_TAG_GSLIST:
+    case GI_TYPE_TAG_GHASH:
+    case GI_TYPE_TAG_ERROR:
+	// We should support time_t easily.
+    case GI_TYPE_TAG_TIME_T:
+    case GI_TYPE_TAG_GTYPE:
 	return FALSE;
+
+    }
+    return FALSE;
 }
 
 SeedValue seed_value_from_gvalue(GValue * gval, JSValueRef * exception)
 {
-	if (!G_IS_VALUE(gval))
-	{
-		return false;
+    if (!G_IS_VALUE(gval))
+    {
+	return false;
+    }
+    switch (G_VALUE_TYPE(gval))
+    {
+    case G_TYPE_BOOLEAN:
+	return seed_value_from_boolean(g_value_get_boolean(gval), exception);
+    case G_TYPE_CHAR:
+	return seed_value_from_char(g_value_get_char(gval), exception);
+    case G_TYPE_UCHAR:
+	return seed_value_from_uchar(g_value_get_uchar(gval), exception);
+    case G_TYPE_INT:
+	return seed_value_from_int(g_value_get_int(gval), exception);
+    case G_TYPE_UINT:
+	return seed_value_from_uint(g_value_get_uint(gval), exception);
+    case G_TYPE_LONG:
+	return seed_value_from_long(g_value_get_long(gval), exception);
+    case G_TYPE_ULONG:
+	return seed_value_from_ulong(g_value_get_ulong(gval), exception);
+    case G_TYPE_INT64:
+	return seed_value_from_int64(g_value_get_int64(gval), exception);
+    case G_TYPE_UINT64:
+	return seed_value_from_uint64(g_value_get_uint64(gval), exception);
+    case G_TYPE_FLOAT:
+	return seed_value_from_float(g_value_get_float(gval), exception);
+    case G_TYPE_DOUBLE:
+	return seed_value_from_double(g_value_get_double(gval), exception);
+    case G_TYPE_STRING:
+	return seed_value_from_string((gchar *)
+				      g_value_get_string(gval), exception);
+    case G_TYPE_POINTER:
+	return seed_make_struct(g_value_get_pointer(gval), 0);
+    }
+
+    if (g_type_is_a(G_VALUE_TYPE(gval), G_TYPE_ENUM) ||
+	g_type_is_a(G_VALUE_TYPE(gval), G_TYPE_FLAGS))
+	return seed_value_from_long(gval->data[0].v_long, exception);
+    else if (g_type_is_a(G_VALUE_TYPE(gval), G_TYPE_ENUM))
+	return seed_value_from_long(gval->data[0].v_long, exception);
+    else if (g_type_is_a(G_VALUE_TYPE(gval), G_TYPE_OBJECT))
+    {
+	// TODO: check for leaks
+	return seed_value_from_object(g_value_get_object(gval), exception);
+    }
+    else
+    {
+	GIBaseInfo *info;
+	GIInfoType type;
+
+	info = g_irepository_find_by_gtype(0, G_VALUE_TYPE(gval));
+	type = g_base_info_get_type(info);
+
+	if (type == GI_INFO_TYPE_UNION)
+	{
+	    return seed_make_union(g_value_peek_pointer(gval), info);
+
+	}
+	else if (type == GI_INFO_TYPE_STRUCT)
+	{
+	    return seed_make_struct(g_value_peek_pointer(gval), info);
+
 	}
-	switch (G_VALUE_TYPE(gval))
-	{
-	case G_TYPE_BOOLEAN:
-		return seed_value_from_boolean(g_value_get_boolean(gval),
-					       exception);
-	case G_TYPE_CHAR:
-		return seed_value_from_char(g_value_get_char(gval), exception);
-	case G_TYPE_UCHAR:
-		return seed_value_from_uchar(g_value_get_uchar(gval),
-					     exception);
-	case G_TYPE_INT:
-		return seed_value_from_int(g_value_get_int(gval), exception);
-	case G_TYPE_UINT:
-		return seed_value_from_uint(g_value_get_uint(gval), exception);
-	case G_TYPE_LONG:
-		return seed_value_from_long(g_value_get_long(gval), exception);
-	case G_TYPE_ULONG:
-		return seed_value_from_ulong(g_value_get_ulong(gval),
-					     exception);
-	case G_TYPE_INT64:
-		return seed_value_from_int64(g_value_get_int64(gval),
-					     exception);
-	case G_TYPE_UINT64:
-		return seed_value_from_uint64(g_value_get_uint64(gval),
-					      exception);
-	case G_TYPE_FLOAT:
-		return seed_value_from_float(g_value_get_float(gval),
-					     exception);
-	case G_TYPE_DOUBLE:
-		return seed_value_from_double(g_value_get_double(gval),
-					      exception);
-	case G_TYPE_STRING:
-		return seed_value_from_string((gchar *)
-					      g_value_get_string(gval),
-					      exception);
-	case G_TYPE_POINTER:
-		return seed_make_struct(g_value_get_pointer(gval), 0);
-	}
-
-	if (g_type_is_a(G_VALUE_TYPE(gval), G_TYPE_ENUM) ||
-	    g_type_is_a(G_VALUE_TYPE(gval), G_TYPE_FLAGS))
-		return seed_value_from_long(gval->data[0].v_long, exception);
-	else if (g_type_is_a(G_VALUE_TYPE(gval), G_TYPE_ENUM))
-		return seed_value_from_long(gval->data[0].v_long, exception);
-	else if (g_type_is_a(G_VALUE_TYPE(gval), G_TYPE_OBJECT))
-	{
-		// TODO: check for leaks
-		return seed_value_from_object(g_value_get_object(gval),
-					      exception);
-	}
-	else
+	else if (type == GI_INFO_TYPE_BOXED)
 	{
-		GIBaseInfo *info;
-		GIInfoType type;
-
-		info = g_irepository_find_by_gtype(0, G_VALUE_TYPE(gval));
-		type = g_base_info_get_type(info);
-
-		if (type == GI_INFO_TYPE_UNION)
-		{
-			return seed_make_union(g_value_peek_pointer(gval),
-					       info);
-
-		}
-		else if (type == GI_INFO_TYPE_STRUCT)
-		{
-			return seed_make_struct(g_value_peek_pointer(gval),
-						info);
-
-		}
-		else if (type == GI_INFO_TYPE_BOXED)
-		{
-			printf("Trying to marshal boxed type \n");
-		}
-
+	    printf("Trying to marshal boxed type \n");
 	}
 
-	return NULL;
+    }
+
+    return NULL;
 }
 
 gboolean
 seed_gvalue_from_seed_value(SeedValue val, GType type, GValue * ret,
 			    JSValueRef * exception)
 {
-	switch (type)
+    switch (type)
+    {
+    case G_TYPE_BOOLEAN:
+	{
+	    /*
+	     * This is fail. Need to call seed_gvalue_from_seed_value with 
+	     * no type, and then try gobject cast. 
+	     */
+	    // if(!JSValueIsBoolean(eng->context, val))
+	    // goto bad_type;
+
+	    g_value_init(ret, G_TYPE_BOOLEAN);
+	    g_value_set_boolean(ret, seed_value_to_boolean(val, exception));
+	    return TRUE;
+	}
+    case G_TYPE_INT:
+    case G_TYPE_UINT:
+	{
+	    g_value_init(ret, type);
+	    if (type == G_TYPE_INT)
+		g_value_set_int(ret, seed_value_to_int(val, exception));
+	    else
+		g_value_set_uint(ret, seed_value_to_uint(val, exception));
+	    return TRUE;
+	}
+    case G_TYPE_CHAR:
+	{
+	    g_value_init(ret, G_TYPE_CHAR);
+	    g_value_set_char(ret, seed_value_to_char(val, exception));
+	    return TRUE;
+	}
+    case G_TYPE_UCHAR:
+	{
+	    g_value_init(ret, G_TYPE_UCHAR);
+	    g_value_set_uchar(ret, seed_value_to_uchar(val, exception));
+	    return TRUE;
+	}
+    case G_TYPE_LONG:
+    case G_TYPE_ULONG:
+    case G_TYPE_INT64:
+    case G_TYPE_UINT64:
+    case G_TYPE_FLOAT:
+    case G_TYPE_DOUBLE:
+	{
+	    switch (type)
+	    {
+	    case G_TYPE_LONG:
+		g_value_init(ret, G_TYPE_LONG);
+		g_value_set_long(ret, seed_value_to_long(val, exception));
+		break;
+	    case G_TYPE_ULONG:
+		g_value_init(ret, G_TYPE_ULONG);
+		g_value_set_ulong(ret, seed_value_to_ulong(val, exception));
+		break;
+	    case G_TYPE_INT64:
+		g_value_init(ret, G_TYPE_INT64);
+		g_value_set_int64(ret, seed_value_to_int64(val, exception));
+		break;
+	    case G_TYPE_UINT64:
+		g_value_init(ret, G_TYPE_UINT64);
+		g_value_set_uint64(ret, seed_value_to_uint64(val, exception));
+		break;
+	    case G_TYPE_FLOAT:
+		g_value_init(ret, G_TYPE_FLOAT);
+		g_value_set_float(ret, seed_value_to_float(val, exception));
+		break;
+	    case G_TYPE_DOUBLE:
+		g_value_init(ret, G_TYPE_DOUBLE);
+		g_value_set_double(ret, seed_value_to_double(val, exception));
+		break;
+	    }
+	    return TRUE;
+	}
+    case G_TYPE_STRING:
 	{
-	case G_TYPE_BOOLEAN:
-		{
-			/*
-			 * This is fail. Need to call seed_gvalue_from_seed_value with 
-			 * no type, and then try gobject cast. 
-			 */
-			// if(!JSValueIsBoolean(eng->context, val))
-			// goto bad_type;
-
-			g_value_init(ret, G_TYPE_BOOLEAN);
-			g_value_set_boolean(ret,
-					    seed_value_to_boolean(val,
-								  exception));
-			return TRUE;
-		}
-	case G_TYPE_INT:
-	case G_TYPE_UINT:
-		{
-			g_value_init(ret, type);
-			if (type == G_TYPE_INT)
-				g_value_set_int(ret,
-						seed_value_to_int(val,
-								  exception));
-			else
-				g_value_set_uint(ret,
-						 seed_value_to_uint(val,
-								    exception));
-			return TRUE;
-		}
-	case G_TYPE_CHAR:
+	    gchar *cval = seed_value_to_string(val, exception);
+
+	    g_value_init(ret, G_TYPE_STRING);
+	    g_value_take_string(ret, cval);
+
+	    return TRUE;
+	}
+    default:
+	{
+	    switch (JSValueGetType(eng->context, val))
+	    {
+	    case kJSTypeBoolean:
 		{
-			g_value_init(ret, G_TYPE_CHAR);
-			g_value_set_char(ret,
-					 seed_value_to_char(val, exception));
-			return TRUE;
+		    g_value_init(ret, G_TYPE_BOOLEAN);
+		    g_value_set_boolean(ret,
+					seed_value_to_boolean(val, exception));
+		    return TRUE;
 		}
-	case G_TYPE_UCHAR:
+	    case kJSTypeNumber:
 		{
-			g_value_init(ret, G_TYPE_UCHAR);
-			g_value_set_uchar(ret,
-					  seed_value_to_uchar(val, exception));
-			return TRUE;
+		    g_value_init(ret, G_TYPE_DOUBLE);
+		    g_value_set_double(ret,
+				       seed_value_to_double(val, exception));
+		    return TRUE;
 		}
-	case G_TYPE_LONG:
-	case G_TYPE_ULONG:
-	case G_TYPE_INT64:
-	case G_TYPE_UINT64:
-	case G_TYPE_FLOAT:
-	case G_TYPE_DOUBLE:
+	    case kJSTypeString:
 		{
-			switch (type)
-			{
-			case G_TYPE_LONG:
-				g_value_init(ret, G_TYPE_LONG);
-				g_value_set_long(ret,
-						 seed_value_to_long(val,
-								    exception));
-				break;
-			case G_TYPE_ULONG:
-				g_value_init(ret, G_TYPE_ULONG);
-				g_value_set_ulong(ret,
-						  seed_value_to_ulong(val,
-								      exception));
-				break;
-			case G_TYPE_INT64:
-				g_value_init(ret, G_TYPE_INT64);
-				g_value_set_int64(ret,
-						  seed_value_to_int64(val,
-								      exception));
-				break;
-			case G_TYPE_UINT64:
-				g_value_init(ret, G_TYPE_UINT64);
-				g_value_set_uint64(ret,
-						   seed_value_to_uint64(val,
-									exception));
-				break;
-			case G_TYPE_FLOAT:
-				g_value_init(ret, G_TYPE_FLOAT);
-				g_value_set_float(ret,
-						  seed_value_to_float(val,
-								      exception));
-				break;
-			case G_TYPE_DOUBLE:
-				g_value_init(ret, G_TYPE_DOUBLE);
-				g_value_set_double(ret,
-						   seed_value_to_double(val,
-									exception));
-				break;
-			}
-			return TRUE;
-		}
-	case G_TYPE_STRING:
-		{
-			gchar *cval = seed_value_to_string(val, exception);
-
-			g_value_init(ret, G_TYPE_STRING);
-			g_value_take_string(ret, cval);
+		    gchar *cv = seed_value_to_string(val,
+						     exception);
 
-			return TRUE;
-		}
-	default:
-		{
-			switch (JSValueGetType(eng->context, val))
-			{
-			case kJSTypeBoolean:
-				{
-					g_value_init(ret, G_TYPE_BOOLEAN);
-					g_value_set_boolean(ret,
-							    seed_value_to_boolean
-							    (val, exception));
-					return TRUE;
-				}
-			case kJSTypeNumber:
-				{
-					g_value_init(ret, G_TYPE_DOUBLE);
-					g_value_set_double(ret,
-							   seed_value_to_double
-							   (val, exception));
-					return TRUE;
-				}
-			case kJSTypeString:
-				{
-					gchar *cv = seed_value_to_string(val,
-									 exception);
-
-					g_value_init(ret, G_TYPE_STRING);
-					g_value_take_string(ret, cv);
-					return TRUE;
-				}
-			default:
-				break;
-			}
-			break;
+		    g_value_init(ret, G_TYPE_STRING);
+		    g_value_take_string(ret, cv);
+		    return TRUE;
 		}
+	    default:
+		break;
+	    }
+	    break;
 	}
+    }
 
-	if (g_type_is_a(type, G_TYPE_ENUM)
-	    && JSValueIsNumber(eng->context, val))
-	{
-		g_value_init(ret, type);
-		ret->data[0].v_long = seed_value_to_long(val, exception);
-		return TRUE;
-	}
-	else if (g_type_is_a(type, G_TYPE_FLAGS)
-		 && JSValueIsNumber(eng->context, val))
-	{
-		g_value_init(ret, type);
-		ret->data[0].v_long = seed_value_to_long(val, exception);
-		return TRUE;
-	}
-	else if (g_type_is_a(type, G_TYPE_OBJECT)
-		 && (JSValueIsNull(eng->context, val)
-		     || seed_value_is_gobject(val)))
-	{
-		GObject *o = seed_value_to_object(val, exception);
-
-		if (o == NULL || g_type_is_a(G_OBJECT_TYPE(o), type))
-		{
-			g_value_init(ret, G_TYPE_OBJECT);
-			g_value_set_object(ret, o);
-			return TRUE;
-		}
-
-		g_object_unref(o);
-	}
-	else if (g_type_is_a(type, G_TYPE_BOXED))
-	{
-		gpointer p = seed_struct_get_pointer(val);
-		if (p)
-		{
-			g_value_init(ret, type);
-			g_value_set_boxed(ret, p);
-			return TRUE;
-		}
+    if (g_type_is_a(type, G_TYPE_ENUM) && JSValueIsNumber(eng->context, val))
+    {
+	g_value_init(ret, type);
+	ret->data[0].v_long = seed_value_to_long(val, exception);
+	return TRUE;
+    }
+    else if (g_type_is_a(type, G_TYPE_FLAGS)
+	     && JSValueIsNumber(eng->context, val))
+    {
+	g_value_init(ret, type);
+	ret->data[0].v_long = seed_value_to_long(val, exception);
+	return TRUE;
+    }
+    else if (g_type_is_a(type, G_TYPE_OBJECT)
+	     && (JSValueIsNull(eng->context, val)
+		 || seed_value_is_gobject(val)))
+    {
+	GObject *o = seed_value_to_object(val, exception);
+
+	if (o == NULL || g_type_is_a(G_OBJECT_TYPE(o), type))
+	{
+	    g_value_init(ret, G_TYPE_OBJECT);
+	    g_value_set_object(ret, o);
+	    return TRUE;
+	}
+
+	g_object_unref(o);
+    }
+    else if (g_type_is_a(type, G_TYPE_BOXED))
+    {
+	gpointer p = seed_struct_get_pointer(val);
+	if (p)
+	{
+	    g_value_init(ret, type);
+	    g_value_set_boxed(ret, p);
+	    return TRUE;
 	}
+    }
 
-	return FALSE;
+    return FALSE;
 }
 
 SeedValue seed_value_get_property(SeedValue val, const gchar * name)
 {
 
-	JSStringRef jname = JSStringCreateWithUTF8CString(name);
-	JSValueRef ret = JSObjectGetProperty(eng->context,
-					     (JSObjectRef) val,
-					     jname, NULL);
+    JSStringRef jname = JSStringCreateWithUTF8CString(name);
+    JSValueRef ret = JSObjectGetProperty(eng->context,
+					 (JSObjectRef) val,
+					 jname, NULL);
 
-	JSStringRelease(jname);
+    JSStringRelease(jname);
 
-	return ret;
+    return ret;
 }
 
 gboolean
 seed_value_set_property(JSObjectRef object,
 			const gchar * name, JSValueRef value)
 {
-	JSStringRef jname = JSStringCreateWithUTF8CString(name);
+    JSStringRef jname = JSStringCreateWithUTF8CString(name);
 
-	if (value)
-	{
-		JSObjectSetProperty(eng->context, (JSObjectRef) object,
-				    jname, value, 0, 0);
-	}
+    if (value)
+    {
+	JSObjectSetProperty(eng->context, (JSObjectRef) object,
+			    jname, value, 0, 0);
+    }
 
-	JSStringRelease(jname);
+    JSStringRelease(jname);
 
-	return TRUE;
+    return TRUE;
 }
 
 gboolean seed_value_to_boolean(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsBoolean(eng->context, val))
-	{
-		if (!JSValueIsNull(eng->context, val))
-		{
-			seed_make_exception(exception, "ConversionError",
-					    "Can not convert Javascript value to boolean");
-			return 0;
-		}
-
-		return 0;
+    if (!JSValueIsBoolean(eng->context, val))
+    {
+	if (!JSValueIsNull(eng->context, val))
+	{
+	    seed_make_exception(exception, "ConversionError",
+				"Can not convert Javascript value to boolean");
+	    return 0;
 	}
 
-	return JSValueToBoolean(eng->context, val);
+	return 0;
+    }
+
+    return JSValueToBoolean(eng->context, val);
 }
 
 JSValueRef seed_value_from_boolean(gboolean val, JSValueRef * exception)
 {
-	return JSValueMakeBoolean(eng->context, val);
+    return JSValueMakeBoolean(eng->context, val);
 }
 
 guint seed_value_to_uint(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val))
-	{
-		if (!JSValueIsNull(eng->context, val))
-		{
-			seed_make_exception(exception, "ConversionError",
-					    "Can not convert Javascript value to"
-					    " boolean");
-		}
-		return 0;
+    if (!JSValueIsNumber(eng->context, val))
+    {
+	if (!JSValueIsNull(eng->context, val))
+	{
+	    seed_make_exception(exception, "ConversionError",
+				"Can not convert Javascript value to"
+				" boolean");
 	}
+	return 0;
+    }
 
-	return (guint) JSValueToNumber(eng->context, val, NULL);
+    return (guint) JSValueToNumber(eng->context, val, NULL);
 }
 
 JSValueRef seed_value_from_uint(guint val, JSValueRef * exception)
 {
-	return JSValueMakeNumber(eng->context, (gdouble) val);
+    return JSValueMakeNumber(eng->context, (gdouble) val);
 }
 
 gint seed_value_to_int(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val))
-	{
-		if (!JSValueIsNull(eng->context, val))
-			seed_make_exception(exception, "ConversionError",
-					    "Can not convert Javascript value to"
-					    " int");
-		return 0;
-	}
+    if (!JSValueIsNumber(eng->context, val))
+    {
+	if (!JSValueIsNull(eng->context, val))
+	    seed_make_exception(exception, "ConversionError",
+				"Can not convert Javascript value to" " int");
+	return 0;
+    }
 
-	return (gint) JSValueToNumber(eng->context, val, NULL);
+    return (gint) JSValueToNumber(eng->context, val, NULL);
 }
 
 JSValueRef seed_value_from_int(gint val, JSValueRef * exception)
 {
-	return JSValueMakeNumber(eng->context, (gdouble) val);
+    return JSValueMakeNumber(eng->context, (gdouble) val);
 }
 
 gchar seed_value_to_char(JSValueRef val, JSValueRef * exception)
 {
-	gint cv;
+    gint cv;
 
-	if (!JSValueIsNumber(eng->context, val))
-	{
-		if (!JSValueIsNull(eng->context, val))
-			seed_make_exception(exception, "ConversionError",
-					    "Can not convert Javascript value to"
-					    " gchar");
-		return 0;
-	}
+    if (!JSValueIsNumber(eng->context, val))
+    {
+	if (!JSValueIsNull(eng->context, val))
+	    seed_make_exception(exception, "ConversionError",
+				"Can not convert Javascript value to" " gchar");
+	return 0;
+    }
 
-	cv = JSValueToNumber(eng->context, val, NULL);
+    cv = JSValueToNumber(eng->context, val, NULL);
 
-	if (cv < G_MININT8 || cv > G_MAXINT8)
-	{
-		seed_make_exception(exception, "ConversionError",
-				    "Javascript number out of range of gchar");
-		return 0;
-	}
+    if (cv < G_MININT8 || cv > G_MAXINT8)
+    {
+	seed_make_exception(exception, "ConversionError",
+			    "Javascript number out of range of gchar");
+	return 0;
+    }
 
-	return (char)cv;
+    return (char)cv;
 }
 
 JSValueRef seed_value_from_char(gchar val, JSValueRef * exception)
 {
-	return JSValueMakeNumber(eng->context, (gdouble) val);
+    return JSValueMakeNumber(eng->context, (gdouble) val);
 }
 
 guchar seed_value_to_uchar(JSValueRef val, JSValueRef * exception)
 {
-	guint cv;
+    guint cv;
 
-	if (!JSValueIsNumber(eng->context, val))
-	{
-		if (!JSValueIsNull(eng->context, val))
-			seed_make_exception(exception, "ConversionError",
-					    "Can not convert Javascript value to"
-					    " guchar");
-		return 0;
-	}
+    if (!JSValueIsNumber(eng->context, val))
+    {
+	if (!JSValueIsNull(eng->context, val))
+	    seed_make_exception(exception, "ConversionError",
+				"Can not convert Javascript value to"
+				" guchar");
+	return 0;
+    }
 
-	cv = JSValueToNumber(eng->context, val, NULL);
+    cv = JSValueToNumber(eng->context, val, NULL);
 
-	if (cv > G_MAXUINT8)
-	{
-		seed_make_exception(exception, "ConversionError",
-				    "Javascript number out of range of guchar");
-		return 0;
-	}
+    if (cv > G_MAXUINT8)
+    {
+	seed_make_exception(exception, "ConversionError",
+			    "Javascript number out of range of guchar");
+	return 0;
+    }
 
-	return (guchar) cv;
+    return (guchar) cv;
 }
 
 JSValueRef seed_value_from_uchar(guchar val, JSValueRef * exception)
 {
-	return JSValueMakeNumber(eng->context, (gdouble) val);
+    return JSValueMakeNumber(eng->context, (gdouble) val);
 }
 
 glong seed_value_to_long(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val))
-	{
-		if (!JSValueIsNull(eng->context, val))
-			seed_make_exception(exception, "ConversionError",
-					    "Can not convert Javascript value to"
-					    " long");
-		return 0;
-	}
+    if (!JSValueIsNumber(eng->context, val))
+    {
+	if (!JSValueIsNull(eng->context, val))
+	    seed_make_exception(exception, "ConversionError",
+				"Can not convert Javascript value to" " long");
+	return 0;
+    }
 
-	return (glong) JSValueToNumber(eng->context, val, NULL);
+    return (glong) JSValueToNumber(eng->context, val, NULL);
 }
 
 JSValueRef seed_value_from_long(glong val, JSValueRef * exception)
 {
-	return JSValueMakeNumber(eng->context, (gdouble) val);
+    return JSValueMakeNumber(eng->context, (gdouble) val);
 }
 
 gulong seed_value_to_ulong(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val))
-	{
-		if (!JSValueIsNull(eng->context, val))
-			seed_make_exception(exception, "ConversionError",
-					    "Can not convert Javascript value to"
-					    " ulong");
+    if (!JSValueIsNumber(eng->context, val))
+    {
+	if (!JSValueIsNull(eng->context, val))
+	    seed_make_exception(exception, "ConversionError",
+				"Can not convert Javascript value to" " ulong");
 
-		return 0;
-	}
+	return 0;
+    }
 
-	return (gulong) JSValueToNumber(eng->context, val, NULL);
+    return (gulong) JSValueToNumber(eng->context, val, NULL);
 }
 
 JSValueRef seed_value_from_ulong(gulong val, JSValueRef * exception)
 {
-	return JSValueMakeNumber(eng->context, (gdouble) val);
+    return JSValueMakeNumber(eng->context, (gdouble) val);
 }
 
 gint64 seed_value_to_int64(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val))
-	{
-		if (!JSValueIsNull(eng->context, val))
-			seed_make_exception(exception, "ConversionError",
-					    "Can not convert Javascript value to"
-					    " gint64");
+    if (!JSValueIsNumber(eng->context, val))
+    {
+	if (!JSValueIsNull(eng->context, val))
+	    seed_make_exception(exception, "ConversionError",
+				"Can not convert Javascript value to"
+				" gint64");
 
-		return 0;
-	}
+	return 0;
+    }
 
-	return (gint64) JSValueToNumber(eng->context, val, NULL);
+    return (gint64) JSValueToNumber(eng->context, val, NULL);
 }
 
 JSValueRef seed_value_from_int64(gint64 val, JSValueRef * exception)
 {
-	return JSValueMakeNumber(eng->context, (gdouble) val);
+    return JSValueMakeNumber(eng->context, (gdouble) val);
 }
 
 guint64 seed_value_to_uint64(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val))
-	{
-		if (!JSValueIsNull(eng->context, val))
-			seed_make_exception(exception, "ConversionError",
-					    "Can not convert Javascript value to"
-					    " guint64");
+    if (!JSValueIsNumber(eng->context, val))
+    {
+	if (!JSValueIsNull(eng->context, val))
+	    seed_make_exception(exception, "ConversionError",
+				"Can not convert Javascript value to"
+				" guint64");
 
-		return 0;
-	}
+	return 0;
+    }
 
-	return (guint64) JSValueToNumber(eng->context, val, NULL);
+    return (guint64) JSValueToNumber(eng->context, val, NULL);
 }
 
 JSValueRef seed_value_from_uint64(guint64 val, JSValueRef * exception)
 {
-	return JSValueMakeNumber(eng->context, (gdouble) val);
+    return JSValueMakeNumber(eng->context, (gdouble) val);
 }
 
 gfloat seed_value_to_float(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val))
-	{
-		if (!JSValueIsNull(eng->context, val))
-			seed_make_exception(exception, "ConversionError",
-					    "Can not convert Javascript value to"
-					    " gfloat");
-		return 0;
-	}
+    if (!JSValueIsNumber(eng->context, val))
+    {
+	if (!JSValueIsNull(eng->context, val))
+	    seed_make_exception(exception, "ConversionError",
+				"Can not convert Javascript value to"
+				" gfloat");
+	return 0;
+    }
 
-	return (gfloat) JSValueToNumber(eng->context, val, NULL);
+    return (gfloat) JSValueToNumber(eng->context, val, NULL);
 }
 
 JSValueRef seed_value_from_float(gfloat val, JSValueRef * exception)
 {
-	return JSValueMakeNumber(eng->context, (gdouble) val);
+    return JSValueMakeNumber(eng->context, (gdouble) val);
 }
 
 gdouble seed_value_to_double(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val))
-	{
-		if (!JSValueIsNull(eng->context, val))
-			seed_make_exception(exception, "ConversionError",
-					    "Can not convert Javascript value to"
-					    " double");
-		return 0;
-	}
+    if (!JSValueIsNumber(eng->context, val))
+    {
+	if (!JSValueIsNull(eng->context, val))
+	    seed_make_exception(exception, "ConversionError",
+				"Can not convert Javascript value to"
+				" double");
+	return 0;
+    }
 
-	return (gdouble) JSValueToNumber(eng->context, val, NULL);
+    return (gdouble) JSValueToNumber(eng->context, val, NULL);
 }
 
 JSValueRef seed_value_from_double(gdouble val, JSValueRef * exception)
 {
-	return JSValueMakeNumber(eng->context, (gdouble) val);
+    return JSValueMakeNumber(eng->context, (gdouble) val);
 }
 
 gchar *seed_value_to_string(JSValueRef val, JSValueRef * exception)
 {
-	JSStringRef jsstr = 0;
-	JSValueRef func, str;
-	gchar *buf;
-	gint length;
-
-	if (val == NULL)
-		return NULL;
+    JSStringRef jsstr = 0;
+    JSValueRef func, str;
+    gchar *buf;
+    gint length;
 
-	if (JSValueIsBoolean(eng->context, val)
-	    || JSValueIsNumber(eng->context, val))
-	{
-		buf =
-		    g_strdup_printf("%f",
-				    JSValueToNumber(eng->context, val, NULL));
-	}
-	else if (JSValueIsNull(eng->context, val)
-		 || JSValueIsUndefined(eng->context, val))
-	{
-		buf = strdup("[null]");
-	}
-	else
-	{
-		if (!JSValueIsString(eng->context, val))	// In this case,
-			// it's an object
-		{
-			func = seed_value_get_property(val, "toString");
-			str =
-			    JSObjectCallAsFunction(eng->context,
-						   (JSObjectRef) func,
-						   (JSObjectRef) val, 0, NULL,
-						   NULL);
-		}
+    if (val == NULL)
+	return NULL;
 
-		jsstr = JSValueToStringCopy(eng->context, val, NULL);
-		length = JSStringGetMaximumUTF8CStringSize(jsstr);
-		buf = g_malloc(length * sizeof(gchar));
-		JSStringGetUTF8CString(jsstr, buf, length);
-		if (jsstr)
-			JSStringRelease(jsstr);
-	}
+    if (JSValueIsBoolean(eng->context, val)
+	|| JSValueIsNumber(eng->context, val))
+    {
+	buf = g_strdup_printf("%f", JSValueToNumber(eng->context, val, NULL));
+    }
+    else if (JSValueIsNull(eng->context, val)
+	     || JSValueIsUndefined(eng->context, val))
+    {
+	buf = strdup("[null]");
+    }
+    else
+    {
+	if (!JSValueIsString(eng->context, val))	// In this case,
+	    // it's an object
+	{
+	    func = seed_value_get_property(val, "toString");
+	    str =
+		JSObjectCallAsFunction(eng->context,
+				       (JSObjectRef) func,
+				       (JSObjectRef) val, 0, NULL, NULL);
+	}
+
+	jsstr = JSValueToStringCopy(eng->context, val, NULL);
+	length = JSStringGetMaximumUTF8CStringSize(jsstr);
+	buf = g_malloc(length * sizeof(gchar));
+	JSStringGetUTF8CString(jsstr, buf, length);
+	if (jsstr)
+	    JSStringRelease(jsstr);
+    }
 
-	return buf;
+    return buf;
 }
 
 JSValueRef seed_value_from_string(const gchar * val, JSValueRef * exception)
 {
-	JSStringRef jsstr = JSStringCreateWithUTF8CString(val);
-	JSValueRef valstr = JSValueMakeString(eng->context, jsstr);
-	JSStringRelease(jsstr);
+    JSStringRef jsstr = JSStringCreateWithUTF8CString(val);
+    JSValueRef valstr = JSValueMakeString(eng->context, jsstr);
+    JSStringRelease(jsstr);
 
-	return valstr;
+    return valstr;
 }
 
 GObject *seed_value_to_object(JSValueRef val, JSValueRef * exception)
 {
-	GObject *gobject;
+    GObject *gobject;
 
-	if (!seed_value_is_gobject(val))
-	{
-		JSValueRef object;
-		if (!JSValueIsObject(eng->context, val))
-			return NULL;
-		object = seed_value_get_property(val, "gsuper");
-		if (val && object && JSValueIsObject(eng->context, object)) ;
-		{
-			JSValueRef ref_data = 0;
-			gobject = seed_value_to_object(object, exception);
-			if (gobject)
-			{
-				g_object_set_data(gobject, "js-ref",
-						  (gpointer) val);
-			}
-			return gobject;
-		}
+    if (!seed_value_is_gobject(val))
+    {
+	JSValueRef object;
+	if (!JSValueIsObject(eng->context, val))
+	    return NULL;
+	object = seed_value_get_property(val, "gsuper");
+	if (val && object && JSValueIsObject(eng->context, object)) ;
+	{
+	    JSValueRef ref_data = 0;
+	    gobject = seed_value_to_object(object, exception);
+	    if (gobject)
+	    {
+		g_object_set_data(gobject, "js-ref", (gpointer) val);
+	    }
+	    return gobject;
 	}
+    }
 
-	gobject = (GObject *) JSObjectGetPrivate((JSObjectRef) val);
+    gobject = (GObject *) JSObjectGetPrivate((JSObjectRef) val);
 
-	return gobject;
+    return gobject;
 }
 
 JSValueRef seed_value_from_object(GObject * val, JSValueRef * exception)
 {
-	if (val == NULL)
-		return JSValueMakeNull(eng->context);
-	else
-		return seed_wrap_object(val);
+    if (val == NULL)
+	return JSValueMakeNull(eng->context);
+    else
+	return seed_wrap_object(val);
 }



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