After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 623173 - Allow a return value in peas_method_apply_valist
Allow a return value in peas_method_apply_valist
Status: RESOLVED FIXED
Product: libpeas
Classification: Platform
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: libpeas-maint
libpeas-maint
Depends on:
Blocks:
 
 
Reported: 2010-06-29 22:25 UTC by Garrett Regier
Modified: 2010-06-30 20:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Allow a return value in peas_method_apply_valist (8.04 KB, patch)
2010-06-29 22:27 UTC, Garrett Regier
none Details | Review
Allow a return value in peas_method_apply_valist - splinter please load this one (6.70 KB, patch)
2010-06-29 22:40 UTC, Garrett Regier
needs-work Details | Review
Allow a return value in peas_method_apply_valist v3 (6.77 KB, patch)
2010-06-29 23:16 UTC, Garrett Regier
none Details | Review
Handle return values in peas_method_apply_valist() (6.84 KB, patch)
2010-06-30 18:58 UTC, Steve Frécinaux
committed Details | Review
[PeasUIConfigurable] Make the dialog the return value. (4.62 KB, patch)
2010-06-30 18:58 UTC, Steve Frécinaux
committed Details | Review

Description Garrett Regier 2010-06-29 22:25:24 UTC
Right now you cannot specify a return value for peas_method_apply_valist which means you must use an out param which is annoying.
Comment 1 Garrett Regier 2010-06-29 22:27:47 UTC
Created attachment 164929 [details] [review]
Allow a return value in peas_method_apply_valist

I know this works for returning a gboolean and an object.
Comment 2 Garrett Regier 2010-06-29 22:40:59 UTC
Created attachment 164931 [details] [review]
Allow a return value in peas_method_apply_valist - splinter please load this one

Attaching another to hopefully get splinter to load if for review.

Also without the quoted that was meant for another patch.
Comment 3 Steve Frécinaux 2010-06-29 23:00:50 UTC
Comment on attachment 164931 [details] [review]
Allow a return value in peas_method_apply_valist - splinter please load this one

>+  /* Notes: According to GCC 4.4,
>+   *  - int8, uint8, int16, uint16, short and ushort are promoted to int when passed through '...'
>+   *  - float is promoted to double when passed through '...'
>+   */
>+   /* The above shouldnt matter so I think we can unpromote the below */

I think you can remove these comments as what gets passed through '...' is just a pointer, not the actual type, unlike for (in) arguments.
Hence you should also use the "real" types in the switch, not the promoted ones.

>+      *(gboolean *) in_retval = out_retval->v_boolean;

Could you use *((gboolean *) int_retval) = out_retval->v_boolean instead? (notice the parens) I think it's more readable at the end, operators priority is not always obvious.

>+
>+static gboolean
> read_next_argument (GArgument  *cur_arg,

What's the reason for making this become a gboolean?

> 
>+  retval_info = g_callable_info_get_return_type (func_info);
>+  retval_is_void = g_type_info_get_tag (retval_info) == GI_TYPE_TAG_VOID;
>+
>+  if (!retval_is_void)
>+    {
>+      in_retval = va_arg (args, gpointer);
>+    }

I think the return value argument should be put at the end of the peas_method_apply() arg list, as it is usually done for (out) args.
Comment 4 Steve Frécinaux 2010-06-29 23:03:51 UTC
> I think the return value argument should be put at the end of the
> peas_method_apply() arg list, as it is usually done for (out) args.

The above statement means that for functions with a single (out) param, the apply() call should be the same if the param is the return value or if the param is an (out) value of the function.
Comment 5 Garrett Regier 2010-06-29 23:16:28 UTC
Created attachment 164936 [details] [review]
Allow a return value in peas_method_apply_valist v3

(In reply to comment #3)
> (From update of attachment 164931 [details] [review])
> >+  /* Notes: According to GCC 4.4,
> >+   *  - int8, uint8, int16, uint16, short and ushort are promoted to int when passed through '...'
> >+   *  - float is promoted to double when passed through '...'
> >+   */
> >+   /* The above shouldnt matter so I think we can unpromote the below */
> 
> I think you can remove these comments as what gets passed through '...' is just
> a pointer, not the actual type, unlike for (in) arguments.
> Hence you should also use the "real" types in the switch, not the promoted
> ones.

Done

> >+      *(gboolean *) in_retval = out_retval->v_boolean;
> 
> Could you use *((gboolean *) int_retval) = out_retval->v_boolean instead?
> (notice the parens) I think it's more readable at the end, operators priority
> is not always obvious.

Done

> >+
> >+static gboolean
> > read_next_argument (GArgument  *cur_arg,
> 
> What's the reason for making this become a gboolean?

Extra bit of safety in-case a new tag is added.

> > 
> >+  retval_info = g_callable_info_get_return_type (func_info);
> >+  retval_is_void = g_type_info_get_tag (retval_info) == GI_TYPE_TAG_VOID;
> >+
> >+  if (!retval_is_void)
> >+    {
> >+      in_retval = va_arg (args, gpointer);
> >+    }
> 
> I think the return value argument should be put at the end of the
> peas_method_apply() arg list, as it is usually done for (out) args.

Done
Comment 6 Steve Frécinaux 2010-06-30 18:58:46 UTC
Created attachment 164986 [details] [review]
Handle return values in peas_method_apply_valist()
Comment 7 Steve Frécinaux 2010-06-30 18:58:58 UTC
Created attachment 164987 [details] [review]
[PeasUIConfigurable] Make the dialog the return value.

It was previously an out parameter, but we recently gained the ability
to use return values of extension interface methods.
Comment 8 Steve Frécinaux 2010-06-30 20:09:26 UTC
Attachment 164986 [details] pushed as 72b5eab - Handle return values in peas_method_apply_valist()
Attachment 164987 [details] pushed as 3892bd5 - [PeasUIConfigurable] Make the dialog the return value.