mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-05 01:58:01 +02:00
scanner: parse the type="destructor" attribute on requests/events
This commit is contained in:
parent
2e4d984819
commit
9e731ddf04
1 changed files with 39 additions and 7 deletions
|
|
@ -137,6 +137,7 @@ class Message:
|
|||
since: int = attr.ib()
|
||||
opcode: int = attr.ib()
|
||||
interface: "Interface" = attr.ib()
|
||||
is_destructor: bool = attr.ib(default=False)
|
||||
|
||||
arguments: list[Argument] = attr.ib(init=False, factory=list)
|
||||
|
||||
|
|
@ -160,9 +161,20 @@ class Message:
|
|||
class Request(Message):
|
||||
@classmethod
|
||||
def create(
|
||||
cls, name: str, opcode: int, interface: "Interface", since: int = 1
|
||||
cls,
|
||||
name: str,
|
||||
opcode: int,
|
||||
interface: "Interface",
|
||||
since: int = 1,
|
||||
is_destructor: bool = False,
|
||||
) -> "Request":
|
||||
return cls(name=name, opcode=opcode, since=since, interface=interface)
|
||||
return cls(
|
||||
name=name,
|
||||
opcode=opcode,
|
||||
since=since,
|
||||
interface=interface,
|
||||
is_destructor=is_destructor,
|
||||
)
|
||||
|
||||
@property
|
||||
def fqdn(self):
|
||||
|
|
@ -173,9 +185,20 @@ class Request(Message):
|
|||
class Event(Message):
|
||||
@classmethod
|
||||
def create(
|
||||
cls, name: str, opcode: int, interface: "Interface", since: int = 1
|
||||
cls,
|
||||
name: str,
|
||||
opcode: int,
|
||||
interface: "Interface",
|
||||
since: int = 1,
|
||||
is_destructor: bool = False,
|
||||
) -> "Event":
|
||||
return cls(name=name, opcode=opcode, since=since, interface=interface)
|
||||
return cls(
|
||||
name=name,
|
||||
opcode=opcode,
|
||||
since=since,
|
||||
interface=interface,
|
||||
is_destructor=is_destructor,
|
||||
)
|
||||
|
||||
@property
|
||||
def fqdn(self):
|
||||
|
|
@ -387,10 +410,14 @@ class Protocol(xml.sax.handler.ContentHandler):
|
|||
raise XmlError(
|
||||
*self.location, f"Missing attribute {e} in element '{element}'"
|
||||
)
|
||||
|
||||
is_destructor = attrs.get("type", "") == "destructor"
|
||||
opcode = len(self.current_interface.requests)
|
||||
request = Request.create(
|
||||
name=name, since=since, opcode=opcode, interface=self.current_interface
|
||||
name=name,
|
||||
since=since,
|
||||
opcode=opcode,
|
||||
interface=self.current_interface,
|
||||
is_destructor=is_destructor,
|
||||
)
|
||||
self.current_interface.add_request(request)
|
||||
self.current_message = request
|
||||
|
|
@ -413,9 +440,14 @@ class Protocol(xml.sax.handler.ContentHandler):
|
|||
*self.location, f"Missing attribute {e} in element '{element}'"
|
||||
)
|
||||
|
||||
is_destructor = attrs.get("type", "") == "destructor"
|
||||
opcode = len(self.current_interface.events)
|
||||
event = Event.create(
|
||||
name=name, since=since, opcode=opcode, interface=self.current_interface
|
||||
name=name,
|
||||
since=since,
|
||||
opcode=opcode,
|
||||
interface=self.current_interface,
|
||||
is_destructor=is_destructor,
|
||||
)
|
||||
self.current_interface.add_event(event)
|
||||
self.current_message = event
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue