seed r317 - trunk/libseed
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r317 - trunk/libseed
- Date: Mon, 24 Nov 2008 03:24:37 +0000 (UTC)
Author: racarr
Date: Mon Nov 24 03:24:37 2008
New Revision: 317
URL: http://svn.gnome.org/viewvc/seed?rev=317&view=rev
Log:
Big cleanup of the new struct code.
Modified:
trunk/libseed/seed-structs.c
Modified: trunk/libseed/seed-structs.c
==============================================================================
--- trunk/libseed/seed-structs.c (original)
+++ trunk/libseed/seed-structs.c Mon Nov 24 03:24:37 2008
@@ -99,33 +99,16 @@
}
static JSValueRef
-seed_union_get_property(JSContextRef context,
- JSObjectRef object,
- JSStringRef property_name, JSValueRef * exception)
+seed_field_get_value(gpointer object,
+ GIFieldInfo * field,
+ JSValueRef * exception)
{
- gpointer pointer;
- gchar *cproperty_name;
- int i;
- int length;
- seed_struct_privates *priv = JSObjectGetPrivate(object);
- GIFieldInfo *field = 0;
- GITypeInfo *field_type = 0;
+ GITypeInfo *field_type;
GArgument field_value;
JSValueRef ret;
- length = JSStringGetMaximumUTF8CStringSize(property_name);
- cproperty_name = g_malloc(length * sizeof(gchar));
- JSStringGetUTF8CString(property_name, cproperty_name, length);
-
- field = seed_union_find_field((GIUnionInfo *) priv->info, cproperty_name);
- if (!field)
- {
- g_free(cproperty_name);
- return 0;
- }
-
field_type = g_field_info_get_type(field);
- if (!g_field_info_get_field(field, priv->pointer, &field_value))
+ if (!g_field_info_get_field(field, object, &field_value))
{
GITypeTag tag;
@@ -139,31 +122,60 @@
switch (g_base_info_get_type(interface))
{
case GI_INFO_TYPE_STRUCT:
- ret = seed_make_struct((priv->pointer + offset), interface);
- goto found;
+ return seed_make_struct((object + offset), interface);
+
case GI_INFO_TYPE_UNION:
- ret = seed_make_union((priv->pointer + offset), interface);
- goto found;
+ return seed_make_union((object + offset), interface);
+
case GI_INFO_TYPE_BOXED:
- ret = seed_make_boxed((priv->pointer + offset), interface);
- goto found;
+ return seed_make_boxed((object + offset), interface);
+
default:
g_base_info_unref(interface);
}
}
- g_free(cproperty_name);
return JSValueMakeNull(eng->context);
}
// Maybe need to release argument.
ret = seed_gi_argument_make_js(&field_value, field_type, exception);
+ if (field_type)
+ g_base_info_unref((GIBaseInfo *) field_type);
+ return ret;
+}
+
+
+static JSValueRef
+seed_union_get_property(JSContextRef context,
+ JSObjectRef object,
+ JSStringRef property_name, JSValueRef * exception)
+{
+ gpointer pointer;
+ gchar *cproperty_name;
+ int i;
+ int length;
+ seed_struct_privates *priv = JSObjectGetPrivate(object);
+ GIFieldInfo *field = 0;
+ GITypeInfo *field_type = 0;
+ GArgument field_value;
+ JSValueRef ret;
+
+ length = JSStringGetMaximumUTF8CStringSize(property_name);
+ cproperty_name = g_malloc(length * sizeof(gchar));
+ JSStringGetUTF8CString(property_name, cproperty_name, length);
+
+ field = seed_union_find_field((GIUnionInfo *) priv->info, cproperty_name);
+ if (!field)
+ {
+ g_free(cproperty_name);
+ return 0;
+ }
- found:
+ ret = seed_field_get_value(priv->pointer, field, exception);
g_base_info_unref((GIBaseInfo *) field);
- if (field_type)
- g_base_info_unref((GIBaseInfo *) field_type);
+
g_free(cproperty_name);
return ret;
@@ -196,45 +208,9 @@
return 0;
}
- field_type = g_field_info_get_type(field);
- if (!g_field_info_get_field(field, priv->pointer, &field_value))
- {
- GITypeTag tag;
-
- tag = g_type_info_get_tag(field_type);
- if (tag == GI_TYPE_TAG_INTERFACE)
- {
- GIBaseInfo *interface;
-
- interface = g_type_info_get_interface(field_type);
- gint offset = g_field_info_get_offset(field);
- switch (g_base_info_get_type(interface))
- {
- case GI_INFO_TYPE_STRUCT:
- ret = seed_make_struct((priv->pointer + offset), interface);
- goto found;
- case GI_INFO_TYPE_UNION:
- ret = seed_make_union((priv->pointer + offset), interface);
- goto found;
- case GI_INFO_TYPE_BOXED:
- ret = seed_make_boxed((priv->pointer + offset), interface);
- goto found;
- default:
- g_base_info_unref(interface);
- }
- }
-
- g_free(cproperty_name);
- return JSValueMakeNull(context);
- }
-
- ret = seed_gi_argument_make_js(&field_value, field_type, exception);
- // Maybe need to release argument
- found:
+ ret = seed_field_get_value(priv->pointer, field, exception);
g_base_info_unref((GIBaseInfo *) field);
- if (field_type)
- g_base_info_unref((GIBaseInfo *) field_type);
g_free(cproperty_name);
return ret;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]