seed r183 - trunk/libseed



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

Log:
Add indent script and run it.


Added:
   trunk/libseed/indent.sh
Modified:
   trunk/libseed/seed-builtins.c
   trunk/libseed/seed-builtins.h
   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-gtype.h
   trunk/libseed/seed-private.h
   trunk/libseed/seed-signals.c
   trunk/libseed/seed-signals.h
   trunk/libseed/seed-structs.c
   trunk/libseed/seed-structs.h
   trunk/libseed/seed-types.c
   trunk/libseed/seed-types.h
   trunk/libseed/seed.h

Added: trunk/libseed/indent.sh
==============================================================================
--- (empty file)
+++ trunk/libseed/indent.sh	Sat Nov  8 01:41:15 2008
@@ -0,0 +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 \
+            -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:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-builtins.c
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -36,7 +38,8 @@
 	const gchar *import_file;
 	gchar *buffer, *walk;
 
-	if (argumentCount != 1) {
+	if (argumentCount != 1)
+	{
 		gchar *mes =
 		    g_strdup_printf("Seed.include expected 1 argument, "
 				    "got %d", argumentCount);
@@ -48,8 +51,10 @@
 
 	g_file_get_contents(import_file, &buffer, 0, 0);
 
-	if (!buffer) {
-		gchar * mes = g_strdup_printf("File not found: %s.\n", import_file);
+	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);
@@ -57,7 +62,8 @@
 
 	walk = buffer;
 
-	if (*walk == '#') {
+	if (*walk == '#')
+	{
 		while (*walk != '\n')
 			walk++;
 		walk++;
@@ -83,9 +89,11 @@
 	   size_t argumentCount,
 	   const JSValueRef arguments[], JSValueRef * exception)
 {
-	if (argumentCount != 1) {
-		gchar *mes = g_strdup_printf("Seed.print Expected 1 argument,"
-					     " got %d", argumentCount);
+	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);
@@ -113,7 +121,8 @@
 	gchar *str = 0;
 	gchar *buf;
 
-	if (argumentCount != 1) {
+	if (argumentCount != 1)
+	{
 		gchar *mes =
 		    g_strdup_printf("Seed.readline Expected 1 argument, "
 				    "got %d", argumentCount);
@@ -125,7 +134,8 @@
 	buf = seed_value_to_string(arguments[0], exception);
 
 	str = readline(buf);
-	if (str && *str) {
+	if (str && *str)
+	{
 		add_history(str);
 		valstr = seed_value_from_string(str, exception);
 		g_free(str);
@@ -171,11 +181,14 @@
 
 	const gchar *type_name;
 
-	if (type_tag == GI_TYPE_TAG_INTERFACE) {
+	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 {
+	}
+	else
+	{
 		type_name = g_type_tag_to_string(type_tag);
 	}
 
@@ -207,29 +220,30 @@
 
 	if (!JSValueIsObject(ctx, arguments[0]))
 		return JSValueMakeNull(ctx);
-	if (!JSValueIsObjectOfClass(ctx, arguments[0],
-				    gobject_method_class))
+	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_set_property(data_obj, "name", (JSValueRef)
 				seed_value_from_string(g_base_info_get_name
-									   ((GIBaseInfo *) info), exception));
+						       ((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));
+				 (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) {
+	for (i = 0; i < g_callable_info_get_n_args(info); ++i)
+	{
 		JSObjectRef argument = JSObjectMake(ctx, NULL, NULL);
 
 		const gchar *arg_name =
@@ -238,10 +252,10 @@
 						(info, i)));
 
 		seed_value_set_property(argument, "type",
-								seed_value_from_string(arg_name, exception));
+					seed_value_from_string(arg_name,
+							       exception));
 
-		JSObjectSetPropertyAtIndex(ctx, args_obj, i, argument,
-					   NULL);
+		JSObjectSetPropertyAtIndex(ctx, args_obj, i, argument, NULL);
 	}
 
 	return data_obj;
@@ -254,14 +268,17 @@
 		  size_t argumentCount,
 		  const JSValueRef arguments[], JSValueRef * exception)
 {
-	if (argumentCount != 0) {
+	if (argumentCount != 0)
+	{
 		JSStringRef jsstr = JSValueToStringCopy(ctx,
 							arguments[0],
 							exception);
 		JSCheckScriptSyntax(ctx, jsstr, 0, 0, exception);
 		if (jsstr)
 			JSStringRelease(jsstr);
-	} else {
+	}
+	else
+	{
 		gchar *mes = g_strdup_printf("Seed.check_syntax expected"
 					     "0 argument, got %d",
 					     argumentCount);
@@ -304,9 +321,9 @@
 {
 	// 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);
+	// GMainLoop* loop = g_main_loop_new(NULL,FALSE);
+	// if (!g_main_loop_is_running(loop))
+	// return JSValueMakeBoolean(ctx, 0);
 
 	if (argumentCount != 2)
 	{
@@ -330,72 +347,74 @@
 
 JSValueRef
 seed_closure(JSContextRef ctx,
-		 JSObjectRef function,
-		 JSObjectRef this_object,
-		 size_t argumentCount,
-		 const JSValueRef arguments[], JSValueRef * exception)
+	     JSObjectRef function,
+	     JSObjectRef this_object,
+	     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 
+JSValueRef
 seed_closure_native(JSContextRef ctx,
-		 JSObjectRef function,
-		 JSObjectRef this_object,
-		 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);
-		}
-		
-		info = (GICallableInfo *)
-				JSObjectGetPrivate((JSObjectRef)arguments[1]);
-		
-		privates = seed_make_native_closure(info, arguments[0]);
-		
-		return JSObjectMake(eng->context, seed_native_callback_class, privates);
+		    JSObjectRef function,
+		    JSObjectRef this_object,
+		    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);
+	}
+
+	info = (GICallableInfo *)
+	    JSObjectGetPrivate((JSObjectRef) arguments[1]);
+
+	privates = seed_make_native_closure(info, arguments[0]);
+
+	return JSObjectMake(eng->context, seed_native_callback_class, privates);
 }
 
-void seed_init_builtins(gint *argc, gchar ***argv)
+void seed_init_builtins(gint * argc, gchar *** argv)
 {
 	guint i;
 	JSObjectRef arrayObj;
@@ -416,12 +435,13 @@
 
 	arrayObj = JSObjectMake(eng->context, NULL, NULL);
 
-	for (i = 0; i < *argc; ++i) {
+	for (i = 0; i < *argc; ++i)
+	{
 		// TODO: exceptions!
 
 		JSObjectSetPropertyAtIndex(eng->context, arrayObj, i,
-								   seed_value_from_string((*argv)[i], 0),
-					   NULL);
+					   seed_value_from_string((*argv)[i],
+								  0), NULL);
 	}
 
 	argcref = seed_value_from_int(*argc, 0);
@@ -429,4 +449,3 @@
 	seed_value_set_property(arrayObj, "length", argcref);
 	seed_value_set_property(obj, "argv", arrayObj);
 }
-

Modified: trunk/libseed/seed-builtins.h
==============================================================================
--- trunk/libseed/seed-builtins.h	(original)
+++ trunk/libseed/seed-builtins.h	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-builtins.h
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -24,7 +26,6 @@
 
 // TODO: someday, maybe, move import_namespace here!
 
-
 JSValueRef
 seed_include(JSContextRef ctx,
 	     JSObjectRef function,

Modified: trunk/libseed/seed-closure.c
==============================================================================
--- trunk/libseed/seed-closure.c	(original)
+++ trunk/libseed/seed-closure.c	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-closure.c.h
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -19,15 +21,14 @@
 #include "seed-private.h"
 #include <sys/mman.h>
 
-static ffi_type *
-get_ffi_type (GITypeInfo *info)
+static ffi_type *get_ffi_type(GITypeInfo * info)
 {
 	ffi_type *rettype;
-		
-	if (g_type_info_is_pointer (info))
+
+	if (g_type_info_is_pointer(info))
 		rettype = &ffi_type_pointer;
 	else
-		switch (g_type_info_get_tag (info))
+		switch (g_type_info_get_tag(info))
 		{
 		case GI_TYPE_TAG_VOID:
 			rettype = &ffi_type_void;
@@ -65,12 +66,12 @@
 		case GI_TYPE_TAG_UINT:
 			rettype = &ffi_type_uint;
 			break;
-		case GI_TYPE_TAG_SSIZE: /* FIXME */
+		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_SIZE:	/* FIXME */
+		case GI_TYPE_TAG_TIME_T:	/* May not be portable */
 		case GI_TYPE_TAG_ULONG:
 			rettype = &ffi_type_ulong;
 			break;
@@ -91,17 +92,16 @@
 			rettype = &ffi_type_pointer;
 			break;
 		default:
-			g_assert_not_reached ();
+			g_assert_not_reached();
 		}
-		
+
 	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);
@@ -110,280 +110,291 @@
 }
 
 static void
-seed_handle_closure(ffi_cif *cif, 
-		    void * result, 
-		    void ** args, 
-		    void * userdata)
+seed_handle_closure(ffi_cif * cif, void *result, void **args, void *userdata)
 {
-	SeedNativeClosure * privates = userdata;
+	SeedNativeClosure *privates = userdata;
 	gint num_args, i;
-	JSValueRef * jsargs;
+	JSValueRef *jsargs;
 	JSValueRef return_value;
 	GITypeTag return_tag;
-	GIArgInfo * arg_info;
-	GITypeInfo * return_type;
+	GIArgInfo *arg_info;
+	GITypeInfo *return_type;
 	GArgument rarg;
-	GArgument * return_arg = g_new0(GArgument, 1);
-		
+	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);
-		
+	jsargs = (JSValueRef *) g_new0(JSValueRef, num_args);
+
 	for (i = 0; i < num_args; i++)
 	{
-		GITypeInfo * arg_type;
+		GITypeInfo *arg_type;
 		GITypeTag tag;
 		GType type;
-		GArgument * arg = &rarg;
-				
+		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)
+
+		switch (tag)
 		{
 		case GI_TYPE_TAG_BOOLEAN:
-			arg->v_boolean = *(gboolean*)args[i];
+			arg->v_boolean = *(gboolean *) args[i];
 			break;
 		case GI_TYPE_TAG_INT8:
-			arg->v_int8 = *(gint8*)args[i];
+			arg->v_int8 = *(gint8 *) args[i];
 			break;
 		case GI_TYPE_TAG_UINT8:
-			arg->v_uint8 = *(guint8*)args[i];
+			arg->v_uint8 = *(guint8 *) args[i];
 			break;
 		case GI_TYPE_TAG_INT16:
-			arg->v_int16 = *(gint16*)args[i];
+			arg->v_int16 = *(gint16 *) args[i];
 			break;
 		case GI_TYPE_TAG_UINT16:
-			arg->v_uint16 = *(guint16*)args[i];
+			arg->v_uint16 = *(guint16 *) args[i];
 			break;
 		case GI_TYPE_TAG_INT32:
-			arg->v_int32 = *(gint32*)args[i];
+			arg->v_int32 = *(gint32 *) args[i];
 			break;
 		case GI_TYPE_TAG_UINT32:
-			arg->v_uint32 = *(guint32*)args[i];
+			arg->v_uint32 = *(guint32 *) args[i];
 			break;
 		case GI_TYPE_TAG_LONG:
 		case GI_TYPE_TAG_INT64:
-			arg->v_int64 = *(glong*)args[i];
+			arg->v_int64 = *(glong *) args[i];
 			break;
 		case GI_TYPE_TAG_ULONG:
 		case GI_TYPE_TAG_UINT64:
-			arg->v_uint64 = *(glong*)args[i];
+			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];
+			arg->v_int32 = *(gint *) args[i];
 			break;
 		case GI_TYPE_TAG_UINT:
-			arg->v_uint32 = *(guint*)args[i];
+			arg->v_uint32 = *(guint *) args[i];
 			break;
 		case GI_TYPE_TAG_FLOAT:
-			arg->v_float = *(gfloat*)args[i];
+			arg->v_float = *(gfloat *) args[i];
 			break;
 		case GI_TYPE_TAG_DOUBLE:
-			arg->v_double = *(gdouble*)args[i];
+			arg->v_double = *(gdouble *) args[i];
 			break;
 		case GI_TYPE_TAG_UTF8:
-			arg->v_string = *(gchar **)args[i];
+			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;
+			{
+				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];
+			arg->v_pointer = *(gpointer *) args[i];
 			break;
 		default:
 			arg->v_pointer = 0;
 		}
 		jsargs[i] = seed_gi_argument_make_js(arg, arg_type, 0);
 	}
-		
-	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);
+	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;
+		*(gboolean *) result = return_arg->v_boolean;
+		break;
 	case GI_TYPE_TAG_INT8:
-			*(gint8*)result = return_arg->v_int8;
-			break;
+		*(gint8 *) result = return_arg->v_int8;
+		break;
 	case GI_TYPE_TAG_UINT8:
-			*(guint8*)result = return_arg->v_uint8;
-			break;
+		*(guint8 *) result = return_arg->v_uint8;
+		break;
 	case GI_TYPE_TAG_INT16:
-			*(gint16*)result = return_arg->v_int16;
-			break;
+		*(gint16 *) result = return_arg->v_int16;
+		break;
 	case GI_TYPE_TAG_UINT16:
-			return_arg->v_uint16 = *(guint16*)args[i];
-			break;
+		return_arg->v_uint16 = *(guint16 *) args[i];
+		break;
 	case GI_TYPE_TAG_INT32:
-			*(gint32*)result = return_arg->v_int32;
-			break;
+		*(gint32 *) result = return_arg->v_int32;
+		break;
 	case GI_TYPE_TAG_UINT32:
-			*(guint32*)result = return_arg->v_uint32;
-			break;
+		*(guint32 *) result = return_arg->v_uint32;
+		break;
 	case GI_TYPE_TAG_LONG:
 	case GI_TYPE_TAG_INT64:
-			*(glong*)result = return_arg->v_int64;
-			break;
+		*(glong *) result = return_arg->v_int64;
+		break;
 	case GI_TYPE_TAG_ULONG:
 	case GI_TYPE_TAG_UINT64:
-			*(glong*)result = return_arg->v_uint64;
-			break;
+		*(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;
+		*(gint *) result = return_arg->v_int32;
+		break;
 	case GI_TYPE_TAG_UINT:
-			*(guint*)result = return_arg->v_uint32;
-			break;
+		*(guint *) result = return_arg->v_uint32;
+		break;
 	case GI_TYPE_TAG_FLOAT:
-			*(gfloat*)result = return_arg->v_float;
-			break;
+		*(gfloat *) result = return_arg->v_float;
+		break;
 	case GI_TYPE_TAG_DOUBLE:
-			*(gdouble*)result = return_arg->v_double;
-			break;
+		*(gdouble *) result = return_arg->v_double;
+		break;
 	case GI_TYPE_TAG_UTF8:
-		    *(gchar**)result = return_arg->v_string;
-			break;
+		*(gchar **) result = return_arg->v_string;
+		break;
 	case GI_TYPE_TAG_INTERFACE:
-	{
+		{
 			GIBaseInfo *interface;
 			GIInfoType interface_type;
-			
+
 			interface = g_type_info_get_interface(return_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;
+			    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;
+				 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;
+			}
+		}
 	case GI_TYPE_TAG_GLIST:
 	case GI_TYPE_TAG_GSLIST:
-			*(gpointer*)result = return_arg->v_pointer;
-			break;
+		*(gpointer *) result = return_arg->v_pointer;
+		break;
 	default:
-			*(gpointer*)result = 0;
+		*(gpointer *) result = 0;
 	}
 }
 
-
-SeedNativeClosure * seed_make_native_closure(GICallableInfo * info,
-					JSValueRef function)
+SeedNativeClosure *seed_make_native_closure(GICallableInfo * info,
+					    JSValueRef function)
 {
-	ffi_cif * cif;
+	ffi_cif *cif;
 	ffi_closure *closure;
-	ffi_type ** arg_types;
+	ffi_type **arg_types;
 	ffi_arg result;
 	ffi_status status;
-	GITypeInfo * return_type;
-	GIArgInfo * arg_info;
+	GITypeInfo *return_type;
+	GIArgInfo *arg_info;
 	gint num_args, i;
-	SeedNativeClosure * privates;
+	SeedNativeClosure *privates;
 	JSObjectRef cached;
-	
-	cached = (JSObjectRef)seed_value_get_property(function, "__seed_native_closure");
-	if (cached && JSValueIsObjectOfClass(eng->context, cached, seed_native_callback_class))
+
+	cached =
+	    (JSObjectRef) seed_value_get_property(function,
+						  "__seed_native_closure");
+	if (cached
+	    && JSValueIsObjectOfClass(eng->context, cached,
+				      seed_native_callback_class))
 	{
-			return (SeedNativeClosure *)JSObjectGetPrivate(cached);
+		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);
+	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);
+
+	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_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));
-	
+
+	seed_value_set_property((JSObjectRef) function,
+				"__seed_native_closure",
+				(JSValueRef) JSObjectMake(eng->context,
+							  seed_native_callback_class,
+							  privates));
+
 	return privates;
 }
 
-SeedClosure * seed_make_gclosure(JSObjectRef function,
-								 JSObjectRef this)
+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);
-		
-		((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);
-		
-		return (SeedClosure *)closure;
+	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;
+
+	JSValueProtect(eng->context, function);
+
+	return (SeedClosure *) closure;
 }
 
 JSClassDefinition seed_native_callback_def = {
@@ -394,20 +405,18 @@
 	NULL,			/* Static Values */
 	NULL,			/* Static Functions */
 	NULL,
-	seed_closure_finalize,			/* Finalize */
+	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 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);

