[seed: 4/15] Importer supports GI_INFO_TYPE_STRUCT
- From: Robert Carr <racarr src gnome org>
- To: svn-commits-list gnome org
- Subject: [seed: 4/15] Importer supports GI_INFO_TYPE_STRUCT
- Date: Sun, 12 Apr 2009 02:11:04 -0400 (EDT)
commit 58f0d615b63c9ae0da60ff83267f4e1e4f7bd6a6
Author: Robert Carr <racarr mireia (none)>
Date: Sat Apr 11 17:55:47 2009 -0400
Importer supports GI_INFO_TYPE_STRUCT
---
libseed/seed-engine.h | 1 +
libseed/seed-importer.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/libseed/seed-engine.h b/libseed/seed-engine.h
index ce42c65..ed10ece 100644
--- a/libseed/seed-engine.h
+++ b/libseed/seed-engine.h
@@ -28,6 +28,7 @@ extern JSClassRef gobject_class;
extern JSClassRef gobject_method_class;
extern JSClassRef gobject_constructor_class;
extern JSClassRef gobject_named_constructor_class;
+extern JSClassRef seed_struct_constructor_class;
extern JSClassRef seed_callback_class;
extern SeedEngine *eng;
diff --git a/libseed/seed-importer.c b/libseed/seed-importer.c
index c085e74..d750cf7 100644
--- a/libseed/seed-importer.c
+++ b/libseed/seed-importer.c
@@ -123,6 +123,42 @@ seed_gi_importer_handle_object (JSContextRef ctx,
}
}
+static void
+seed_gi_importer_handle_struct (JSContextRef ctx,
+ JSObjectRef namespace_ref,
+ GIStructInfo *info,
+ JSValueRef *exception)
+{
+ JSObjectRef struct_ref;
+ JSObjectRef proto;
+ gint i, n_methods;
+ GIFunctionInfo *finfo;
+
+ struct_ref =
+ JSObjectMake (ctx, seed_struct_constructor_class, info);
+
+ n_methods = g_struct_info_get_n_methods (info);
+
+ for (i = 0; i < n_methods; i++)
+ {
+ GIFunctionInfoFlags flags;
+ finfo = g_struct_info_get_method ((GIStructInfo *) info, i);
+
+ flags = g_function_info_get_flags (finfo);
+
+ if (flags & GI_FUNCTION_IS_METHOD)
+ g_base_info_unref ((GIBaseInfo *) finfo);
+ else
+ seed_gobject_define_property_from_function_info
+ (ctx, finfo, struct_ref, FALSE);
+ }
+
+ proto = seed_struct_prototype (ctx, (GIBaseInfo *)info);
+ seed_object_set_property (ctx, struct_ref, "prototype", proto);
+
+ seed_object_set_property (ctx, namespace_ref, g_base_info_get_name ((GIBaseInfo *)info), struct_ref);
+}
+
static JSObjectRef
seed_gi_importer_do_namespace (JSContextRef ctx,
gchar *namespace,
@@ -168,6 +204,10 @@ seed_gi_importer_do_namespace (JSContextRef ctx,
seed_gi_importer_handle_object (ctx, namespace_ref, (GIObjectInfo *) info, exception);
g_base_info_unref (info);
break;
+ case GI_INFO_TYPE_STRUCT:
+ seed_gi_importer_handle_struct (ctx, namespace_ref, (GIStructInfo *) info, exception);
+ g_base_info_unref (info);
+ break;
default:
g_base_info_unref (info);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]