[PATCH wayland] Add "enum" attribute to "arg" elements

Bill Spitzak spitzak at gmail.com
Wed Apr 22 11:36:24 PDT 2015


I think this looks like the correct patch.

Only correction is that I would put the enum right after the type="int" 
consistently. Some of your cases you put the summary between them.

On 04/19/2015 01:30 PM, Auke Booij wrote:
> On 19 April 2015 at 14:51, Jeroen Bollen <jbinero at gmail.com> wrote:
>> Hello,
>>
>> It seems like this discussion died off. Currently there is no way to tell,
>> from the Wayland XML specification whether an argument is a bitfield, or
>> whether the argument takes an enum and what enum this is.
>>
>> I am currently in the progress of writing a Wayland binding generator for
>> the Rust language. This language, like many others is strongly typed. To
>> make full usage of this type system, it would be beneficial to know from the
>> specification whether an argument is a bitfield, and what enum type it
>> takes.
>>
>> Surely there are more people who generate bindings to these strongly typed
>> languages. How have you fixed the issue? Are there patched versions
>> available, and maybe pending to be merged? I have looked around a bit, and
>> didn't find anything, but then again, I'm not familiar with Wayland
>> development. (This is the first time I use a mailing list!)
>
> Quite coincidentally, I was planning on writing a similar email quite
> soon, so I'll just go ahead and write what I wanted to say!
>
> I wrote Haskell bindings, and the same problem occurs there. I did not
> find a way to solve the problem, and it would be best if such an enum
> argument be added to the spec.
>
> I wrote the patch below. It introduces an "enum" attribute that allows
> message arguments to refer to the enum collection they're using (it is
> understood that this enum is part of the same interface). I also added
> a "bitfield" attribute to enums that indicates whether the enum values
> are to be OR'ed together, or to be used as-is: ie whether the enum
> values are actually enums or actually flag fields.
>
>
>
> This improvement to the protocol allows you to refer to the kind of
> enum you are expecting.
> It also introduces a distinction between enums that are bitfields, ie
> that can be OR'ed together.
> ---
>   protocol/wayland.dtd |  2 ++
>   protocol/wayland.xml | 32 ++++++++++++++++----------------
>   2 files changed, 18 insertions(+), 16 deletions(-)
>
> diff --git a/protocol/wayland.dtd b/protocol/wayland.dtd
> index b8b1573..3b67ca8 100644
> --- a/protocol/wayland.dtd
> +++ b/protocol/wayland.dtd
> @@ -14,6 +14,7 @@
>   <!ELEMENT enum (description?,entry*)>
>     <!ATTLIST enum name CDATA #REQUIRED>
>     <!ATTLIST enum since CDATA #IMPLIED>
> +  <!ATTLIST enum bitfield CDATA #IMPLIED>
>   <!ELEMENT entry (description?)>
>     <!ATTLIST entry name CDATA #REQUIRED>
>     <!ATTLIST entry value CDATA #REQUIRED>
> @@ -25,5 +26,6 @@
>     <!ATTLIST arg summary CDATA #IMPLIED>
>     <!ATTLIST arg interface CDATA #IMPLIED>
>     <!ATTLIST arg allow-null CDATA #IMPLIED>
> +  <!ATTLIST arg enum CDATA #IMPLIED>
>   <!ELEMENT description (#PCDATA)>
>     <!ATTLIST description summary CDATA #REQUIRED>
> diff --git a/protocol/wayland.xml b/protocol/wayland.xml
> index f52677f..2b9efa1 100644
> --- a/protocol/wayland.xml
> +++ b/protocol/wayland.xml
> @@ -367,7 +367,7 @@
>    can be used for buffers. Known formats include
>    argb8888 and xrgb8888.
>         </description>
> -      <arg name="format" type="uint"/>
> +      <arg name="format" type="uint" enum="format"/>
>       </event>
>     </interface>
>
> @@ -774,7 +774,7 @@
>         </description>
>         <arg name="seat" type="object" interface="wl_seat" summary="the
> wl_seat whose pointer is used"/>
>         <arg name="serial" type="uint" summary="serial of the implicit
> grab on the pointer"/>
> -      <arg name="edges" type="uint" summary="which edge or corner is
> being dragged"/>
> +      <arg name="edges" type="uint" summary="which edge or corner is
> being dragged" enum="resize"/>
>       </request>
>
>       <request name="set_toplevel">
> @@ -785,7 +785,7 @@
>         </description>
>       </request>
>
> -    <enum name="transient">
> +    <enum name="transient" bitfield="true">
>         <description summary="details of transient behaviour">
>    These flags specify details of the expected behaviour
>    of transient surfaces. Used in the set_transient request.
> @@ -807,7 +807,7 @@
>         <arg name="parent" type="object" interface="wl_surface"/>
>         <arg name="x" type="int"/>
>         <arg name="y" type="int"/>
> -      <arg name="flags" type="uint"/>
> +      <arg name="flags" type="uint" enum="transient"/>
>       </request>
>
>       <enum name="fullscreen_method">
> @@ -891,7 +891,7 @@
>         <arg name="parent" type="object" interface="wl_surface"/>
>         <arg name="x" type="int"/>
>         <arg name="y" type="int"/>
> -      <arg name="flags" type="uint"/>
> +      <arg name="flags" type="uint" enum="transient"/>
>       </request>
>
>       <request name="set_maximized">
> @@ -972,7 +972,7 @@
>    in surface local coordinates.
>         </description>
>
> -      <arg name="edges" type="uint"/>
> +      <arg name="edges" type="uint" enum="resize"/>
>         <arg name="width" type="int"/>
>         <arg name="height" type="int"/>
>       </event>
> @@ -1337,7 +1337,7 @@
>         maintains a keyboard focus and a pointer focus.
>       </description>
>
> -    <enum name="capability">
> +    <enum name="capability" bitfield="true">
>         <description summary="seat capability bitmask">
>           This is a bitmask of capabilities this seat has; if a member is
>           set, then it is present on the seat.
> @@ -1353,7 +1353,7 @@
>    keyboard or touch capabilities.  The argument is a capability
>    enum containing the complete set of capabilities this seat has.
>         </description>
> -      <arg name="capabilities" type="uint"/>
> +      <arg name="capabilities" type="uint" enum="capability"/>
>       </event>
>
>       <request name="get_pointer">
> @@ -1521,7 +1521,7 @@
>         <arg name="serial" type="uint"/>
>         <arg name="time" type="uint" summary="timestamp with
> millisecond granularity"/>
>         <arg name="button" type="uint"/>
> -      <arg name="state" type="uint"/>
> +      <arg name="state" type="uint" enum="button_state"/>
>       </event>
>
>       <enum name="axis">
> @@ -1553,7 +1553,7 @@
>         </description>
>
>         <arg name="time" type="uint" summary="timestamp with
> millisecond granularity"/>
> -      <arg name="axis" type="uint"/>
> +      <arg name="axis" type="uint" enum="axis"/>
>         <arg name="value" type="fixed"/>
>       </event>
>
> @@ -1593,7 +1593,7 @@
>    This event provides a file descriptor to the client which can be
>    memory-mapped to provide a keyboard mapping description.
>         </description>
> -      <arg name="format" type="uint"/>
> +      <arg name="format" type="uint" enum="keymap_format"/>
>         <arg name="fd" type="fd"/>
>         <arg name="size" type="uint"/>
>       </event>
> @@ -1638,7 +1638,7 @@
>         <arg name="serial" type="uint"/>
>         <arg name="time" type="uint" summary="timestamp with
> millisecond granularity"/>
>         <arg name="key" type="uint"/>
> -      <arg name="state" type="uint"/>
> +      <arg name="state" type="uint" enum="key_state"/>
>       </event>
>
>       <event name="modifiers">
> @@ -1819,17 +1819,17 @@
>      summary="width in millimeters of the output"/>
>         <arg name="physical_height" type="int"
>      summary="height in millimeters of the output"/>
> -      <arg name="subpixel" type="int"
> +      <arg name="subpixel" type="int" enum="subpixel"
>      summary="subpixel orientation of the output"/>
>         <arg name="make" type="string"
>      summary="textual description of the manufacturer"/>
>         <arg name="model" type="string"
>      summary="textual description of the model"/>
> -      <arg name="transform" type="int"
> +      <arg name="transform" type="int" enum="transform"
>      summary="transform that maps framebuffer to output"/>
>       </event>
>
> -    <enum name="mode">
> +    <enum name="mode" bitfield="true">
>         <description summary="mode information">
>    These flags describe properties of an output mode.
>    They are used in the flags bitfield of the mode event.
> @@ -1856,7 +1856,7 @@
>           the output may be scaled, as described in wl_output.scale,
>           or transformed , as described in wl_output.transform.
>         </description>
> -      <arg name="flags" type="uint" summary="bitfield of mode flags"/>
> +      <arg name="flags" type="uint" summary="bitfield of mode flags"
> enum="mode"/>
>         <arg name="width" type="int" summary="width of the mode in
> hardware units"/>
>         <arg name="height" type="int" summary="height of the mode in
> hardware units"/>
>         <arg name="refresh" type="int" summary="vertical refresh rate in mHz"/>
>


More information about the wayland-devel mailing list