seed r6 - in trunk: examples libseed
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r6 - in trunk: examples libseed
- Date: Sat, 18 Oct 2008 02:54:45 +0000 (UTC)
Author: racarr
Date: Sat Oct 18 02:54:44 2008
New Revision: 6
URL: http://svn.gnome.org/viewvc/seed?rev=6&view=rev
Log:
Myriad of bug fixes, Gio example.
Added:
trunk/examples/ls.js (contents, props changed)
Modified:
trunk/libseed/seed-engine.c
trunk/libseed/seed-engine.h
trunk/libseed/seed-types.c
Added: trunk/examples/ls.js
==============================================================================
--- (empty file)
+++ trunk/examples/ls.js Sat Oct 18 02:54:44 2008
@@ -0,0 +1,10 @@
+#!/usr/local/bin/seed
+Seed.import_namespace("Gio");
+
+file = Gio.file_new_for_path(".");
+enumerator = file.enumerate_children("standard::name");
+
+while (child = enumerator.next_file())
+{
+ Seed.print(child.get_name());
+}
Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c (original)
+++ trunk/libseed/seed-engine.c Sat Oct 18 02:54:44 2008
@@ -264,7 +264,7 @@
return retval_ref;
}
-static void seed_gobject_define_property_from_function_info(GIFunctionInfo *info, JSObjectRef object)
+void seed_gobject_define_property_from_function_info(GIFunctionInfo *info, JSObjectRef object)
{
GIFunctionInfoFlags flags;
int n_args, i;
Modified: trunk/libseed/seed-engine.h
==============================================================================
--- trunk/libseed/seed-engine.h (original)
+++ trunk/libseed/seed-engine.h Sat Oct 18 02:54:44 2008
@@ -41,5 +41,6 @@
JSClassRef seed_gobject_get_class_for_gtype(GType type);
JSValueRef seed_locale_string_to_seed_value(char * str);
+void seed_gobject_define_property_from_function_info(GIFunctionInfo *info, JSObjectRef object);
#endif
Modified: trunk/libseed/seed-types.c
==============================================================================
--- trunk/libseed/seed-types.c (original)
+++ trunk/libseed/seed-types.c Sat Oct 18 02:54:44 2008
@@ -68,8 +68,9 @@
SeedValue user_data;
SeedValue js_ref;
JSClassRef class;
- GType type;
+ GType type, *interfaces;
JSValueRef prototype;
+ guint i, n;
type = G_OBJECT_TYPE(object);
@@ -88,10 +89,32 @@
class = seed_gobject_get_class_for_gtype(type);
}
-
prototype = seed_gobject_get_prototype_for_gtype(type);
js_ref = JSObjectMake(eng->context, class, object);
- JSObjectSetPrototype(eng->context, (JSObjectRef)js_ref, prototype);
+ if (prototype)
+ JSObjectSetPrototype(eng->context,
+ (JSObjectRef)js_ref, prototype);
+ else
+ {
+ interfaces = g_type_interfaces(G_OBJECT_TYPE(object), &n);
+ for (i = 0; i < n; i++)
+ {
+ GIFunctionInfo * function;
+ GIBaseInfo * interface;
+ gint n_functions, k;
+
+ interface = g_irepository_find_by_gtype(0,
+ interfaces[i]);
+
+ 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,
+ (JSObjectRef)js_ref);
+ }
+ }
+ }
// Is this going to work? g_free seems wrong, don't we need some
// variety of finalize. This is a pointer declared on the stack anyway.
@@ -106,10 +129,6 @@
0); */
return js_ref;
-
-
-
-
}
/* Should update to try and use glib type conversion */
@@ -193,7 +212,8 @@
interface = g_type_info_get_interface(type_info);
interface_type = g_base_info_get_type(interface);
- if (interface_type == GI_INFO_TYPE_OBJECT)
+ if (interface_type == GI_INFO_TYPE_OBJECT ||
+ interface_type == GI_INFO_TYPE_INTERFACE)
return G_TYPE_OBJECT;
else if (interface_type == GI_INFO_TYPE_ENUM)
return G_TYPE_LONG;
@@ -288,7 +308,8 @@
arg->v_pointer = NULL;
- if (interface_type == GI_INFO_TYPE_OBJECT)
+ if (interface_type == GI_INFO_TYPE_OBJECT
+ || interface_type == GI_INFO_TYPE_INTERFACE)
{
if (!G_VALUE_HOLDS_OBJECT(&gval))
{
@@ -399,8 +420,14 @@
interface_type = g_base_info_get_type(interface);
- if (interface_type == GI_INFO_TYPE_OBJECT)
+ if (interface_type == GI_INFO_TYPE_OBJECT ||
+ interface_type == GI_INFO_TYPE_INTERFACE)
{
+ if (arg->v_pointer == 0)
+ {
+ g_value_unset(&gval);
+ return JSValueMakeNull(eng->context);
+ }
g_value_set_object(&gval, arg->v_pointer);
break;
}
@@ -561,8 +588,8 @@
else
val = seed_wrap_object(gobject);
-
- g_object_unref(gobject);
+ if (gobject)
+ g_object_unref(gobject);
return val;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]