mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-01-06 09:30:12 +01:00
protocol: change type=bitmask to use the wayland protocol's bitfield=true
This commit is contained in:
parent
5c860507e5
commit
b7ac763241
2 changed files with 19 additions and 12 deletions
|
|
@ -241,16 +241,20 @@ class Enum:
|
|||
name: str = attr.ib()
|
||||
since: int = attr.ib()
|
||||
interface: "Interface" = attr.ib()
|
||||
is_bitmask: bool = attr.ib(default=False)
|
||||
is_bitfield: bool = attr.ib(default=False)
|
||||
description: Optional[Description] = attr.ib(default=None)
|
||||
|
||||
entries: list[Entry] = attr.ib(init=False, factory=list)
|
||||
|
||||
@classmethod
|
||||
def create(
|
||||
cls, name: str, interface: "Interface", since: int = 1, is_bitmask: bool = False
|
||||
cls,
|
||||
name: str,
|
||||
interface: "Interface",
|
||||
since: int = 1,
|
||||
is_bitfield: bool = False,
|
||||
) -> "Enum":
|
||||
return cls(name=name, since=since, interface=interface, is_bitmask=is_bitmask)
|
||||
return cls(name=name, since=since, interface=interface, is_bitfield=is_bitfield)
|
||||
|
||||
def add_entry(self, entry: Entry) -> None:
|
||||
for e in self.entries:
|
||||
|
|
@ -260,7 +264,7 @@ class Enum:
|
|||
if e.value == entry.value:
|
||||
raise ValueError(f"Duplicate enum value '{entry.value}'")
|
||||
|
||||
if self.is_bitmask:
|
||||
if self.is_bitfield:
|
||||
if e.value < 0:
|
||||
raise ValueError("Bitmasks must not be less than zero")
|
||||
if e.value.bit_count() > 1:
|
||||
|
|
@ -529,19 +533,22 @@ class ProtocolParser(xml.sax.handler.ContentHandler):
|
|||
self.location,
|
||||
)
|
||||
|
||||
enum_type = attrs.get("type", None)
|
||||
if enum_type is not None and enum_type not in ["bitmask"]:
|
||||
try:
|
||||
is_bitfield = {
|
||||
"true": True,
|
||||
"false": False,
|
||||
}[attrs.get("bitfield", "false")]
|
||||
except KeyError as e:
|
||||
raise XmlError.create(
|
||||
f"Invalid enum type {enum_type} in element '{element}'",
|
||||
f"Invalid value {e} for boolean bitfield attribute in '{element}'",
|
||||
self.location,
|
||||
)
|
||||
is_bitmask = enum_type == "bitmask"
|
||||
|
||||
enum = Enum.create(
|
||||
name=name,
|
||||
since=since,
|
||||
interface=self.current_interface,
|
||||
is_bitmask=is_bitmask,
|
||||
is_bitfield=is_bitfield,
|
||||
)
|
||||
try:
|
||||
self.current_interface.add_enum(enum)
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@
|
|||
|
||||
<event name="invalid_object" since="1">
|
||||
<description summary="Invalid object in request notification">
|
||||
Notification that an object ID used in a prior request was
|
||||
Notification that an object ID used in an earlier request was
|
||||
invalid and does not exist.
|
||||
|
||||
This event is sent by the EIS implementation when an object that
|
||||
|
|
@ -526,7 +526,7 @@
|
|||
</description>
|
||||
</request>
|
||||
|
||||
<enum name="capabilities" since="1" type="bitmask">
|
||||
<enum name="capabilities" since="1" bitfield="true">
|
||||
<description summary="Seat capabilities">
|
||||
A set of capabilities possible available on this seat. A client may bind to these
|
||||
capabilies and an EIS implementation may then create device based on the bound
|
||||
|
|
@ -734,7 +734,7 @@
|
|||
<arg name="name" type="string" summary="the device name"/>
|
||||
</event>
|
||||
|
||||
<enum name="capabilities" since="1" type="bitmask">
|
||||
<enum name="capabilities" since="1" bitfield="true">
|
||||
<description summary="Device capabilities">
|
||||
These capabilities are binary compatible with ei_seat.capabilities.
|
||||
</description>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue