diff options
author | Andrew Shadura <andrew.shadura@collabora.co.uk> | 2016-09-20 10:59:26 +0200 |
---|---|---|
committer | Andrew Shadura <andrew.shadura@collabora.co.uk> | 2016-09-20 10:59:26 +0200 |
commit | 3eae3d5d283d014bc2afbb0f2e649fbb45fedb32 (patch) | |
tree | 8a492fede97e2b61eb71594ddcc73446125b4f74 | |
parent | bca9ac980abb342f4575bc1780800ca00c169933 (diff) |
Imported Upstream version 4.0.0+20160607+9e45c19
-rw-r--r-- | ChangeLog | 49 | ||||
-rw-r--r-- | Makefile.in | 4 | ||||
-rw-r--r-- | libseed/seed-engine.c | 80 | ||||
-rw-r--r-- | libseed/seed-types.c | 1 |
4 files changed, 100 insertions, 34 deletions
@@ -1,6 +1,45 @@ # Generated by Makefile. Do not edit. -commit 3aaf5cb4c22a92137c725cdd5d27e788961d6acc +commit 9e45c19695f40a4bfebdff584e7952dfb169fa5d +Author: Danilo Cesar Lemes de Paula <danilo.cesar@collabora.co.uk> +Date: Tue Jun 7 10:54:47 2016 -0300 + + Add missing handler + + This fix a crash where a g_assert_not_reached() was called. + + libseed/seed-types.c | 1 + + 1 file changed, 1 insertion(+) + +commit eb749b146d81c26550999c3f1206a33888669ce7 +Author: Danilo Cesar Lemes de Paula <danilo.cesar@collabora.co.uk> +Date: Tue Jun 7 10:52:21 2016 -0300 + + Void function with one OUT arg should use arg as return value + + A void method with only one OUT argument should return this argument + itself. The old logic returns an array with only one index, which is + weird and not compatible with the gjs approach. + + libseed/seed-engine.c | 19 +++++++++++++++---- + 1 file changed, 15 insertions(+), 4 deletions(-) + +commit edcc73307f2a519fa6ddeb31fbfda40f5ae0771f +Author: Danilo Cesar Lemes de Paula <danilo.cesar@collabora.co.uk> +Date: Mon Jun 6 18:41:23 2016 -0300 + + Return objects as array starting from index zero + + When a method returns void but has OUT arguments, seed would return + an object similar as an Array, but the starting index is be 1 instead + of zero. + + This behavior is not correct, the starting index should always be zero. + + libseed/seed-engine.c | 29 ++++++++++++++++++++--------- + 1 file changed, 20 insertions(+), 9 deletions(-) + +commit 9e1266222b4e91fb115ed9e4c3dad7c8dfb2c129 Author: Danilo Cesar Lemes de Paula <danilo.cesar@collabora.co.uk> Date: Thu May 26 15:55:05 2016 -0300 @@ -9,7 +48,7 @@ Date: Thu May 26 15:55:05 2016 -0300 configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -commit c029206f7fbc4f3fe41a7095502461503e544713 +commit 6af8554e61b1c16aa3e2fe0c1049303295a55086 Author: Danilo Cesar Lemes de Paula <danilo.cesar@collabora.co.uk> Date: Thu May 26 15:54:45 2016 -0300 @@ -18,7 +57,7 @@ Date: Thu May 26 15:54:45 2016 -0300 configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -commit 00d0e371eeaf4fbebfd1820d31c8b099fd0d3799 +commit 4d859dc61590a4d5b3991ceee4b9ff279f1768a4 Author: Danilo Cesar Lemes de Paula <danilo.cesar@collabora.co.uk> Date: Wed May 25 22:24:57 2016 -0300 @@ -28,8 +67,8 @@ Date: Wed May 25 22:24:57 2016 -0300 array. This commit makes it work for both cases (after and before). - libseed/seed-engine.c | 100 ++++++++++++++++++++++++++++++++++++-------------- - 1 file changed, 73 insertions(+), 27 deletions(-) + libseed/seed-engine.c | 104 +++++++++++++++++++++++++++++++++++++------------- + 1 file changed, 77 insertions(+), 27 deletions(-) commit 2d441004af6d556d79713ecd1dea3ea2fc64ea91 Author: Danilo Cesar Lemes de Paula <danilo.cesar@collabora.co.uk> diff --git a/Makefile.in b/Makefile.in index 1120098..48a214d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -197,8 +197,8 @@ CSCOPE = cscope DIST_SUBDIRS = $(SUBDIRS) am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/config.h.in \ $(srcdir)/seed.pc.in AUTHORS COPYING ChangeLog INSTALL NEWS \ - README compile config.guess config.sub depcomp install-sh \ - ltmain.sh missing + README compile config.guess config.sub install-sh ltmain.sh \ + missing DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) diff --git a/libseed/seed-engine.c b/libseed/seed-engine.c index 7636cbb..1651789 100644 --- a/libseed/seed-engine.c +++ b/libseed/seed-engine.c @@ -444,14 +444,17 @@ seed_gobject_init_method_invoked(JSContextRef ctx, } // Pre-process the arguments list to find which arguments needs to be skipped. -gint* _process_skipped_arguments(const JSValueRef arguments[], GIBaseInfo *info, - gint *out_skipped_args) +gint* +_process_skipped_arguments(const JSValueRef arguments[], + GIBaseInfo* info, + gint* out_skipped_args) { int n_args = g_callable_info_get_n_args((GICallableInfo*) info); - int skipped_args = 0;; + int skipped_args = 0; + ; int i; - gint *skip = g_new0(gint, n_args + 1); + gint* skip = g_new0(gint, n_args + 1); GITypeInfo* type_info = NULL; GIArgInfo* arg_info = NULL; @@ -461,7 +464,6 @@ gint* _process_skipped_arguments(const JSValueRef arguments[], GIBaseInfo *info, type_info = g_arg_info_get_type(arg_info); GIDirection dir = g_arg_info_get_direction(arg_info); - GITypeTag type_tag = g_type_info_get_tag(type_info); gint array_len_pos = g_type_info_get_array_length(type_info); @@ -483,6 +485,17 @@ gint* _process_skipped_arguments(const JSValueRef arguments[], GIBaseInfo *info, return skip; } +void +_add_jsvalue_in_array(JSContextRef ctx, + JSObjectRef dest, + gint pos, + JSValueRef obj) +{ + gchar* int_str = g_strdup_printf("%d", pos); + seed_object_set_property(ctx, (JSObjectRef) dest, int_str, obj); + g_free(int_str); +} + static JSValueRef seed_gobject_method_invoked(JSContextRef ctx, JSObjectRef function, @@ -516,6 +529,8 @@ seed_gobject_method_invoked(JSContextRef ctx, GError* error = 0; gint length_arg_pos = 0; guint64 array_len = 0; + gint array_return_value_count = 0; + gboolean return_only_one_out = false; info = JSObjectGetPrivate(function); @@ -540,13 +555,16 @@ seed_gobject_method_invoked(JSContextRef ctx, in_args[n_in_args++].v_pointer = object; int out_skipped_args = 0; - skipped_args = _process_skipped_arguments(arguments, info, &out_skipped_args); + skipped_args + = _process_skipped_arguments(arguments, info, &out_skipped_args); + + SEED_NOTE(INVOCATION, "Calling seed_object_method_invoked for function %s", + g_base_info_get_name(info)); // now loop through all the other args. for (i = 0, j = 0; (i < (n_args)); i++) { if (skipped_args[i]) { - SEED_NOTE(INVOCATION, - "Skipping parameter %d", i); + SEED_NOTE(INVOCATION, "Skipping parameter %d", i); n_in_args++; j++; continue; @@ -615,7 +633,7 @@ seed_gobject_method_invoked(JSContextRef ctx, if (!g_arg_info_may_be_null(arg_info)) { gboolean is_null - = (!arguments[i-j] || JSValueIsNull(ctx, arguments[i-j])); + = (!arguments[i - j] || JSValueIsNull(ctx, arguments[i - j])); if (!is_null && (g_type_info_get_tag(type_info) == GI_TYPE_TAG_INTERFACE)) { @@ -624,7 +642,8 @@ seed_gobject_method_invoked(JSContextRef ctx, type_info); GIInfoType interface_type = g_base_info_get_type(interface); - gboolean arg_is_object = JSValueIsObject(ctx, arguments[i-j]); + gboolean arg_is_object + = JSValueIsObject(ctx, arguments[i - j]); gboolean is_gvalue = (interface_type == GI_INFO_TYPE_STRUCT) @@ -646,7 +665,8 @@ seed_gobject_method_invoked(JSContextRef ctx, arrays. */ if (!is_gvalue && is_struct_or_union && arg_is_object - && (seed_pointer_get_pointer(ctx, arguments[i-j]) == 0)) { + && (seed_pointer_get_pointer(ctx, arguments[i - j]) + == 0)) { is_null = TRUE; } g_base_info_unref(interface); @@ -677,13 +697,13 @@ seed_gobject_method_invoked(JSContextRef ctx, guint out_length = 0; if (!seed_value_to_gi_argument_with_out_length( - ctx, arguments[i-j], type_info, transfer, + ctx, arguments[i - j], type_info, transfer, &in_args[n_in_args++], &out_length, exception)) { seed_make_exception(ctx, exception, "ArgumentError", "Unable to make argument %d for" " function: %s. \n", - i + 1, g_base_info_get_name( - (GIBaseInfo*) info)); + i + 1, + g_base_info_get_name((GIBaseInfo*) info)); retval_ref = JSValueMakeNull(ctx); goto invoke_return; @@ -769,11 +789,17 @@ seed_gobject_method_invoked(JSContextRef ctx, } if (tag == GI_TYPE_TAG_VOID) { - // if we have no out args - returns undefined - // otherwise we return an object, and put the return values into that - // along with supporting the old object.value way + // * if we have no out args - returns undefined + // * if we have *one* out_arg but no return type, + // do nothing here and return the OUT as return later. + // * otherwise we return an object, and put the return values into that + // along with supporting the old object.value way if (n_out_args < 1) retval_ref = JSValueMakeUndefined(ctx); + else if (n_out_args == 1){ + return_only_one_out = true; + use_return_as_out = 1; + } else { retval_ref = JSObjectMake(ctx, NULL, NULL); use_return_as_out = 1; @@ -820,9 +846,10 @@ seed_gobject_method_invoked(JSContextRef ctx, JSValueRef jsout_val = seed_value_from_gi_argument_full(ctx, &retval, type_info, exception, array_len, tag); + if (use_return_as_out && force_return_array) { - seed_object_set_property(ctx, (JSObjectRef) retval_ref, "0", - jsout_val); + _add_jsvalue_in_array(ctx, (JSObjectRef) retval_ref, + array_return_value_count++, jsout_val); } else retval_ref = jsout_val; @@ -841,10 +868,7 @@ seed_gobject_method_invoked(JSContextRef ctx, // etc.. in_args_pos = out_args_pos = 0; - gint array_return_count = 1; for (i = 0; (i < n_args); i++) { - // We start array_return_count as 1 because the position 0 is - // the real returned value. JSValueRef jsout_val; arg_info = g_callable_info_get_arg((GICallableInfo*) info, i); dir = g_arg_info_get_direction(arg_info); @@ -968,11 +992,11 @@ seed_gobject_method_invoked(JSContextRef ctx, // if we add it to the return argument and/or the first out arguement if (use_return_as_out) { - if (force_return_array) { - gchar* int_str = g_strdup_printf("%d", array_return_count++); - seed_object_set_property(ctx, (JSObjectRef) retval_ref, int_str, - jsout_val); - g_free(int_str); + if (return_only_one_out) { + retval_ref = jsout_val; + } else if (force_return_array) { + _add_jsvalue_in_array(ctx, (JSObjectRef) retval_ref, + array_return_value_count++, jsout_val); } else { seed_object_set_property(ctx, (JSObjectRef) retval_ref, g_base_info_get_name( @@ -998,6 +1022,8 @@ seed_gobject_method_invoked(JSContextRef ctx, } invoke_return: + SEED_NOTE(INVOCATION, "END seed_object_method_invoked for function %s", + g_base_info_get_name(info)); // clean up everything.. for (i = 0; (i < (n_args)); i++) diff --git a/libseed/seed-types.c b/libseed/seed-types.c index 3330419..51208e0 100644 --- a/libseed/seed-types.c +++ b/libseed/seed-types.c @@ -147,6 +147,7 @@ seed_release_arg(GITransfer transfer, case GI_TYPE_TAG_GTYPE: case GI_TYPE_TAG_FLOAT: case GI_TYPE_TAG_UINT8: + case GI_TYPE_TAG_INT32: case GI_TYPE_TAG_UINT32: g_free(arg->v_pointer); break; |