Modified: trunk/libseed/seed-closure.h
==============================================================================
--- trunk/libseed/seed-closure.h	(original)
+++ trunk/libseed/seed-closure.h	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-builtins.h
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -28,21 +30,19 @@
 	JSObjectRef this;
 } SeedClosure;
 
-typedef struct _SeedNativeClosure
-{
-		GICallableInfo * info;
-		JSValueRef function;
-		
-		ffi_closure * closure;
-		ffi_cif * cif;
+typedef struct _SeedNativeClosure {
+	GICallableInfo *info;
+	JSValueRef function;
+
+	ffi_closure *closure;
+	ffi_cif *cif;
 } SeedNativeClosure;
 
 extern JSClassRef seed_native_callback_class;
 
-SeedNativeClosure * seed_make_native_closure(GICallableInfo * info,
-					JSValueRef function);
-SeedClosure * seed_make_gclosure(JSObjectRef function,
-								 JSObjectRef this);
+SeedNativeClosure *seed_make_native_closure(GICallableInfo * info,
+					    JSValueRef function);
+SeedClosure *seed_make_gclosure(JSObjectRef function, JSObjectRef this);
 
 void seed_closures_init();
 

Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c	(original)
+++ trunk/libseed/seed-engine.c	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-engine.c
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -30,8 +32,9 @@
 
 gchar *glib_message = 0;
 
-void seed_make_exception(JSValueRef * exception,
-			 const gchar * name, const gchar * message)
+void
+seed_make_exception(JSValueRef * exception,
+		    const gchar * name, const gchar * message)
 {
 	JSStringRef js_name = 0;
 	JSStringRef js_message = 0;
@@ -41,11 +44,13 @@
 	if (!exception)
 		return;
 
-	if (name) {
+	if (name)
+	{
 		js_name = JSStringCreateWithUTF8CString(name);
 		js_name_ref = JSValueMakeString(eng->context, js_name);
 	}
-	if (message) {
+	if (message)
+	{
 		js_message = JSStringCreateWithUTF8CString(message);
 		js_message_ref = JSValueMakeString(eng->context, js_message);
 	}
@@ -87,7 +92,8 @@
 
 	g_assert(argumentCount <= 1);
 
-	if (argumentCount == 1) {
+	if (argumentCount == 1)
+	{
 		jsprops = JSObjectCopyPropertyNames(eng->context,
 						    (JSObjectRef) arguments[0]);
 		nparams = JSPropertyNameArrayGetCount(jsprops);
@@ -96,9 +102,11 @@
 
 	params = g_new0(GParameter, nparams + 1);
 
-	// TODO: make sure we don't die if we get passed something other than an object
+	// TODO: make sure we don't die if we get passed something other than
+	// an object
 
-	while (i < nparams) {
+	while (i < nparams)
+	{
 		GType type;
 		jsprop_name = JSPropertyNameArrayGetNameAtIndex(jsprops, i);
 
@@ -109,17 +117,17 @@
 		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);
-		}
+			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],
@@ -131,14 +139,14 @@
 			type = param_spec->value_type;
 
 		seed_gvalue_from_seed_value(jsprop_value,
-									type, &params[i].value, exception);
-			
+					    type, &params[i].value, exception);
+
 		if (*exception)
 		{
 
-				g_free(prop_name);
-				g_free(params);
-				return 0;
+			g_free(prop_name);
+			g_free(params);
+			return 0;
 		}
 		params[i].name = prop_name;
 
@@ -203,15 +211,14 @@
 	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
+	// 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);
@@ -220,35 +227,46 @@
 
 	if (instance_method)
 		in_args[n_in_args++].v_pointer = object;
-	for (i = 0; (i < (n_args)); i++) {
+	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) {
+		if (i + 1 > argumentCount)
+		{
 			in_args[n_in_args++].v_pointer = 0;
-		} else if (dir == GI_DIRECTION_IN || dir == GI_DIRECTION_INOUT) {
+		}
+		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);
-				
+						   &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) {
+		}
+		else if (dir == GI_DIRECTION_OUT)
+		{
 			n_out_args++;
 		}
 
@@ -258,41 +276,44 @@
 	if (g_function_info_invoke((GIFunctionInfo *) info,
 				   in_args,
 				   n_in_args,
-				   out_args, n_out_args, &retval, &error)) {
+				   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);
+			    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++)
+	}
+	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) == '-')
 			{
-					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);
-					
+				*(string->str + w + 1) =
+				    g_unichar_toupper(*(string->str + w + 1));
+				g_string_erase(string, w, 1);
 			}
-			seed_make_exception(exception, string->str,
-								error->message);
+			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);
+		g_string_free(string, TRUE);
+		g_free(in_args);
+		g_free(out_args);
+
+		return JSValueMakeNull(eng->context);
 	}
 
 	g_free(in_args);
@@ -300,17 +321,18 @@
 	return retval_ref;
 }
 
-void seed_gobject_define_property_from_function_info(GIFunctionInfo * info,
-						     JSObjectRef object,
-						     gboolean instance)
+void
+seed_gobject_define_property_from_function_info(GIFunctionInfo * info,
+						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));
+	// 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);
 
@@ -328,31 +350,34 @@
 
 }
 
-static void seed_gobject_add_methods_for_interfaces(GIObjectInfo * oinfo,
-						    JSObjectRef object)
+static void
+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);
 
-	for (i = 0; i < 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_functions = g_interface_info_get_n_methods(interface);
-		for (k = 0; k < n_functions; k++) {
+		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);
+		// g_base_info_unref((GIBaseInfo*)interface);
 	}
 }
 
-static void seed_gobject_add_methods_for_type(GIObjectInfo * oinfo,
-					      JSObjectRef object)
+static void
+seed_gobject_add_methods_for_type(GIObjectInfo * oinfo, JSObjectRef object)
 {
 	gint n_methods;
 	gint i;
@@ -360,7 +385,8 @@
 
 	n_methods = g_object_info_get_n_methods(oinfo);
 
-	for (i = 0; i < n_methods; i++) {
+	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);
@@ -377,13 +403,13 @@
 	JSObjectRef prototype_obj;
 	JSObjectRef parent_prototype;
 
-	if ((ref = g_type_get_qdata(type, qname)) != NULL) {
+	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);
@@ -393,7 +419,8 @@
 	def.attributes = kJSClassAttributeNoAutomaticPrototype;
 
 	prototype_obj = JSObjectMake(eng->context, 0, 0);
-	if (parent) {
+	if (parent)
+	{
 		parent_prototype = seed_gobject_get_prototype_for_gtype(parent);
 		if (parent_prototype)
 			JSObjectSetPrototype(eng->context,
@@ -410,35 +437,38 @@
 
 	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);
+		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;
-			
-			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++)
 			{
-					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);
-					}
+				function =
+				    g_interface_info_get_method((GIInterfaceInfo
+								 *)
+								interface, k);
+				seed_gobject_define_property_from_function_info
+				    (function, prototype_obj, TRUE);
 			}
+		}
 	}
 
 	return ref;
@@ -449,10 +479,10 @@
 	JSObjectRef prototype = 0;
 	while (type && !prototype)
 	{
-			prototype = g_type_get_qdata(type, qprototype);
-			type = g_type_parent(type);
+		prototype = g_type_get_qdata(type, qprototype);
+		type = g_type_parent(type);
 	}
-	
+
 	return prototype;
 }
 
@@ -463,7 +493,7 @@
 	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);
 }
@@ -481,17 +511,18 @@
 					   G_OBJECT_TYPE(gobject));
 
 	seed_add_signals_to_object(object, gobject);
-	if (!base) {
+	if (!base)
+	{
 		return;
 	}
 	g_assert(g_base_info_get_type(base) == GI_INFO_TYPE_OBJECT);
 
 }
 
-static JSValueRef seed_gobject_get_property(JSContextRef context,
-					    JSObjectRef object,
-					    JSStringRef property_name,
-					    JSValueRef * exception)
+static JSValueRef
+seed_gobject_get_property(JSContextRef context,
+			  JSObjectRef object,
+			  JSStringRef property_name, JSValueRef * exception)
 {
 	GParamSpec *spec;
 	GObject *b;
@@ -512,9 +543,11 @@
 	spec = g_object_class_find_property(G_OBJECT_GET_CLASS(b),
 					    cproperty_name);
 
-	if (!spec) {
+	if (!spec)
+	{
 		len = strlen(cproperty_name);
-		for (i = 0; i < len - 1; i++) {
+		for (i = 0; i < len - 1; i++)
+		{
 			if (cproperty_name[i] == '_')
 				cproperty_name[i] = '-';
 		}
@@ -533,10 +566,11 @@
 	return (JSValueRef) ret;
 }
 
-static bool seed_gobject_set_property(JSContextRef context,
-				      JSObjectRef object,
-				      JSStringRef property_name,
-				      JSValueRef value, JSValueRef * exception)
+static bool
+seed_gobject_set_property(JSContextRef context,
+			  JSObjectRef object,
+			  JSStringRef property_name,
+			  JSValueRef value, JSValueRef * exception)
 {
 	GParamSpec *spec = 0;
 	GObject *obj;
@@ -557,16 +591,19 @@
 	spec = g_object_class_find_property(G_OBJECT_GET_CLASS(obj),
 					    cproperty_name);
 
-	if (!spec) {
+	if (!spec)
+	{
 		gint i, len;
 		len = strlen(cproperty_name);
-		for (i = 0; i < len; i++) {
+		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) {
+		if (!spec)
+		{
 			g_free(cproperty_name);
 			return 0;
 		}
@@ -580,17 +617,18 @@
 	seed_gvalue_from_seed_value(value, type, &gval, exception);
 	if (*exception)
 	{
-			g_free(cproperty_name);
-			return 0;
+		g_free(cproperty_name);
+		return 0;
 	}
 
 	if (glib_message)
 	{
-			g_free(glib_message);
-			glib_message = 0;
+		g_free(glib_message);
+		glib_message = 0;
 	}
 	g_object_set_property(obj, cproperty_name, &gval);
-	if (glib_message != 0) {
+	if (glib_message != 0)
+	{
 		seed_make_exception(exception, "PropertyError", glib_message);
 
 		return FALSE;
@@ -617,25 +655,30 @@
 
 	if (argumentCount == 0)
 	{
-			seed_make_exception(exception,
-								"ArgumentError", 
-								"Seed.import_namespace"
-								" expected 1 or 2 arguments, got 0");
-			return JSValueMakeNull(eng->context);
+		seed_make_exception(exception,
+				    "ArgumentError",
+				    "Seed.import_namespace"
+				    " expected 1 or 2 arguments, got 0");
+		return JSValueMakeNull(eng->context);
 	}
 
 	namespace = seed_value_to_string(arguments[0], exception);
-	if (argumentCount == 2) {
+	if (argumentCount == 2)
+	{
 		version = seed_value_to_string(arguments[1], exception);
 	}
 
 	if (!g_irepository_require(g_irepository_get_default(), namespace,
-				   version, 0, NULL)) {
+				   version, 0, NULL))
+	{
 		gchar *mes;
-		if (!version) {
-			mes = g_strdup_printf("No such namespace: %s",
-					      namespace);
-		} else {
+		if (!version)
+		{
+			mes =
+			    g_strdup_printf("No such namespace: %s", namespace);
+		}
+		else
+		{
 			mes =
 			    g_strdup_printf
 			    ("No such namespace: %s (version %s)", namespace,
@@ -651,16 +694,20 @@
 	JSValueProtect(eng->context, namespace_ref);
 	seed_value_set_property(eng->global, namespace, namespace_ref);
 
-	for (i = 0; i < n; i++) {
+	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)) {
+		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;
@@ -671,43 +718,48 @@
 						g_base_info_get_name(info),
 						enum_class);
 
-			for (j = 0; j < num_vals; j++) {
+			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));
+				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);
+				value_ref =
+				    JSValueMakeNumber(eng->context, value);
+				JSValueProtect(eng->context,
+					       (JSValueRef) value_ref);
 
-				for (j = 0; j < name_len; j++) {
+				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(enum_class, name,
+							value_ref);
 
 				g_free(name);
 
 			}
-		} else if (info &&
-			   (g_base_info_get_type(info) == GI_INFO_TYPE_OBJECT))
+		}
+		else if (info &&
+			 (g_base_info_get_type(info) == GI_INFO_TYPE_OBJECT))
 		{
 			GType type;
 			JSClassRef class_ref;
 
-			type = g_registered_type_info_get_g_type(
-					  (GIRegisteredTypeInfo *) info);
+			type =
+			    g_registered_type_info_get_g_type((GIRegisteredTypeInfo *) info);
 
-			if (type != 0) {
+			if (type != 0)
+			{
 				JSObjectRef constructor_ref;
 				gint i, n_methods;
 				GIFunctionInfo *finfo;
@@ -724,16 +776,20 @@
 				n_methods =
 				    g_object_info_get_n_methods((GIObjectInfo *)
 								info);
-				for (i = 0; i < n_methods; i++) {
+				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) {
+					if (flags & GI_FUNCTION_IS_CONSTRUCTOR)
+					{
 						seed_gobject_define_property_from_function_info
 						    (finfo, constructor_ref,
 						     FALSE);
-					} else {
+					}
+					else
+					{
 						g_base_info_unref((GIBaseInfo *)
 								  finfo);
 					}
@@ -746,8 +802,9 @@
 				JSValueProtect(eng->context,
 					       (JSValueRef) constructor_ref);
 			}
-		} else if (info &&
-			   (g_base_info_get_type(info) == GI_INFO_TYPE_STRUCT))
+		}
+		else if (info &&
+			 (g_base_info_get_type(info) == GI_INFO_TYPE_STRUCT))
 		{
 			JSObjectRef struct_ref;
 			gint i, n_methods;
@@ -758,7 +815,8 @@
 			n_methods =
 			    g_struct_info_get_n_methods((GIStructInfo *) info);
 
-			for (i = 0; i < n_methods; i++) {
+			for (i = 0; i < n_methods; i++)
+			{
 				finfo =
 				    g_struct_info_get_method((GIStructInfo *)
 							     info, i);
@@ -772,33 +830,35 @@
 						struct_ref);
 
 			JSValueProtect(eng->context, (JSValueRef) struct_ref);
-		} else if (info &&
-				 (g_base_info_get_type(info) == GI_INFO_TYPE_CALLBACK))
+		}
+		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))
+			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);
-				
+			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\")",
@@ -872,7 +932,7 @@
 	NULL,			/* Set Property */
 	NULL,			/* Delete Property */
 	NULL,			/* Get Property Names */
-	NULL,	/* Call As Function */
+	NULL,			/* Call As Function */
 	NULL,			/* Call As Constructor */
 	NULL,			/* Has Instance */
 	NULL			/* Convert To Type */
@@ -898,7 +958,7 @@
 	NULL			/* Convert To Type */
 };
 
-void seed_create_function(gchar *name, gpointer func, JSObjectRef obj)
+void seed_create_function(gchar * name, gpointer func, JSObjectRef obj)
 {
 	JSObjectRef oref;
 
@@ -907,55 +967,55 @@
 	seed_value_set_property(obj, name, oref);
 }
 
-static void seed_log_handler(const gchar * domain,
-			     GLogLevelFlags log_level,
-			     const gchar * message, gpointer user_data)
+static void
+seed_log_handler(const gchar * domain,
+		 GLogLevelFlags log_level,
+		 const gchar * message, gpointer user_data)
 {
 	glib_message = g_strdup(message);
 }
 
-gboolean seed_init(gint *argc, gchar ***argv)
+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");
-		
-		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();
+	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 =
+	defaults_script =
 	    JSStringCreateWithUTF8CString("Seed.include(\"/usr/local/share"
 					  "/seed/Seed.js\")");
 	JSEvaluateScript(eng->context, defaults_script, NULL, NULL, 0, NULL);
@@ -972,7 +1032,8 @@
 
 	ret->script = JSStringCreateWithUTF8CString(js);
 
-	if (source_url) {
+	if (source_url)
+	{
 		ret->source_url = JSStringCreateWithUTF8CString(source_url);
 	}
 	ret->line_number = line_number;

Modified: trunk/libseed/seed-engine.h
==============================================================================
--- trunk/libseed/seed-engine.h	(original)
+++ trunk/libseed/seed-engine.h	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-engine.h
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -39,10 +41,11 @@
 JSObjectRef seed_gobject_get_prototype_for_gtype(GType type);
 JSClassRef seed_gobject_get_class_for_gtype(GType type);
 
-void seed_gobject_define_property_from_function_info(GIFunctionInfo * info,
-						     JSObjectRef object,
-						     gboolean instance);
-void seed_create_function(gchar *name, gpointer func, JSObjectRef obj);
+void
+seed_gobject_define_property_from_function_info(GIFunctionInfo * info,
+						JSObjectRef object,
+						gboolean instance);
+void seed_create_function(gchar * name, gpointer func, JSObjectRef obj);
 void seed_make_exception(JSValueRef * exception,
 			 const gchar * name, const gchar * message);
 #endif

Modified: trunk/libseed/seed-gtype.c
==============================================================================
--- trunk/libseed/seed-gtype.c	(original)
+++ trunk/libseed/seed-gtype.c	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-gtype.c
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -22,204 +24,193 @@
 
 JSClassRef seed_gtype_class;
 
-static void 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);
-		
-		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);
-		
-		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;
-}
-
-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;
-}
-
-static JSObjectRef seed_gtype_constructor_invoked(JSContextRef ctx,
-												  JSObjectRef constructor,
-												  size_t argumentCount,
-												  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);
+static void
+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);
+
+	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);
+
+	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;
+}
+
+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;
+}
+
+static JSObjectRef
+seed_gtype_constructor_invoked(JSContextRef ctx,
+			       JSObjectRef constructor,
+			       size_t argumentCount,
+			       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);
 }
 
 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);
-		
-		gtype_constructor = JSObjectMake(eng->context, seed_gtype_class, 0);
-		
-		seed_value_set_property(eng->global, "GType", gtype_constructor);
-		
-}
+	def.callAsConstructor = seed_gtype_constructor_invoked;
+	seed_gtype_class = JSClassCreate(&def);
+	JSClassRetain(seed_gtype_class);
 
+	gtype_constructor = JSObjectMake(eng->context, seed_gtype_class, 0);
 
+	seed_value_set_property(eng->global, "GType", gtype_constructor);
 
+}

Modified: trunk/libseed/seed-gtype.h
==============================================================================
--- trunk/libseed/seed-gtype.h	(original)
+++ trunk/libseed/seed-gtype.h	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-gtype.h
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>

Modified: trunk/libseed/seed-private.h
==============================================================================
--- trunk/libseed/seed-private.h	(original)
+++ trunk/libseed/seed-private.h	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-private.h
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -44,5 +46,4 @@
 #include "seed-closure.h"
 #include "seed-gtype.h"
 
-
 #endif

Modified: trunk/libseed/seed-signals.c
==============================================================================
--- trunk/libseed/seed-signals.c	(original)
+++ trunk/libseed/seed-signals.c	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-signals.c
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -28,8 +30,9 @@
 
 JSClassRef signal_holder_class;
 
-static void seed_add_signal_to_object(JSObjectRef object_ref,
-				      GObject * obj, GSignalQuery * signal)
+static void
+seed_add_signal_to_object(JSObjectRef object_ref,
+			  GObject * obj, GSignalQuery * signal)
 {
 	guint k;
 	JSObjectRef signal_ref;
@@ -37,7 +40,8 @@
 	gchar *js_signal_name = g_strdup(signal->signal_name);
 	g_assert(signal);
 
-	for (k = 0; k < strlen(js_signal_name); k++) {
+	for (k = 0; k < strlen(js_signal_name); k++)
+	{
 		if (js_signal_name[k] == '-')
 			js_signal_name[k] = '_';
 	}
@@ -51,16 +55,18 @@
 	g_free(js_signal_name);
 }
 
-static void seed_add_signals_for_type(JSObjectRef object_ref,
-				      GObject * obj, GType type)
+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++) {
+	for (i = 0; i < n; i++)
+	{
 		g_signal_query(signal_ids[i], &query);
-		if (query.signal_id != 0) {
+		if (query.signal_id != 0)
+		{
 			seed_add_signal_to_object(object_ref, obj, &query);
 		}
 	}
@@ -77,10 +83,11 @@
 	g_assert(obj);
 
 	type = G_OBJECT_TYPE(obj);
-	
+
 	signals_ref = JSObjectMake(eng->context, signal_holder_class, 0);
 
-	while (type != 0) {
+	while (type != 0)
+	{
 		seed_add_signals_for_type(signals_ref, obj, type);
 
 		interfaces = g_type_interfaces(type, &n);
@@ -92,7 +99,7 @@
 
 		g_free(interfaces);
 	}
-	
+
 	seed_value_set_property(object_ref, "signal", signals_ref);
 }
 
@@ -109,8 +116,10 @@
 
 	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. "
@@ -143,15 +152,17 @@
 
 	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);
+	// Losing a ref here. Fix please.
+	// g_closure_add_finalize_notifier(closure, NULL, NULL);
 	((SeedClosure *) closure)->function = (JSObjectRef) arguments[0];
 	((SeedClosure *) closure)->object =
 	    g_object_get_data(privates->object, "js-ref");
-	if (argumentCount == 2 && !JSValueIsNull(eng->context, arguments[1])) {
+	if (argumentCount == 2 && !JSValueIsNull(eng->context, arguments[1]))
+	{
 		JSValueProtect(eng->context, (JSObjectRef) arguments[1]);
 		((SeedClosure *) closure)->this = (JSObjectRef) arguments[1];
-	} else
+	}
+	else
 		((SeedClosure *) closure)->this = 0;
 
 	JSValueProtect(eng->context, (JSObjectRef) arguments[0]);
@@ -190,7 +201,7 @@
 JSClassDefinition *seed_get_signal_class(void)
 {
 	JSClassDefinition signal_holder = kJSClassDefinitionEmpty;
-	
+
 	signal_holder.className = "gobject_signals";
 	signal_holder_class = JSClassCreate(&signal_holder);
 	JSClassRetain(signal_holder_class);

Modified: trunk/libseed/seed-signals.h
==============================================================================
--- trunk/libseed/seed-signals.h	(original)
+++ trunk/libseed/seed-signals.h	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-signals.h
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -23,11 +25,13 @@
 #include "seed-private.h"
 
 void
+
+
 seed_signal_marshal_func(GClosure * closure,
-						 GValue * return_value,
-						 guint n_param_values,
-						 const GValue * param_values,
-						 gpointer invocation_hint, gpointer marshall_data);
+			 GValue * return_value,
+			 guint n_param_values,
+			 const GValue * param_values,
+			 gpointer invocation_hint, gpointer marshall_data);
 
 void seed_add_signals_to_object(JSObjectRef object_ref, GObject * obj);
 JSClassDefinition *seed_get_signal_class(void);

Modified: trunk/libseed/seed-structs.c
==============================================================================
--- trunk/libseed/seed-structs.c	(original)
+++ trunk/libseed/seed-structs.c	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-structs.h
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -58,13 +60,15 @@
 
 	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++) {
+		for (i = 0; i < n_methods; i++)
+		{
 			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);
 		}
@@ -83,13 +87,15 @@
 
 	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++) {
+		for (i = 0; i < n_methods; i++)
+		{
 			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);
 		}
@@ -97,4 +103,3 @@
 
 	return object;
 }
-

Modified: trunk/libseed/seed-structs.h
==============================================================================
--- trunk/libseed/seed-structs.h	(original)
+++ trunk/libseed/seed-structs.h	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-struct.h
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>

