Integer Enum

91 views
Skip to first unread message

Christopher Johnson

unread,
Jun 15, 2014, 5:25:11 PM6/15/14
to haxe...@googlegroups.com
Is there any way to have an enum in Haxe that is just an aliased integer type with associated constant values?  Like the way enums work in C++?

Gama11

unread,
Jun 15, 2014, 5:50:52 PM6/15/14
to haxe...@googlegroups.com
Yes, you can use an abstract enum for that.

Axel Huizinga

unread,
Jun 15, 2014, 6:31:59 PM6/15/14
to haxe...@googlegroups.com

Am 15.06.2014 23:50, schrieb Gama11:
Yes, you can use an abstract enum for that.
Is there any way to get a list of all constants names in this context?

On Sunday, June 15, 2014 11:25:11 PM UTC+2, Christopher Johnson wrote:
Is there any way to have an enum in Haxe that is just an aliased integer type with associated constant values?  Like the way enums work in C++?
--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.


Juraj Kirchheim

unread,
Jun 15, 2014, 6:55:54 PM6/15/14
to haxe...@googlegroups.com
You can definitely use a macro for that ;)

Dan Korostelev

unread,
Jun 16, 2014, 2:22:01 AM6/16/14
to haxe...@googlegroups.com
I made such macro as an example for a friend of mine https://gist.github.com/nadako/bea417991fb0a9f21767
It probably makes more sense to have a @:build-macro that adds a static field or a method returning all values to the abstract itself.

понедельник, 16 июня 2014 г., 2:55:54 UTC+4 пользователь back2dos написал:

Axel Huizinga

unread,
Jun 16, 2014, 3:12:21 AM6/16/14
to haxe...@googlegroups.com

Am 16.06.2014 08:22, schrieb Dan Korostelev:
I made such macro as an example for a friend of mine https://gist.github.com/nadako/bea417991fb0a9f21767
nice - that saved me asking for an example since I still need a basic macro training
now - how would I get the list of var names - i.e. [A,B,C] ?

Valentin Lemiere

unread,
Jun 17, 2014, 4:17:50 AM6/17/14
to haxe...@googlegroups.com
On that example I tried to do
untyped IntEnum.VALUE_ONE + 1
but the compiler still complain.

Is there a way to do such a thing?
Am I using the untyped keywork correctly?

Valentin Lemiere

unread,
Jun 18, 2014, 4:25:52 AM6/18/14
to haxe...@googlegroups.com
Figured it out,
needed to simply overload the operator + in the abstract.
Reply all
Reply to author
Forward
0 new messages