scanner: handle the allow-null attribute for arguments

Currently unused but it's exposed, so yay...
This commit is contained in:
Peter Hutterer 2024-07-24 13:32:03 +10:00
parent 267716a760
commit 87705ef97c

View file

@ -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":