seed r58 - in trunk: examples libseed



Author: racarr
Date: Sun Nov  2 10:20:42 2008
New Revision: 58
URL: http://svn.gnome.org/viewvc/seed?rev=58&view=rev

Log:
Lots of struct work, argument conversion work. Support methods of 
structs. Magic, etc...ladeda. Somewhat sane handling of boxed types now. 
ClutterColor works better than ever! Now ClutterVertex works.

Add spinning bob dylan example.


Added:
   trunk/examples/bob.jpg   (contents, props changed)
   trunk/examples/clutter.js   (contents, props changed)
Modified:
   trunk/libseed/seed-engine.c
   trunk/libseed/seed-structs.c
   trunk/libseed/seed-structs.h
   trunk/libseed/seed-types.c

Added: trunk/examples/bob.jpg
==============================================================================
Binary file. No diff available.

Added: trunk/examples/clutter.js
==============================================================================
--- (empty file)
+++ trunk/examples/clutter.js	Sun Nov  2 10:20:42 2008
@@ -0,0 +1,44 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Clutter");
+
+Clutter.init(null, null);
+
+var stage = new Clutter.Stage();
+var texture = new Clutter.Texture({filename:"bob.jpg"});
+var reflection = new Clutter.CloneTexture({parent_texture:texture});
+var black = Clutter.Color._new();
+
+Clutter.color_parse("Black", black);
+
+
+stage.set_color(black);
+stage.add_actor(texture);
+stage.add_actor(reflection);
+
+reflection.width = reflection.height = 
+   texture.height = texture.width = .55*stage.height;
+texture.x = stage.width/2;
+texture.y = stage.height/2;
+reflection.x = texture.x
+reflection.y = texture.y+texture.height;
+reflection.rotation_angle_z = 180;
+
+reflection.opacity = 80;
+
+reflection.anchor_x = texture.anchor_x = texture.width/2;
+reflection.anchor_y = texture.anchor_y = texture.height/2;
+
+reflection.rotation_angle_y=330;
+texture.rotation_angle_y=30;
+timeline = new Clutter.Timeline({fps:30, num_frames: 60});
+timeline.signal_new_frame.connect(function(timeline, frame_num)
+			  {
+			      texture.rotation_angle_y+=3;
+			      reflection.rotation_angle_y-=3;
+			  });
+timeline.start();
+
+
+stage.show_all();
+Clutter.main();
+

Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c	(original)
+++ trunk/libseed/seed-engine.c	Sun Nov  2 10:20:42 2008
@@ -196,7 +196,9 @@
 		GError * error = 0;
 	
 		info = JSObjectGetPrivate(function);
-		if (!(object = seed_value_to_object(this_object)))
+		if (!
+			((object = seed_value_to_object(this_object)) ||
+			 (object = seed_struct_get_pointer(this_object))))
 				instance_method = FALSE;
 
 		n_args = g_callable_info_get_n_args((GICallableInfo *) info);
@@ -279,10 +281,6 @@
 													 gboolean instance)
 {
 		GIFunctionInfoFlags flags;
-		int n_args, i;
-		GIArgInfo *arg_info;
-		GITypeInfo *type_info;
-		GIDirection dir;
 		SeedValue method_ref;
 		const gchar * name;
 
@@ -292,26 +290,12 @@
 	
 		flags = g_function_info_get_flags (info);
 	
-		if (instance && ((flags & GI_FUNCTION_IS_CONSTRUCTOR) ||
-			(flags & GI_FUNCTION_IS_GETTER) ||
-			 (flags & GI_FUNCTION_IS_SETTER)))
+		if (instance && (flags & GI_FUNCTION_IS_CONSTRUCTOR))
+
 		{
 				return;
 		}
 	
-		n_args = g_callable_info_get_n_args((GICallableInfo *) info);
-		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 (!seed_gi_supports_type(type_info))
-						g_base_info_unref((GIBaseInfo *)type_info);
-		
-		}
 	
 		method_ref = JSObjectMake(eng->context, gobject_method_class, info);
 
@@ -360,7 +344,8 @@
 		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);
+				seed_gobject_define_property_from_function_info(info, 
+																object, TRUE);
 		}
 }
 
@@ -702,7 +687,7 @@
 
 
 								n_methods = 
