GNOME Bugzilla – Bug 528436
semi-implicit conversion to GValue
Last modified: 2009-06-04 10:21:03 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"); ?
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;
looks like an excellent proposal :)
Would be very nice to have it soon. I need that in GNOME Scan. Étienne.
*** Bug 541949 has been marked as a duplicate of this bug. ***
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).
Created attachment 118620 [details] Test program Simple test program. To Compile valac --save-temps test-1.vala
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.
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.
How about the GConfValue? Which is more commonly used with GClient.get()/set().
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.
awesome