seed r264 - in trunk: examples libseed tests
- From: racarr svn gnome org
- To: svn-commits-list gnome org
- Subject: seed r264 - in trunk: examples libseed tests
- Date: Thu, 13 Nov 2008 08:06:24 +0000 (UTC)
Author: racarr
Date: Thu Nov 13 08:06:23 2008
New Revision: 264
URL: http://svn.gnome.org/viewvc/seed?rev=264&view=rev
Log:
Release in args.
Removed:
trunk/tests/reference-count-new.js
Modified:
trunk/examples/quine.js
trunk/libseed/seed-engine.c
trunk/libseed/seed-types.c
trunk/libseed/seed-types.h
trunk/tests/Makefile.am
Modified: trunk/examples/quine.js
==============================================================================
--- trunk/examples/quine.js (original)
+++ trunk/examples/quine.js Thu Nov 13 08:06:23 2008
@@ -4,4 +4,4 @@
file = Gio.file_new_for_path(Seed.argv[1])
input = file.read();
//get_contents is an addition in extensions/Gio.js to make life easier.
-Seed.print(input.get_contents());
\ No newline at end of file
+Seed.print(input.get_contents());
Modified: trunk/libseed/seed-engine.c
==============================================================================
--- trunk/libseed/seed-engine.c (original)
+++ trunk/libseed/seed-engine.c Thu Nov 13 08:06:23 2008
@@ -292,8 +292,15 @@
if (g_type_info_get_tag(type_info) == GI_TYPE_TAG_VOID)
retval_ref = JSValueMakeNull(eng->context);
else
+ {
retval_ref =
seed_gi_argument_make_js(&retval, type_info, exception);
+
+ seed_gi_release_arg(g_callable_info_get_caller_owns(
+ (GICallableInfo *)info),
+ type_info,
+ &retval);
+ }
g_base_info_unref((GIBaseInfo *) type_info);
}
else
@@ -306,34 +313,38 @@
return JSValueMakeNull(eng->context);
}
-
- if (n_out_args != 0)
+ for (i = 0; (i < n_args); i++)
{
- for (i = 0; (i < n_args); i++)
- {
- JSValueRef jsout_val;
- arg_info = g_callable_info_get_arg((GICallableInfo *) info, i);
- dir = g_arg_info_get_direction(arg_info);
- if (dir == GI_DIRECTION_IN)
- {
- g_base_info_unref((GIBaseInfo *) arg_info);
- continue;
- }
- type_info = g_arg_info_get_type(arg_info);
- jsout_val = seed_gi_argument_make_js(&out_values[i],
- type_info, exception);
- if (!JSValueIsNull(eng->context, arguments[i]) &&
- JSValueIsObject(eng->context, arguments[i]))
- {
- seed_object_set_property((JSObjectRef) arguments[i],
- "value", jsout_val);
- }
-
- g_base_info_unref((GIBaseInfo *) arg_info);
+ JSValueRef jsout_val;
+ arg_info = g_callable_info_get_arg((GICallableInfo *) info, i);
+ dir = g_arg_info_get_direction(arg_info);
+ type_info = g_arg_info_get_type(arg_info);
+
+ if (dir == GI_DIRECTION_IN)
+ {
+ seed_gi_release_in_arg(
+ g_arg_info_get_ownership_transfer(arg_info),
+ type_info,
+ &in_args[i+(instance_method ? 1 : 0)]);
+
g_base_info_unref((GIBaseInfo *) type_info);
+ g_base_info_unref((GIBaseInfo *) arg_info);
+ continue;
}
+ jsout_val = seed_gi_argument_make_js(&out_values[i],
+ type_info, exception);
+ if (!JSValueIsNull(eng->context, arguments[i]) &&
+ JSValueIsObject(eng->context, arguments[i]))
+ {
+ seed_object_set_property((JSObjectRef) arguments[i],
+ "value", jsout_val);
+ }
+
+ g_base_info_unref((GIBaseInfo *) arg_info);
+ g_base_info_unref((GIBaseInfo *) type_info);
}
+
g_free(in_args);
g_free(out_args);
g_free(out_values);
@@ -510,7 +521,7 @@
g_object_set_data_full (gobject, "js-ref", NULL, NULL);
g_object_remove_toggle_ref(gobject, seed_toggle_ref, 0);
- g_object_unref(gobject);
+ g_object_run_dispose(gobject);
}
static void seed_gobject_initialize(JSContextRef ctx, JSObjectRef object)
Modified: trunk/libseed/seed-types.c
==============================================================================
--- trunk/libseed/seed-types.c (original)
+++ trunk/libseed/seed-types.c Thu Nov 13 08:06:23 2008
@@ -177,6 +177,90 @@
return 0;
}
+static gboolean seed_release_arg(GITransfer transfer,
+ GITypeInfo * type_info,
+ GITypeTag type_tag,
+ GArgument * arg)
+{
+ GType gtype;
+
+ switch (type_tag)
+ {
+ case GI_TYPE_TAG_UTF8:
+ g_free(arg->v_string);
+ break;
+ case GI_TYPE_TAG_INTERFACE:
+ {
+ if (arg->v_pointer)
+ {
+ GIBaseInfo * interface_info;
+ GType interface_type;
+
+ interface_info = g_type_info_get_interface(type_info);
+
+ gtype =
+ g_registered_type_info_get_g_type(
+ (GIRegisteredTypeInfo*)interface_info);
+
+// TODO: Need to fix a broken reference somewhere for this not to break things.
+// Possibly related to subclassing and the two phase destruction process.
+// if (g_type_is_a(gtype, G_TYPE_OBJECT)
+// || g_type_is_a(gtype, G_TYPE_INTERFACE))
+// g_object_unref(G_OBJECT(arg->v_pointer));
+
+ g_base_info_unref(interface_info);
+ }
+ break;
+ }
+ default:
+ break;
+
+ }
+
+ return TRUE;
+}
+
+gboolean seed_gi_release_arg(GITransfer transfer,
+ GITypeInfo *type_info,
+ GArgument * arg)
+{
+ GITypeTag type_tag;
+
+ if (transfer == GI_TRANSFER_NOTHING)
+ return TRUE;
+
+ type_tag = g_type_info_get_tag ((GITypeInfo *) type_info);
+
+ return seed_release_arg(transfer,
+ type_info,
+ type_tag,
+ arg);
+}
+
+gboolean seed_gi_release_in_arg(GITransfer transfer,
+ GITypeInfo * type_info,
+ GArgument * arg)
+{
+ GITypeTag type_tag;
+
+ if (transfer == GI_TRANSFER_EVERYTHING)
+ return;
+
+ type_tag = g_type_info_get_tag ((GITypeInfo *) type_info);
+
+ switch (type_tag)
+ {
+ case GI_TYPE_TAG_UTF8:
+ return seed_release_arg(GI_TRANSFER_EVERYTHING,
+ type_info,
+ type_tag,
+ arg);
+ }
+
+ return TRUE;
+}
+
+
gboolean
seed_gi_make_argument(JSValueRef value,
GITypeInfo * type_info, GArgument * arg,
@@ -1054,7 +1138,7 @@
{
JSStringRef jsstr = 0;
JSValueRef func, str;
- gchar *buf;
+ gchar *buf = 0;
gint length;
if (val == NULL)
@@ -1084,8 +1168,11 @@
jsstr = JSValueToStringCopy(eng->context, val, NULL);
length = JSStringGetMaximumUTF8CStringSize(jsstr);
- buf = g_malloc(length * sizeof(gchar));
- JSStringGetUTF8CString(jsstr, buf, length);
+ if (length > 0)
+ {
+ buf = g_malloc(length * sizeof(gchar));
+ JSStringGetUTF8CString(jsstr, buf, length);
+ }
if (jsstr)
JSStringRelease(jsstr);
}
Modified: trunk/libseed/seed-types.h
==============================================================================
--- trunk/libseed/seed-types.h (original)
+++ trunk/libseed/seed-types.h Thu Nov 13 08:06:23 2008
@@ -39,6 +39,14 @@
GITypeInfo * type_info,
JSValueRef * exception);
+gboolean seed_gi_release_arg(GITransfer transfer,
+ GITypeInfo * type_info,
+ GArgument * arg);
+
+gboolean seed_gi_release_in_arg(GITransfer transfer,
+ GITypeInfo * type_info,
+ GArgument * arg);
+
GType seed_gi_type_to_gtype(GITypeInfo * type_info, GITypeTag tag);
gboolean seed_value_to_boolean(JSValueRef val, JSValueRef * exception);
Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am (original)
+++ trunk/tests/Makefile.am Thu Nov 13 08:06:23 2008
@@ -3,8 +3,7 @@
compare.js \
constructor-args.js \
signal-this.js \
- reference-count-new.js \
- gtype-typerror.js \
+ type-typerror.js \
gtype-signal.js \
signal-userdata.js \
gtype-signal-exception.js \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]