seed r153 - in trunk: libseed tests



Author: racarr
Date: Fri Nov  7 05:06:01 2008
New Revision: 153
URL: http://svn.gnome.org/viewvc/seed?rev=153&view=rev

Log:
Pass prototype into class_init.


Modified:
   trunk/libseed/seed-gtype.c
   trunk/tests/gtype.js

Modified: trunk/libseed/seed-gtype.c
==============================================================================
--- trunk/libseed/seed-gtype.c	(original)
+++ trunk/libseed/seed-gtype.c	Fri Nov  7 05:06:01 2008
@@ -29,9 +29,12 @@
 {
 		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_value_from_int(*(gint*)args[1],0);
+		jsargs[1] = seed_gobject_get_prototype_for_gtype(type);
 		
 		JSObjectCallAsFunction(eng->context,
 							   function,
@@ -131,6 +134,7 @@
 		ffi_closure * init_closure = 0;
 		ffi_closure * instance_init_closure = 0;
 		GTypeQuery query;
+		JSObjectRef constructor_ref;
 
 		if (argumentCount != 1)
 		{
@@ -183,10 +187,17 @@
 		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, 

Modified: trunk/tests/gtype.js
==============================================================================
--- trunk/tests/gtype.js	(original)
+++ trunk/tests/gtype.js	Fri Nov  7 05:06:01 2008
@@ -1,7 +1,7 @@
 #!/usr/local/bin/seed
 // Returns: 0
 // STDIN:
-// STDOUT:In constructor for \[object HelloWindow\]\nIn map, verifying widget\.title : Hello!
+// STDOUT:In klass init\nIn constructor for \[object HelloWindow\]\nPrototypes!\nIn map, verifying widget\.title : Hello!
 // STDERR:
 
 Seed.import_namespace("Gtk");
@@ -10,6 +10,11 @@
 HelloWindowType = {
     parent: Gtk.Window,
     name: "HelloWindow",
+    class_init: function(klass, prototype)
+    {
+	prototype.message = "Prototypes!";
+	Seed.print("In klass init");
+    },
     instance_init: function(widget, klass)
     {
 	widget.title = "Hello!";
@@ -18,6 +23,7 @@
 
 HelloWindow = new GType(HelloWindowType);
 w = new HelloWindow();
+Seed.print(w.message);
 w.signal.map.connect(
 		     function(widget)
 		     {



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