From 87705ef97c6df7c18f8154a6eb256be1ecbd206e Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Wed, 24 Jul 2024 13:32:03 +1000 Subject: [PATCH] scanner: handle the allow-null attribute for arguments Currently unused but it's exposed, so yay... --- proto/ei-scanner | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/proto/ei-scanner b/proto/ei-scanner index 4aefd0a..11edb85 100755 --- a/proto/ei-scanner +++ b/proto/ei-scanner @@ -92,6 +92,10 @@ class Argument: For an argument referenced by another argument of type "new_id", this field points to the other argument that references this argument. """ + allow_null: bool = attr.ib(default=False) + """ + For an argument of type string, specify if the argument may be NULL. + """ @property def signature(self) -> str: @@ -137,6 +141,7 @@ class Argument: summary: str = "", enum: Optional["Enum"] = None, interface: Optional["Interface"] = None, + allow_null: bool = False, ) -> "Argument": return cls( name=name, @@ -144,6 +149,7 @@ class Argument: summary=summary, enum=enum, interface=interface, + allow_null=allow_null, ) @@ -709,12 +715,15 @@ class ProtocolParser(xml.sax.handler.ContentHandler): f"Failed to find enum '{intf.name}.{enum_name}'", self.location, ) + + allow_null = attrs.get("allow-null", "false") == "true" arg = Argument.create( name=name, protocol_type=proto_type, summary=summary, enum=enum, interface=interface, + allow_null=allow_null, ) self.current_message.add_argument(arg) if proto_type == "new_id":