New enum QapiSpecialFeature enumerates the special feature flags.
New helper gen_special_features() returns code to represent a
collection of special feature flags as a bitset.
The next few commits will put them to use.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Message-Id: <
20211028102520.747396-5-armbru@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
#ifndef QAPI_UTIL_H
#define QAPI_UTIL_H
+typedef enum {
+ QAPI_DEPRECATED,
+} QapiSpecialFeature;
+
/* QEnumLookup flags */
#define QAPI_ENUM_DEPRECATED 1
Dict,
Iterator,
Optional,
+ Sequence,
Tuple,
)
mcgen,
)
from .schema import (
+ QAPISchemaFeature,
QAPISchemaIfCond,
QAPISchemaModule,
QAPISchemaObjectType,
from .source import QAPISourceInfo
+def gen_special_features(features: Sequence[QAPISchemaFeature]) -> str:
+ special_features = [f"1u << QAPI_{feat.name.upper()}"
+ for feat in features if feat.is_special()]
+ return ' | '.join(special_features) or '0'
+
+
class QAPIGen:
def __init__(self, fname: str):
self.fname = fname
class QAPISchemaFeature(QAPISchemaMember):
role = 'feature'
+ def is_special(self):
+ return self.name in ('deprecated')
+
class QAPISchemaObjectTypeMember(QAPISchemaMember):
def __init__(self, name, info, typ, optional, ifcond=None, features=None):