Modified: trunk/libseed/seed-types.c
==============================================================================
--- trunk/libseed/seed-types.c	(original)
+++ trunk/libseed/seed-types.c	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-types.c
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -37,22 +39,20 @@
 	return JSValueIsObjectOfClass(eng->context, value, gobject_class);
 }
 
-void seed_toggle_ref(gpointer data,
-							GObject * object,
-							gboolean is_last_ref)
+void seed_toggle_ref(gpointer data, GObject * object, gboolean is_last_ref)
 {
-		JSValueRef wrapper;
-		
-		wrapper = (JSValueRef)data;
+	JSValueRef wrapper;
 
-		if (is_last_ref)
-		{
-				JSValueUnprotect(eng->context, wrapper);
-		}
-		else
-		{
-				JSValueProtect(eng->context, wrapper);
-		}
+	wrapper = (JSValueRef) data;
+
+	if (is_last_ref)
+	{
+		JSValueUnprotect(eng->context, wrapper);
+	}
+	else
+	{
+		JSValueProtect(eng->context, wrapper);
+	}
 
 }
 
@@ -84,16 +84,17 @@
 	if (prototype)
 		JSObjectSetPrototype(eng->context,
 				     (JSObjectRef) js_ref, prototype);
-	else {
+	else
+	{
 		g_assert_not_reached();
 	}
 
 	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);
+	g_object_add_toggle_ref(object, seed_toggle_ref, (gpointer) js_ref);
 
 	g_object_unref(object);
 
@@ -102,7 +103,8 @@
 
 GType seed_gi_type_to_gtype(GITypeInfo * type_info, GITypeTag tag)
 {
-	switch (tag) {
+	switch (tag)
+	{
 	case GI_TYPE_TAG_VOID:
 		return G_TYPE_NONE;
 	case GI_TYPE_TAG_BOOLEAN:
@@ -171,9 +173,10 @@
 	return 0;
 }
 
-gboolean seed_gi_make_argument(SeedValue value,
-							   GITypeInfo * type_info, GArgument * arg,
-							   JSValueRef * exception)
+gboolean
+seed_gi_make_argument(SeedValue value,
+		      GITypeInfo * type_info, GArgument * arg,
+		      JSValueRef * exception)
 {
 	GITypeTag gi_tag = g_type_info_get_tag(type_info);
 
@@ -183,7 +186,8 @@
 		return 1;
 	}
 
-	switch (gi_tag) {
+	switch (gi_tag)
+	{
 	case GI_TYPE_TAG_VOID:
 		break;
 	case GI_TYPE_TAG_BOOLEAN:
@@ -247,83 +251,103 @@
 			arg->v_pointer = NULL;
 
 			if (interface_type == GI_INFO_TYPE_OBJECT
-			    || interface_type == GI_INFO_TYPE_INTERFACE) {
-				gobject = seed_value_to_object(value, exception);
+			    || interface_type == GI_INFO_TYPE_INTERFACE)
+			{
+				gobject =
+				    seed_value_to_object(value, exception);
 				required_gtype =
-				    g_registered_type_info_get_g_type((GIRegisteredTypeInfo *)
-													  interface);
+				    g_registered_type_info_get_g_type((GIRegisteredTypeInfo *) interface);
 				if (!gobject
 				    || !g_type_is_a(G_OBJECT_TYPE(gobject),
-						    required_gtype)) {
+						    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);
+			}
+			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 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))
+					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))
 						{
-								if (JSObjectIsFunction(eng->context,
-													   (JSObjectRef)value))
-								{
-										arg->v_pointer = 
-								  seed_make_gclosure((JSObjectRef)value, 0);
-								}
+							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))
+			}
+			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;
-						}
+					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))
+				else if (JSValueIsObjectOfClass(eng->context,
+								value,
+								seed_native_callback_class))
 				{
-						SeedNativeClosure * privates =
-								(SeedNativeClosure*)
-								JSObjectGetPrivate((JSObjectRef)value);
-						arg->v_pointer = privates->closure;
-						break;
+					SeedNativeClosure *privates =
+					    (SeedNativeClosure *)
+					    JSObjectGetPrivate((JSObjectRef)
+							       value);
+					arg->v_pointer = privates->closure;
+					break;
 				}
 				else if (JSObjectIsFunction(eng->context,
-											(JSObjectRef)value))
+							    (JSObjectRef)
+							    value))
 				{
-						SeedNativeClosure * privates =
-								seed_make_native_closure(
-									   (GICallableInfo*)interface, value);
-						arg->v_pointer = privates->closure;
-						break;
+					SeedNativeClosure *privates =
+					    seed_make_native_closure((GICallableInfo *) interface,
+								     value);
+					arg->v_pointer = privates->closure;
+					break;
 				}
 
 			}
@@ -337,11 +361,13 @@
 
 }
 
-JSValueRef seed_gi_argument_make_js(GArgument * arg, GITypeInfo * type_info,
-									JSValueRef * exception)
+JSValueRef
+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) {
+	switch (gi_tag)
+	{
 	case GI_TYPE_TAG_VOID:
 		return 0;
 	case GI_TYPE_TAG_BOOLEAN:
@@ -386,15 +412,23 @@
 			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) {
+			    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_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);
 			}
@@ -411,13 +445,15 @@
 			ret = JSObjectMake(eng->context, NULL, NULL);
 			list_type = g_type_info_get_param_type(type_info, 0);
 
