[seed] libseed: Fix passing a union out to a C function
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [seed] libseed: Fix passing a union out to a C function
- Date: Tue, 12 Jan 2010 07:11:30 +0000 (UTC)
commit 1300996938d77f8ea7e6739b4d912b7f79274831
Author: Tim Horton <hortont424 gmail com>
Date: Tue Jan 12 01:35:35 2010 -0500
libseed: Fix passing a union out to a C function
The parent class of seed_union was set to seed_union (undefined at that point);
I believe it should be seed_pointer, just like seed_struct
libseed/seed-structs.c | 8 +++++++-
libseed/seed-structs.h | 1 +
libseed/seed-types.c | 9 ++++++---
3 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/libseed/seed-structs.c b/libseed/seed-structs.c
index 73d0e48..5abeabe 100644
--- a/libseed/seed-structs.c
+++ b/libseed/seed-structs.c
@@ -541,6 +541,12 @@ JSObjectRef
seed_make_union (JSContextRef ctx, gpointer younion, GIBaseInfo * info)
{
JSObjectRef object;
+
+ if (younion == NULL)
+ {
+ return JSValueMakeNull (ctx);
+ }
+
seed_struct_privates *priv = g_slice_alloc (sizeof (seed_struct_privates));
priv->pointer = younion;
@@ -659,7 +665,7 @@ seed_structs_init (void)
seed_pointer_class = JSClassCreate (&seed_pointer_def);
seed_struct_def.parentClass = seed_pointer_class;
seed_struct_class = JSClassCreate (&seed_struct_def);
- seed_union_def.parentClass = seed_union_class;
+ seed_union_def.parentClass = seed_pointer_class;
seed_union_class = JSClassCreate (&seed_union_def);
seed_boxed_def.parentClass = seed_struct_class;
seed_boxed_class = JSClassCreate (&seed_boxed_def);
diff --git a/libseed/seed-structs.h b/libseed/seed-structs.h
index 1c066f7..3d4ebb3 100644
--- a/libseed/seed-structs.h
+++ b/libseed/seed-structs.h
@@ -19,6 +19,7 @@
#ifndef _SEED_STRUCT_H
#define _SEED_STRUCT_H
extern JSClassRef seed_struct_class;
+extern JSClassRef seed_union_class;
JSObjectRef seed_make_union (JSContextRef ctx, gpointer younion,
GIBaseInfo * info);
diff --git a/libseed/seed-types.c b/libseed/seed-types.c
index 39abb9f..67060be 100644
--- a/libseed/seed-types.c
+++ b/libseed/seed-types.c
@@ -542,8 +542,8 @@ seed_gi_make_argument (JSContextRef ctx,
arg->v_pointer = NULL;
- if (interface_type == GI_INFO_TYPE_OBJECT
- || interface_type == GI_INFO_TYPE_INTERFACE)
+ if (interface_type == GI_INFO_TYPE_OBJECT ||
+ interface_type == GI_INFO_TYPE_INTERFACE)
{
gobject = seed_value_to_object (ctx, value, exception);
required_gtype =
@@ -584,10 +584,13 @@ seed_gi_make_argument (JSContextRef ctx,
g_base_info_unref (interface);
break;
}
- else if (interface_type == GI_INFO_TYPE_STRUCT)
+ else if (interface_type == GI_INFO_TYPE_STRUCT ||
+ interface_type == GI_INFO_TYPE_UNION)
{
if (JSValueIsObjectOfClass (ctx, value, seed_struct_class))
arg->v_pointer = seed_pointer_get_pointer (ctx, value);
+ else if (JSValueIsObjectOfClass (ctx, value, seed_union_class))
+ arg->v_pointer = seed_pointer_get_pointer (ctx, value);
else
{
GType type =
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]