This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: enums
On 10/21/2010 10:12 AM, Jamison Hope wrote:
The attached *somewhat* works,
Thanks - looks like we're close! (I notice your macro doesn't support
option-pair... or OTHER-DEFS... but they should be easy enough to add.)
but Class#isEnum() returns false and
Class#getEnumConstants() returns null. There must be some special enum
marker in the bytecode, other than being a subclass of java.lang.Enum,
which the compiler needs to add?
You're right - there is an 'enum' flag on enum classes.
It is also set on the actual enum constants.
So a pure macro solution doesn't work.
I'm thinking we can extend the access class-property:
http://www.gnu.org/software/kawa/Defining-new-classes.html#General-class-properties
So the macro would generate:
(define-simple-class TYPE (java.lang.Enum) access: '(enum) ...
(E0 :: TYPE access: '(enum) allocation: 'static init: (TIME "E0" 0))
...)
Look at matchAccess1 in kawa/standard/object.java for hints
for what needs to be done. For example Declaration needs an
ENUM_ACCESS flag.
We need to check that an explicit access: specifier works, preferably
by making sure the expansion in object.java does the right thing if there
are multiple access: specifiers. (It quite possibly already does.)
--
--Per Bothner
per@bothner.com http://per.bothner.com/