-			for (; list != NULL; list = list->next) {
+			for (; list != NULL; list = list->next)
+			{
 				JSValueRef ival;
 
 				larg.v_pointer = list->data;
 				ival =
 				    (JSValueRef) seed_gi_argument_make_js(&larg,
-														  list_type, exception);
+									  list_type,
+									  exception);
 				JSObjectSetPropertyAtIndex(eng->context, ret, i,
 							   ival, NULL);
 				i++;
@@ -438,13 +474,15 @@
 			ret = JSObjectMake(eng->context, NULL, NULL);
 			list_type = g_type_info_get_param_type(type_info, 0);
 
-			for (; list != NULL; list = list->next) {
+			for (; list != NULL; list = list->next)
+			{
 				JSValueRef ival;
 
 				larg.v_pointer = list->data;
 				ival =
 				    (JSValueRef) seed_gi_argument_make_js(&larg,
-														  list_type, exception);
+									  list_type,
+									  exception);
 				JSObjectSetPropertyAtIndex(eng->context, ret, i,
 							   ival, NULL);
 				i++;
@@ -465,7 +503,8 @@
 
 	type_tag = g_type_info_get_tag(type_info);
 
-	switch (type_tag) {
+	switch (type_tag)
+	{
 	case GI_TYPE_TAG_VOID:
 	case GI_TYPE_TAG_BOOLEAN:
 	case GI_TYPE_TAG_INT8:
@@ -505,16 +544,20 @@
 
 SeedValue seed_value_from_gvalue(GValue * gval, JSValueRef * exception)
 {
-	if (!G_IS_VALUE(gval)) {
+	if (!G_IS_VALUE(gval))
+	{
 		return false;
 	}
-	switch (G_VALUE_TYPE(gval)) {
+	switch (G_VALUE_TYPE(gval))
+	{
 	case G_TYPE_BOOLEAN:
-		return seed_value_from_boolean(g_value_get_boolean(gval), exception);
+		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);
+		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:
@@ -522,46 +565,61 @@
 	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);
+		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);
+		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);
+		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);
+		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);
+		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);
+					      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))
+	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)) {
+	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 {
+		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) {
+		if (type == GI_INFO_TYPE_UNION)
+		{
 			return seed_make_union(g_value_peek_pointer(gval),
 					       info);
 
-		} else if (type == GI_INFO_TYPE_STRUCT) {
+		}
+		else if (type == GI_INFO_TYPE_STRUCT)
+		{
 			return seed_make_struct(g_value_peek_pointer(gval),
 						info);
 
-		} else if (type == GI_INFO_TYPE_BOXED) {
+		}
+		else if (type == GI_INFO_TYPE_BOXED)
+		{
 			printf("Trying to marshal boxed type \n");
 		}
 
@@ -570,20 +628,25 @@
 	return NULL;
 }
 
-gboolean seed_gvalue_from_seed_value(SeedValue val, GType type, GValue * ret,
-									 JSValueRef * exception)
+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;
+			/*
+			 * 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));
+			g_value_set_boolean(ret,
+					    seed_value_to_boolean(val,
+								  exception));
 			return TRUE;
 		}
 	case G_TYPE_INT:
@@ -591,21 +654,27 @@
 		{
 			g_value_init(ret, type);
 			if (type == G_TYPE_INT)
-				g_value_set_int(ret, seed_value_to_int(val, exception));
+				g_value_set_int(ret,
+						seed_value_to_int(val,
+								  exception));
 			else
-				g_value_set_uint(ret, seed_value_to_uint(val, exception));
+				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));
+			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));
+			g_value_set_uchar(ret,
+					  seed_value_to_uchar(val, exception));
 			return TRUE;
 		}
 	case G_TYPE_LONG:
@@ -615,35 +684,43 @@
 	case G_TYPE_FLOAT:
 	case G_TYPE_DOUBLE:
 		{
-			switch (type) {
+			switch (type)
+			{
 			case G_TYPE_LONG:
 				g_value_init(ret, G_TYPE_LONG);
-				g_value_set_long(ret, seed_value_to_long(val, exception));
+				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));
+						  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));
+						  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));
+						   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));
+						  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));
+						   seed_value_to_double(val,
+									exception));
 				break;
 			}
 			return TRUE;
@@ -659,13 +736,14 @@
 		}
 	default:
 		{
-			switch (JSValueGetType(eng->context, val)) {
+			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));
+							    (val, exception));
 					return TRUE;
 				}
 			case kJSTypeNumber:
@@ -673,12 +751,13 @@
 					g_value_init(ret, G_TYPE_DOUBLE);
 					g_value_set_double(ret,
 							   seed_value_to_double
-									   (val, exception));
+							   (val, exception));
 					return TRUE;
 				}
 			case kJSTypeString:
 				{
-					gchar *cv = seed_value_to_string(val, exception);
+					gchar *cv = seed_value_to_string(val,
+									 exception);
 
 					g_value_init(ret, G_TYPE_STRING);
 					g_value_take_string(ret, cv);
@@ -692,30 +771,39 @@
 	}
 
 	if (g_type_is_a(type, G_TYPE_ENUM)
-	    && JSValueIsNumber(eng->context, val)) {
+	    && 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)) {
+	}
+	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))) {
+	}
+	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)) {
+		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)) {
+	}
+	else if (g_type_is_a(type, G_TYPE_BOXED))
+	{
 		gpointer p = seed_struct_get_pointer(val);
-		if (p) {
+		if (p)
+		{
 			g_value_init(ret, type);
 			g_value_set_boxed(ret, p);
 			return TRUE;
@@ -725,7 +813,7 @@
 	return FALSE;
 }
 
-SeedValue seed_value_get_property(SeedValue val, const gchar *name)
+SeedValue seed_value_get_property(SeedValue val, const gchar * name)
 {
 
 	JSStringRef jname = JSStringCreateWithUTF8CString(name);
@@ -738,12 +826,14 @@
 	return ret;
 }
 
-gboolean seed_value_set_property(JSObjectRef object,
-				 const gchar *name, JSValueRef value)
+gboolean
+seed_value_set_property(JSObjectRef object,
+			const gchar * name, JSValueRef value)
 {
 	JSStringRef jname = JSStringCreateWithUTF8CString(name);
 
-	if (value) {
+	if (value)
+	{
 		JSObjectSetProperty(eng->context, (JSObjectRef) object,
 				    jname, value, 0, 0);
 	}
@@ -755,13 +845,14 @@
 
 gboolean seed_value_to_boolean(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsBoolean(eng->context, val)) {
-		if (!JSValueIsNull(eng->context, val)) {
+	if (!JSValueIsBoolean(eng->context, val))
+	{
+		if (!JSValueIsNull(eng->context, val))
+		{
 			seed_make_exception(exception, "ConversionError",
-								"Can not convert Javascript value to boolean");
+					    "Can not convert Javascript value to boolean");
 			return 0;
 		}
-			
 
 		return 0;
 	}
@@ -776,12 +867,13 @@
 
 guint seed_value_to_uint(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val)) {
+	if (!JSValueIsNumber(eng->context, val))
+	{
 		if (!JSValueIsNull(eng->context, val))
 		{
-				seed_make_exception(exception, "ConversionError",
-										  "Can not convert Javascript value to"
-										  " boolean");
+			seed_make_exception(exception, "ConversionError",
+					    "Can not convert Javascript value to"
+					    " boolean");
 		}
 		return 0;
 	}
@@ -796,11 +888,12 @@
 
 gint seed_value_to_int(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val)) {
+	if (!JSValueIsNumber(eng->context, val))
+	{
 		if (!JSValueIsNull(eng->context, val))
-				seed_make_exception(exception, "ConversionError",
-										  "Can not convert Javascript value to"
-										  " int");
+			seed_make_exception(exception, "ConversionError",
+					    "Can not convert Javascript value to"
+					    " int");
 		return 0;
 	}
 
@@ -816,20 +909,22 @@
 {
 	gint cv;
 
-	if (!JSValueIsNumber(eng->context, val)) {
+	if (!JSValueIsNumber(eng->context, val))
+	{
 		if (!JSValueIsNull(eng->context, val))
-				seed_make_exception(exception, "ConversionError",
-										  "Can not convert Javascript value to"
-										  " gchar");
+			seed_make_exception(exception, "ConversionError",
+					    "Can not convert Javascript value to"
+					    " gchar");
 		return 0;
 	}
 
 	cv = JSValueToNumber(eng->context, val, NULL);
 
-	if (cv < G_MININT8 || cv > G_MAXINT8) {
+	if (cv < G_MININT8 || cv > G_MAXINT8)
+	{
 		seed_make_exception(exception, "ConversionError",
-								  "Javascript number out of range of gchar");
-					return 0;
+				    "Javascript number out of range of gchar");
+		return 0;
 	}
 
 	return (char)cv;
@@ -844,19 +939,21 @@
 {
 	guint cv;
 
-	if (!JSValueIsNumber(eng->context, val)) {
+	if (!JSValueIsNumber(eng->context, val))
+	{
 		if (!JSValueIsNull(eng->context, val))
-				seed_make_exception(exception, "ConversionError",
-										  "Can not convert Javascript value to"
-										  " guchar");
+			seed_make_exception(exception, "ConversionError",
+					    "Can not convert Javascript value to"
+					    " guchar");
 		return 0;
 	}
 
 	cv = JSValueToNumber(eng->context, val, NULL);
 
-	if (cv > G_MAXUINT8) {
+	if (cv > G_MAXUINT8)
+	{
 		seed_make_exception(exception, "ConversionError",
-								  "Javascript number out of range of guchar");
+				    "Javascript number out of range of guchar");
 		return 0;
 	}
 
@@ -870,11 +967,12 @@
 
 glong seed_value_to_long(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val)) {
+	if (!JSValueIsNumber(eng->context, val))
+	{
 		if (!JSValueIsNull(eng->context, val))
-				seed_make_exception(exception, "ConversionError",
-										  "Can not convert Javascript value to"
-										  " long");
+			seed_make_exception(exception, "ConversionError",
+					    "Can not convert Javascript value to"
+					    " long");
 		return 0;
 	}
 
@@ -888,11 +986,12 @@
 
 gulong seed_value_to_ulong(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val)) {
+	if (!JSValueIsNumber(eng->context, val))
+	{
 		if (!JSValueIsNull(eng->context, val))
 			seed_make_exception(exception, "ConversionError",
-									  "Can not convert Javascript value to"
-									  " ulong");
+					    "Can not convert Javascript value to"
+					    " ulong");
 
 		return 0;
 	}
@@ -907,11 +1006,12 @@
 
 gint64 seed_value_to_int64(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val)) {
+	if (!JSValueIsNumber(eng->context, val))
+	{
 		if (!JSValueIsNull(eng->context, val))
 			seed_make_exception(exception, "ConversionError",
-									  "Can not convert Javascript value to"
-									  " gint64");
+					    "Can not convert Javascript value to"
+					    " gint64");
 
 		return 0;
 	}
@@ -926,11 +1026,12 @@
 
 guint64 seed_value_to_uint64(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val)) {
+	if (!JSValueIsNumber(eng->context, val))
+	{
 		if (!JSValueIsNull(eng->context, val))
 			seed_make_exception(exception, "ConversionError",
-									  "Can not convert Javascript value to"
-									  " guint64");
+					    "Can not convert Javascript value to"
+					    " guint64");
 
 		return 0;
 	}
@@ -938,7 +1039,6 @@
 	return (guint64) JSValueToNumber(eng->context, val, NULL);
 }
 
-
 JSValueRef seed_value_from_uint64(guint64 val, JSValueRef * exception)
 {
 	return JSValueMakeNumber(eng->context, (gdouble) val);
@@ -946,11 +1046,12 @@
 
 gfloat seed_value_to_float(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val)) {
+	if (!JSValueIsNumber(eng->context, val))
+	{
 		if (!JSValueIsNull(eng->context, val))
-				seed_make_exception(exception, "ConversionError",
-										  "Can not convert Javascript value to"
-										  " gfloat");
+			seed_make_exception(exception, "ConversionError",
+					    "Can not convert Javascript value to"
+					    " gfloat");
 		return 0;
 	}
 
@@ -964,11 +1065,12 @@
 
 gdouble seed_value_to_double(JSValueRef val, JSValueRef * exception)
 {
-	if (!JSValueIsNumber(eng->context, val)) {
+	if (!JSValueIsNumber(eng->context, val))
+	{
 		if (!JSValueIsNull(eng->context, val))
-				seed_make_exception(exception, "ConversionError",
-										  "Can not convert Javascript value to"
-										  " double");
+			seed_make_exception(exception, "ConversionError",
+					    "Can not convert Javascript value to"
+					    " double");
 		return 0;
 	}
 
@@ -991,15 +1093,21 @@
 		return NULL;
 
 	if (JSValueIsBoolean(eng->context, val)
-	    || JSValueIsNumber(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)) {
+	}
+	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
+	}
+	else
+	{
+		if (!JSValueIsString(eng->context, val))	// In this case,
+			// it's an object
 		{
 			func = seed_value_get_property(val, "toString");
 			str =
@@ -1014,7 +1122,7 @@
 		buf = g_malloc(length * sizeof(gchar));
 		JSStringGetUTF8CString(jsstr, buf, length);
 		if (jsstr)
-				JSStringRelease(jsstr);
+			JSStringRelease(jsstr);
 	}
 
 	return buf;
@@ -1033,22 +1141,23 @@
 {
 	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));
+	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)
 			{
-					JSValueRef ref_data = 0;
-					gobject = seed_value_to_object(object, exception);
-					if (gobject)
-					{
-							g_object_set_data(gobject, "js-ref",
-											  (gpointer)val);
-					}
-					return gobject;
+				g_object_set_data(gobject, "js-ref",
+						  (gpointer) val);
 			}
+			return gobject;
+		}
 	}
 
 	gobject = (GObject *) JSObjectGetPrivate((JSObjectRef) val);

Modified: trunk/libseed/seed-types.h
==============================================================================
--- trunk/libseed/seed-types.h	(original)
+++ trunk/libseed/seed-types.h	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed-types.h
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -23,17 +25,19 @@
 #include "seed-private.h"
 
 SeedValue seed_value_from_gvalue(GValue * gval, JSValueRef * exception);
-SeedValue seed_value_get_property(SeedValue val, const gchar *name);
+SeedValue seed_value_get_property(SeedValue val, const gchar * name);
 
 gboolean seed_value_set_property(JSObjectRef object,
-				 const gchar *name, JSValueRef value);
-gboolean seed_gvalue_from_seed_value(SeedValue val, GType type, GValue * gval,
-									 JSValueRef * exception);
+				 const gchar * name, JSValueRef value);
+gboolean seed_gvalue_from_seed_value(SeedValue val, GType type,
+				     GValue * gval, JSValueRef * exception);
 gboolean seed_gi_supports_type(GITypeInfo * type_info);
-gboolean seed_gi_make_argument(SeedValue value, GITypeInfo * type_info,
-							   GArgument * arg, JSValueRef * exception);
-JSValueRef seed_gi_argument_make_js(GArgument * arg, GITypeInfo * type_info,
-									JSValueRef * exception);
+gboolean seed_gi_make_argument(SeedValue value,
+			       GITypeInfo * type_info,
+			       GArgument * arg, JSValueRef * exception);
+JSValueRef seed_gi_argument_make_js(GArgument * arg,
+				    GITypeInfo * type_info,
+				    JSValueRef * exception);
 
 GType seed_gi_type_to_gtype(GITypeInfo * type_info, GITypeTag tag);
 
@@ -76,8 +80,6 @@
 GObject *seed_value_to_object(JSValueRef val, JSValueRef * exception);
 JSValueRef seed_value_from_object(GObject * val, JSValueRef * exception);
 
-void seed_toggle_ref(gpointer data,
-							GObject * object,
-					 gboolean is_last_ref);
+void seed_toggle_ref(gpointer data, GObject * object, gboolean is_last_ref);
 
 #endif

Modified: trunk/libseed/seed.h
==============================================================================
--- trunk/libseed/seed.h	(original)
+++ trunk/libseed/seed.h	Sat Nov  8 01:41:15 2008
@@ -1,4 +1,6 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- 
+ */
 /*
  * seed.h
  * Copyright (C) Robert Carr 2008 <carrr rpi edu>
@@ -29,8 +31,10 @@
 
 typedef struct _SeedScript SeedScript;
 
-/* seed-engine.c */
-gboolean seed_init(gint *argc, gchar ***argv);
+/*
+ * seed-engine.c 
+ */
+gboolean seed_init(gint * argc, gchar *** argv);
 
 SeedScript *seed_make_script(const gchar * s, const gchar * source_url,
 			     gint line_number);
@@ -43,55 +47,57 @@
 
 SeedValue seed_evaluate(SeedScript * s, SeedObject this);
 
-/* seed-types.c */
+/*
+ * seed-types.c 
+ */
 
-gboolean seed_value_to_boolean(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_boolean(gboolean val, SeedException *exception);
+gboolean seed_value_to_boolean(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_boolean(gboolean val, SeedException * exception);
 
-guint seed_value_to_uint(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_uint(guint val, SeedException *exception);
+guint seed_value_to_uint(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_uint(guint val, SeedException * exception);
 
-gint seed_value_to_int(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_int(gint val, SeedException *exception);
+gint seed_value_to_int(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_int(gint val, SeedException * exception);
 
-gchar seed_value_to_char(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_char(gchar val, SeedException *exception);
+gchar seed_value_to_char(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_char(gchar val, SeedException * exception);
 
-guchar seed_value_to_uchar(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_uchar(guchar val, SeedException *exception);
+guchar seed_value_to_uchar(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_uchar(guchar val, SeedException * exception);
 
-glong seed_value_to_long(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_long(glong val, SeedException *exception);
+glong seed_value_to_long(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_long(glong val, SeedException * exception);
 
-gulong seed_value_to_ulong(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_ulong(gulong val, SeedException *exception);
+gulong seed_value_to_ulong(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_ulong(gulong val, SeedException * exception);
 
-gint64 seed_value_to_int64(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_int64(gint64 val, SeedException *exception);
+gint64 seed_value_to_int64(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_int64(gint64 val, SeedException * exception);
 
-guint64 seed_value_to_uint64(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_uint64(guint64 val, SeedException *exception);
+guint64 seed_value_to_uint64(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_uint64(guint64 val, SeedException * exception);
 
-gfloat seed_value_to_float(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_float(gfloat val, SeedException *exception);
+gfloat seed_value_to_float(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_float(gfloat val, SeedException * exception);
 
-gdouble seed_value_to_double(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_double(gdouble val, SeedException *exception);
+gdouble seed_value_to_double(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_double(gdouble val, SeedException * exception);
 
-gchar *seed_value_to_string(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_string(gchar * val, SeedException *exception);
+gchar *seed_value_to_string(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_string(gchar * val, SeedException * exception);
 
-GObject *seed_value_to_object(SeedValue val, SeedException *exception);
-SeedValue seed_value_from_object(GObject * val, SeedException *exception);
+GObject *seed_value_to_object(SeedValue val, SeedException * exception);
+SeedValue seed_value_from_object(GObject * val, SeedException * exception);
 
 typedef void (*SeedFunctionCallback) (SeedContextRef ctx,
-									  SeedObject function,
-									  SeedObject this_object,
-									  size_t argument_count,
-									  const SeedValue arguments[],
-									  SeedException * exception);
+				      SeedObject function,
+				      SeedObject this_object,
+				      size_t argument_count,
+				      const SeedValue arguments[],
+				      SeedException * exception);
 
 void seed_create_function(gchar * name, SeedFunctionCallback,
-						  SeedObject object);
+			  SeedObject object);
 
 #endif



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