[seed] Fix incorrect type assumption
- From: Tim Horton <hortont src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [seed] Fix incorrect type assumption
- Date: Mon, 4 Jan 2010 06:09:53 +0000 (UTC)
commit 07db8b4966ca85a256137d32eeca2a634f473825
Author: Tim Horton <hortont424 gmail com>
Date: Mon Jan 4 00:56:29 2010 -0500
Fix incorrect type assumption
seed_gi_argument_make_js was assuming that enums and flags are always longs,
which is (apparently) incorrect. Check the type and convert accordingly.
libseed/seed-types.c | 42 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 41 insertions(+), 1 deletions(-)
---
diff --git a/libseed/seed-types.c b/libseed/seed-types.c
index 39abb9f..bd3d4c0 100644
--- a/libseed/seed-types.c
+++ b/libseed/seed-types.c
@@ -744,6 +744,46 @@ seed_gi_make_argument (JSContextRef ctx,
}
JSValueRef
+seed_gi_argument_make_js_gtype (JSContextRef ctx,
+ GArgument * arg, GType type,
+ JSValueRef * exception)
+{
+ switch (G_TYPE_FUNDAMENTAL(type))
+ {
+ case G_TYPE_BOOLEAN:
+ return seed_value_from_boolean (ctx, arg->v_boolean, exception);
+ case G_TYPE_CHAR:
+ return seed_value_from_char (ctx, arg->v_int8, exception);
+ case G_TYPE_UCHAR:
+ return seed_value_from_uchar (ctx, arg->v_uint8, exception);
+ case G_TYPE_INT:
+ return seed_value_from_int (ctx, arg->v_int32, exception);
+ case G_TYPE_UINT:
+ return seed_value_from_uint (ctx, arg->v_uint32, exception);
+ case G_TYPE_LONG:
+ return seed_value_from_long (ctx, arg->v_long, exception);
+ case G_TYPE_INT64:
+ return seed_value_from_int64 (ctx, arg->v_int64, exception);
+ case G_TYPE_ULONG:
+ return seed_value_from_ulong (ctx, arg->v_ulong, exception);
+ case G_TYPE_UINT64:
+ return seed_value_from_uint64 (ctx, arg->v_uint64, exception);
+ case G_TYPE_FLOAT:
+ return seed_value_from_float (ctx, arg->v_float, exception);
+ case G_TYPE_DOUBLE:
+ return seed_value_from_double (ctx, arg->v_double, exception);
+ case G_TYPE_STRING:
+ return seed_value_from_string (ctx, arg->v_string, exception);
+ case G_TYPE_POINTER:
+ return seed_make_pointer (ctx, arg->v_pointer);
+
+ // TODO: OTHER TYPES?
+ }
+
+ return JSValueMakeUndefined (ctx);
+}
+
+JSValueRef
seed_gi_argument_make_js (JSContextRef ctx,
GArgument * arg, GITypeInfo * type_info,
JSValueRef * exception)
@@ -837,7 +877,7 @@ seed_gi_argument_make_js (JSContextRef ctx,
|| interface_type == GI_INFO_TYPE_FLAGS)
{
g_base_info_unref (interface);
- return seed_value_from_long (ctx, arg->v_long, exception);
+ return seed_gi_argument_make_js_gtype (ctx, arg, g_base_info_get_type(type_info), exception);
}
else if (interface_type == GI_INFO_TYPE_STRUCT)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]