GNOME Bugzilla – Bug 776835
[Genie] Allow enums to have methods
Last modified: 2018-05-22 15:42:50 UTC
The following Vala code works fine: void main () { print (Test.ONE.pretty_print () + "\n"); } enum Test { ONE; public string pretty_print () { return @"The value of this enum is $this"; } } The following Genie code: init print( Test.ONE.pretty_print() ) enum Test ONE def pretty_print():string return @"The value of this enum is $this" produces the error: test.gs:5.3-5.5: error: syntax error, expected end of line but got `def' with previous `tab indent' def pretty_print():string --- Vala allows a function to be defined after the enum values are listed. If this was to be implemented in Genie then a similar scheme is probably best. It would mean adding some additional code to the end of parse_enum_declaration () n the Genie parser. Vala uses the semi-colon to denotes the end of the list of values, but it would be more Genie like to use a new block, i.e. an indent. One test would be to convert https://git.gnome.org/browse/vala/tree/vala/valagenietokentype.vala to Genie, although this couldn't go in mainline because it would only build with the most recent versions of Vala.
Created attachment 351266 [details] [review] Patch for this This patch on master branch: https://github.com/vlad1777d/Genie/tree/enums-methods
Newer Python script for launching tests (updated to run under Python 3.4): https://github.com/vlad1777d/Genie/blob/genie-improved/run_genie_tests.py
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/vala/issues/569.