seed r689 - trunk/libseed
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r689 - trunk/libseed
- Date: Fri, 9 Jan 2009 03:40:23 +0000 (UTC)
Author: racarr
Date: Fri Jan 9 03:40:22 2009
New Revision: 689
URL: http://svn.gnome.org/viewvc/seed?rev=689&view=rev
Log:
Add support for GI_TYPE_TAG_ARRAY in return.
Modified:
trunk/libseed/seed-types.c
Modified: trunk/libseed/seed-types.c
==============================================================================
--- trunk/libseed/seed-types.c (original)
+++ trunk/libseed/seed-types.c Fri Jan 9 03:40:22 2009
@@ -205,6 +205,42 @@
return TRUE;
}
+static JSValueRef
+seed_gi_make_jsarray(JSContextRef ctx,
+ void * array,
+ GITypeInfo * param_type,
+ JSValueRef * exception)
+{
+ GITypeTag element_type;
+ JSValueRef ret = JSValueMakeNull(ctx);
+
+ element_type = g_type_info_get_tag(param_type);
+
+ if (element_type == GI_TYPE_TAG_UTF8)
+ {
+ JSValueRef * elements;
+ guint length, i;
+ gchar ** str_array = (gchar **) array;
+
+ length = g_strv_length(str_array);
+ if (!length)
+ return ret;
+
+ elements = g_alloca(sizeof(JSValueRef) * length);
+ for (i = 0; i < length; ++i)
+ {
+ elements[i] = seed_value_from_string(ctx,
+ str_array[i],
+ exception);
+ }
+
+ ret = (JSValueRef) JSObjectMakeArray(ctx, length,
+ elements, exception);
+ }
+
+ return ret;
+}
+
static gboolean
seed_gi_make_array(JSContextRef ctx,
JSValueRef array,
@@ -497,7 +533,7 @@
}
else if (!JSValueIsObject(ctx, value))
{
- // Is this right?
+ // TODO: FIXME: Is this right?
return FALSE;
}
else
@@ -579,8 +615,24 @@
return seed_value_from_string(ctx, arg->v_string, exception);
case GI_TYPE_TAG_GTYPE:
return seed_value_from_int(ctx, arg->v_int, exception);
+ case GI_TYPE_TAG_ARRAY:
+ {
+ GITypeInfo *param_type;
+ JSValueRef ret;
+ if (!g_type_info_is_zero_terminated(type_info))
+ break;
+
+ param_type = g_type_info_get_param_type(type_info, 0);
+
+ ret = seed_gi_make_jsarray(ctx, arg->v_pointer, param_type,
+ exception);
+
+ g_base_info_unref((GIBaseInfo *) param_type);
+
+ return ret;
+ }
case GI_TYPE_TAG_INTERFACE:
- {
+ {
GIBaseInfo *interface;
GIInfoType interface_type;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]