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 776835 - [Genie] Allow enums to have methods
[Genie] Allow enums to have methods
Status: RESOLVED OBSOLETE
Product: vala
Classification: Core
Component: Genie
unspecified
Other All
: Normal normal
: ---
Assigned To: Jamie McCracken
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2017-01-03 19:06 UTC by Al Thomas
Modified: 2018-05-22 15:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Patch for this (10.11 KB, patch)
2017-05-06 18:58 UTC, Vladislav
none Details | Review

Description Al Thomas 2017-01-03 19:06:23 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.
Comment 1 Vladislav 2017-05-06 18:58:55 UTC
Created attachment 351266 [details] [review]
Patch for this

This patch on master branch:
https://github.com/vlad1777d/Genie/tree/enums-methods
Comment 2 Vladislav 2017-05-06 21:49:37 UTC
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
Comment 3 GNOME Infrastructure Team 2018-05-22 15:42:50 UTC
-- 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.