[PATCH wayland] Add "enum" attribute to "arg" elements
Jeroen Bollen
jbinero at gmail.com
Thu Apr 23 12:15:08 PDT 2015
> (yes the language binding could prevent this, but programmers writing
> direct Wayland api are already wading into dangerous waters and can
> probably be trusted to do this correctly. So for now I don't think there
> is any need for a strict control).
I do not quite agree with this. Yes, they should know they are wading into
dangerous waters, but any error that can be prevented, should be. It also
helps of course, for features like code completion, although as I am
writing Rust bindings, that doesn't apply to me.
> Maybe it could be added, ie you can make global enumerations as well as
> local enumerations. Local ones are still useful for the error values.
That would be a good solution, but maybe that's making the specification a
bit too complex? I would be in favour of moving everything to same
namespace as the interface, but of course, compatibility issues will arise
with exciting binding generators.
In any case, I think the specification should be as strict as possible,
because making it stricter is hard, but making it less strict is easy.
On Thu, 23 Apr 2015 at 20:59 Bill Spitzak <spitzak at gmail.com> wrote:
>
>
> On 04/23/2015 11:28 AM, Jeroen Bollen wrote:
> > > Using enum="interfacename.enumname" would probably work. The
> > > "interfacename." is optional if you are describing a method on the
> same
> > > interface. Another possibility is to just add
> interface="interfacename"
> > > to the argument along with enum="enumname".
> >
> > The second possibility wouldn't work for bitfields that take enums from
> > different interfaces.
>
> I didn't think that would be allowed. The bitmap arg can only or
> together a set of values from a single enumeration.
>
> > > An even more drastic approach would be to put all the values in the
> same
> > > namespace as interfaces, again renaming (or perhaps changing the
> values)
> > > as necessary. This would allow the programmer to write
> > > Widget.setAlignment(Left). It would also match how enums in C work.
> >
> > Putting enums next to interfaces, instead of inside of them, to me, also
> > seems like the best option. I don't think it'll get any support however,
> > as it isn't backwards compatible.
>
> Maybe it could be added, ie you can make global enumerations as well as
> local enumerations. Local ones are still useful for the error values.
> Some sort of aliasing could be used to migrate other local enumerations
> to global without breaking any existing code.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20150423/289297e2/attachment.html>
More information about the wayland-devel
mailing list