-									g_object_info_get_n_methods((GIObjectInfo *)info);
+							  g_object_info_get_n_methods((GIObjectInfo *)info);
 								for (i = 0; i < n_methods; i++)
 								{
 										finfo = 
@@ -738,7 +723,6 @@
 						JSObjectRef struct_ref;
 						int i, n_methods;
 						GIFunctionInfo *finfo;
-						GIFunctionInfoFlags flags;
 						
 						struct_ref = JSObjectMake(eng->context, 0, 0);
 						
@@ -749,13 +733,10 @@
 								finfo =
 										g_struct_info_get_method(
 												(GIStructInfo*)info, i);
-								flags = g_function_info_get_flags(finfo);
-								if (flags & GI_FUNCTION_IS_CONSTRUCTOR)
-								{
 										seed_gobject_define_property_from_function_info(finfo, 
 																						struct_ref,
 																						FALSE);
-								}
+
 						}
 						
 						seed_value_set_property(namespace_ref,

Modified: trunk/libseed/seed-structs.c
==============================================================================
--- trunk/libseed/seed-structs.c	(original)
+++ trunk/libseed/seed-structs.c	Sun Nov  2 10:20:42 2008
@@ -55,15 +55,34 @@
 	return 0;
 }
 
-JSObjectRef seed_make_union(gpointer younion)
+JSObjectRef seed_make_union(gpointer younion, GIBaseInfo *info)
 {
-	if (!seed_struct_class)
-		seed_struct_class = JSClassCreate(&gobject_struct_def);
-	
-	return JSObjectMake(eng->context, seed_struct_class, younion);
+		JSObjectRef object;
+		int i, n_methods;
+		
+		if (!seed_struct_class)
+				seed_struct_class = JSClassCreate(&gobject_struct_def);
+		
+		object = JSObjectMake(eng->context, seed_struct_class, younion);
+		
+		n_methods =
+				g_struct_info_get_n_methods((GIStructInfo *)info);
+		for (i = 0; i < n_methods; i++)
+		{
+				GIFunctionInfo *finfo;
+
+				finfo = g_struct_info_get_method(
+						(GIStructInfo*)info, i);
+				
+				seed_gobject_define_property_from_function_info((GIFunctionInfo *)finfo,
+																object,
+																TRUE);
+		}
+		seed_value_set_property(object, "test", seed_value_from_int(5));
+		return object;
 }
 
-JSObjectRef seed_make_struct(gpointer strukt)
+JSObjectRef seed_make_struct(gpointer strukt, GIBaseInfo *info)
 {
-		return seed_make_union(strukt);
+		return seed_make_union(strukt, info);
 }

Modified: trunk/libseed/seed-structs.h
==============================================================================
--- trunk/libseed/seed-structs.h	(original)
+++ trunk/libseed/seed-structs.h	Sun Nov  2 10:20:42 2008
@@ -20,8 +20,8 @@
 #ifndef _SEED_STRUCT_H
 #define _SEED_STRUCT_H
 
-JSObjectRef seed_make_union(gpointer younion);
-JSObjectRef seed_make_struct(gpointer strukt);
+JSObjectRef seed_make_union(gpointer younion, GIBaseInfo *info);
+JSObjectRef seed_make_struct(gpointer strukt, GIBaseInfo *info);
 gpointer seed_struct_get_pointer(JSValueRef strukt);
 
 #endif

Modified: trunk/libseed/seed-types.c
==============================================================================
--- trunk/libseed/seed-types.c	(original)
+++ trunk/libseed/seed-types.c	Sun Nov  2 10:20:42 2008
@@ -167,7 +167,7 @@
 
 
 gboolean seed_gi_make_argument(SeedValue value,
-							   GITypeInfo *type_info,
+							   GITypeInfo * type_info,
 							   GArgument * arg)
 {
 		GITypeTag gi_tag = g_type_info_get_tag(type_info);
@@ -283,7 +283,7 @@
 		
 }
 
-JSValueRef seed_gi_argument_make_js(GArgument * arg, GITypeInfo *type_info)
+JSValueRef seed_gi_argument_make_js(GArgument * arg, GITypeInfo * type_info)
 {
 		GITypeTag gi_tag = g_type_info_get_tag(type_info);
 		switch (gi_tag)
@@ -347,7 +347,7 @@
 				}
 				else if (interface_type == GI_INFO_TYPE_STRUCT)
 				{
-						return seed_make_struct(arg->v_pointer);
+						return seed_make_struct(arg->v_pointer, interface);
 				}
 		}
 	  
@@ -458,12 +458,12 @@
 		
 		if (type == GI_INFO_TYPE_UNION)
 		{
-				return seed_make_union(g_value_peek_pointer(gval));
+				return seed_make_union(g_value_peek_pointer(gval), info);
 
 		}
 		else if (type == GI_INFO_TYPE_STRUCT)
 		{
-				return seed_make_struct(g_value_peek_pointer(gval));
+				return seed_make_struct(g_value_peek_pointer(gval), info);
 									
 		}
 			
@@ -617,6 +617,17 @@
 
 		g_object_unref(o);
 	}
+	else if(g_type_is_a(type, G_TYPE_BOXED))
+	{
+			gpointer p = seed_struct_get_pointer(val);
+			if (p)
+			{
+					g_value_init(ret, type);
+					g_value_set_boxed(ret, p);
+					return TRUE;
+			}
+	}
+
 	return FALSE;
 }
 



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