mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-04-18 18:00:42 +02:00
scanner: add the camel_name property to our messages
This allows for templating into EiConnectionSetup and the like
This commit is contained in:
parent
58b430039a
commit
20e425a48d
1 changed files with 16 additions and 0 deletions
|
|
@ -16,6 +16,10 @@ import xml.sax.handler
|
|||
import xml.sax._exceptions
|
||||
|
||||
|
||||
def snake2camel(s: str) -> str:
|
||||
return s.replace("_", " ").title().replace(" ", "")
|
||||
|
||||
|
||||
def proto_to_type(proto: str) -> Optional[str]:
|
||||
"""
|
||||
Conversion of protocol types to the signatures we use in the code
|
||||
|
|
@ -147,6 +151,10 @@ class Message:
|
|||
def signature(self) -> str:
|
||||
return "".join([a.signature for a in self.arguments])
|
||||
|
||||
@property
|
||||
def camel_name(self) -> str:
|
||||
return snake2camel(self.name)
|
||||
|
||||
|
||||
@attr.s
|
||||
class Request(Message):
|
||||
|
|
@ -221,6 +229,10 @@ class Enum:
|
|||
def fqdn(self):
|
||||
return f"{self.interface.name}_{self.name}"
|
||||
|
||||
@property
|
||||
def camel_name(self) -> str:
|
||||
return snake2camel(self.name)
|
||||
|
||||
|
||||
@attr.s
|
||||
class Interface:
|
||||
|
|
@ -278,6 +290,10 @@ class Interface:
|
|||
def as_arg(self) -> str:
|
||||
return f"{self.ctype} {self.name}"
|
||||
|
||||
@property
|
||||
def camel_name(self) -> str:
|
||||
return snake2camel(self.name)
|
||||
|
||||
@classmethod
|
||||
def create(cls, name: str, version: int, mode: str = "ei") -> "Interface":
|
||||
assert mode in ["ei", "eis"]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue