summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-03-15 13:56:55 +0100
committerMarkus Armbruster <armbru@redhat.com>2017-03-16 07:13:02 +0100
commit2cfbae3c423ecd13a7722ac7a7dca7ec4168e2ff (patch)
tree14fcbec48e3550368f0251b93aa95a0e62ec6797 /scripts
parent1554a8fae984cad4704fb94a8cef3c9b42ef6185 (diff)
downloadqemu-2cfbae3c423ecd13a7722ac7a7dca7ec4168e2ff.tar.gz
qapi: Have each QAPI schema declare its name rule violations
qapi.py has a hardcoded white-list of type names that may violate the rule on use of upper and lower case. Add a new pragma directive 'name-case-whitelist', and use it to replace the hard-coded white-list. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1489582656-31133-7-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/qapi.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/scripts/qapi.py b/scripts/qapi.py
index 1d86d85d49..78db319831 100644
--- a/scripts/qapi.py
+++ b/scripts/qapi.py
@@ -44,16 +44,7 @@ doc_required = False
returns_whitelist = []
# Whitelist of entities allowed to violate case conventions
-case_whitelist = [
- # From QMP:
- 'ACPISlotType', # DIMM, visible through query-acpi-ospm-status
- 'CpuInfoMIPS', # PC, visible through query-cpu
- 'CpuInfoTricore', # PC, visible through query-cpu
- 'QapiErrorClass', # all members, visible through errors
- 'UuidInfo', # UUID, visible through query-uuid
- 'X86CPURegister32', # all members, visible indirectly through qom-get
- 'q_obj_CpuInfo-base', # CPU, visible through query-cpu
-]
+name_case_whitelist = []
enum_types = []
struct_types = []
@@ -302,7 +293,7 @@ class QAPISchemaParser(object):
self.docs.extend(exprs_include.docs)
def _pragma(self, name, value, info):
- global doc_required, returns_whitelist
+ global doc_required, returns_whitelist, name_case_whitelist
if name == 'doc-required':
if not isinstance(value, bool):
raise QAPISemError(info,
@@ -315,6 +306,13 @@ class QAPISchemaParser(object):
"Pragma returns-whitelist must be"
" a list of strings")
returns_whitelist = value
+ elif name == 'name-case-whitelist':
+ if (not isinstance(value, list)
+ or any([not isinstance(elt, str) for elt in value])):
+ raise QAPISemError(info,
+ "Pragma name-case-whitelist must be"
+ " a list of strings")
+ name_case_whitelist = value
else:
raise QAPISemError(info, "Unknown pragma '%s'" % name)
@@ -1287,7 +1285,7 @@ class QAPISchemaMember(object):
def check_clash(self, info, seen):
cname = c_name(self.name)
- if cname.lower() != cname and self.owner not in case_whitelist:
+ if cname.lower() != cname and self.owner not in name_case_whitelist:
raise QAPISemError(info,
"%s should not use uppercase" % self.describe())
if cname in seen: