Enums, bitfields and wl_arrays
Nils Chr. Brause
nilschrbrause at gmail.com
Tue Oct 13 07:35:50 PDT 2015
Hi,
On Mon, Oct 12, 2015 at 11:08 AM, Pekka Paalanen <ppaalanen at gmail.com> wrote:
> On Mon, 12 Oct 2015 10:41:22 +0200
> Erik De Rijcke <derijcke.erik at gmail.com> wrote:
>
>> Adding enum members is backward compatible for Java. If you compile against
>> an enum with 2 members, and later on a new member is added, you can simply
>> use the new version of the enum.
>>
>> Important however is that the order of old members do not change when new
>> members are added.
>
> This is important. I don't think anyone has ever mentioned anything
> like this before.
>
> We certainly have not expected the order to matter inside an <enum>
> tag, since we require the value to be explicitly given. Not when you
> are coming from C, anyway.
In C++ the order doesn't matter either, since each entry has a defined value.
I wonder why this is different in Java?
> Apparently we would need to start enforcing the rule:
>
> "Only ever add new enum value to the end of a closed enum."
>
> Yeah, now we also need the concept of open and closed enums, because
> for something like used in xdg-shell for window states, the whole enum
> concept doesn't work e.g. in Java (I hear).
A hint whether an enum is open or closed would probably be useful for
languages like Java. The binding developers need to come up with a solution
for their particular binding if they want to use type safe enumerations.
> Should we be adding all these to the Wayland XML language or not?
As far as I'm concerned, everything that can make the life of a language
binding developer easier and doesn't change the C API should be included
in the Wayland XML file.
> Thanks,
> pq
Cheers,
Nils
More information about the wayland-devel
mailing list