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 528436 - semi-implicit conversion to GValue
semi-implicit conversion to GValue
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: general
0.3.x
Other All
: High enhancement
: ---
Assigned To: Jürg Billeter
Vala maintainers
: 541949 (view as bug list)
Depends on:
Blocks: 530817
 
 
Reported: 2008-04-16 16:36 UTC by Marc-Andre Lureau
Modified: 2009-06-04 10:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch that implements the proposed behaviour (7.17 KB, patch)
2008-09-12 20:21 UTC, Andrea Del Signore
none Details | Review
Test program (709 bytes, text/plain)
2008-09-12 20:35 UTC, Andrea Del Signore
  Details
Updated patch (6.48 KB, patch)
2008-10-09 20:23 UTC, Jürg Billeter
none Details | Review
Updated patch svn rev. 1906 (6.51 KB, patch)
2008-10-24 20:03 UTC, Andrea Del Signore
needs-work Details | Review

Description Marc-Andre Lureau 2008-04-16 16:36:38 UTC
It would be really nice to be able to do:

Value v = "test";

<@juergbi> elmarco: some shortcut would make sense, although maybe not completely implicit

var v = Value("test"); ?
Comment 1 Jürg Billeter 2008-05-07 21:08:07 UTC
Maybe we should still add full support for implicit and explicit conversion operators to Vala and use that functionality to implement implicit conversion from various types to GLib.Value and explicit conversion from GLib.Value to various types. This would add support for the following statements:

    Value v = "test";

    string s = (string) v;
Comment 2 Marc-Andre Lureau 2008-05-07 21:13:36 UTC
looks like an excellent proposal :)
Comment 3 Étienne Bersac 2008-05-08 12:16:05 UTC
Would be very nice to have it soon. I need that in GNOME Scan.

Étienne.
Comment 4 Jürg Billeter 2008-07-08 08:50:02 UTC
*** Bug 541949 has been marked as a duplicate of this bug. ***
Comment 5 Andrea Del Signore 2008-09-12 20:21:31 UTC
Created attachment 118617 [details] [review]
Patch that implements the proposed behaviour

This patch implements the "semi-implicit" casts as proposed by Jürg.

I haven't implemented it in initializers (yet).
Comment 6 Andrea Del Signore 2008-09-12 20:35:01 UTC
Created attachment 118620 [details]
Test program

Simple test program. To Compile

valac --save-temps test-1.vala
Comment 7 Jürg Billeter 2008-10-09 20:23:00 UTC
Created attachment 120307 [details] [review]
Updated patch

Thanks for the patch, it's essentially working and I've updated it to apply to trunk. However, the VALA_VALUE_INIT macro seems like a workaround. g_value_unset should automatically be called as a destroy function of GValue.
Comment 8 Andrea Del Signore 2008-10-24 20:03:01 UTC
Created attachment 121307 [details] [review]
Updated patch svn rev. 1906

Sorry for the late response, but I wasn't in the CC list so I missed your comments.

Here is an update to the patch so it can be cleanly applied to svn rev. 1906.

I will try to look on the VALUE_INIT issue in the next days, but I can't promise anything since I'm quite busy at the moment.
Comment 9 Bug flys 2008-10-25 13:29:55 UTC
How about the GConfValue? Which is more commonly used with GClient.get()/set().  
Comment 10 Jürg Billeter 2009-06-04 09:38:19 UTC
commit aee7341479d83a2f9ed0101c5c7bedca55832e1c
Author: Jürg Billeter <j@bitron.ch>
Date:   Thu Jun 4 11:24:27 2009 +0200

    GValue: Add support for implicit and explicit casts
    
    Based on patch by Andrea Del Signore, fixes bug 528436.
Comment 11 Marc-Andre Lureau 2009-06-04 10:21:03 UTC
awesome