scanner: handle since tags in enum values

This commit is contained in:
Peter Hutterer 2023-02-10 15:53:25 +10:00
parent 8c85b8fc1f
commit ea8df6402a
2 changed files with 11 additions and 3 deletions

View file

@ -61,6 +61,10 @@ enum {{enum.fqdn}} {
{{enum.fqdn.upper()}}_{{entry.name.upper()}} = {{entry.value}},
{% endfor %}
};
{% for entry in enum.entries %}
#define {{enum.fqdn.upper()}}_{{entry.name.upper()}}_SINCE_VERSION {{entry.since}}
{% endfor %}
{% endfor %}
/* Message sender functions */

View file

@ -221,10 +221,13 @@ class Entry:
name: str = attr.ib()
value: int = attr.ib()
summary: str = attr.ib()
since: int = attr.ib()
@classmethod
def create(cls, name: str, value: int, summary: str = "") -> "Entry":
return cls(name=name, value=value, summary=summary)
def create(
cls, name: str, value: int, summary: str = "", since: int = 1
) -> "Entry":
return cls(name=name, value=value, summary=summary, since=since)
@attr.s
@ -549,7 +552,8 @@ class Protocol(xml.sax.handler.ContentHandler):
name = attrs["name"]
value = int(attrs["value"])
summary = attrs.get("summary", "")
entry = Entry.create(name=name, value=value, summary=summary)
since = int(attrs.get("since", 1))
entry = Entry.create(name=name, value=value, summary=summary, since=since)
try:
self.current_message.add_entry(entry)
except ValueError as e: