mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-22 11:21:11 +00:00
Omit all deprecated definitions rather than a hard-coded list
Rather than hard-coding a list of deprecated aliases, assume that anything that's deprecated is an alias or otherwise not desired.
This commit is contained in:
parent
f30d4d9b34
commit
33b84f4db7
|
@ -211,6 +211,7 @@ class MacroCollector:
|
||||||
_define_directive_re = re.compile(r'\s*#\s*define\s+(\w+)' +
|
_define_directive_re = re.compile(r'\s*#\s*define\s+(\w+)' +
|
||||||
r'(?:\s+|\((\w+)\)\s*)' +
|
r'(?:\s+|\((\w+)\)\s*)' +
|
||||||
r'(.+)')
|
r'(.+)')
|
||||||
|
_deprecated_definition_re = re.compile(r'\s*MBEDTLS_DEPRECATED')
|
||||||
|
|
||||||
def read_line(self, line):
|
def read_line(self, line):
|
||||||
"""Parse a C header line and record the PSA identifier it defines if any.
|
"""Parse a C header line and record the PSA identifier it defines if any.
|
||||||
|
@ -223,20 +224,16 @@ class MacroCollector:
|
||||||
return
|
return
|
||||||
name, parameter, expansion = m.groups()
|
name, parameter, expansion = m.groups()
|
||||||
expansion = re.sub(r'/\*.*?\*/|//.*', r' ', expansion)
|
expansion = re.sub(r'/\*.*?\*/|//.*', r' ', expansion)
|
||||||
|
if re.match(self._deprecated_definition_re, expansion):
|
||||||
|
# Skip deprecated values, which are assumed to be
|
||||||
|
# backward compatibility aliases that share
|
||||||
|
# numerical values with non-deprecated values.
|
||||||
|
return
|
||||||
if name.endswith('_FLAG') or name.endswith('MASK'):
|
if name.endswith('_FLAG') or name.endswith('MASK'):
|
||||||
# Macro only to build actual values
|
# Macro only to build actual values
|
||||||
return
|
return
|
||||||
elif (name.startswith('PSA_ERROR_') or name == 'PSA_SUCCESS') \
|
elif (name.startswith('PSA_ERROR_') or name == 'PSA_SUCCESS') \
|
||||||
and not parameter:
|
and not parameter:
|
||||||
if name in ['PSA_ERROR_UNKNOWN_ERROR',
|
|
||||||
'PSA_ERROR_OCCUPIED_SLOT',
|
|
||||||
'PSA_ERROR_EMPTY_SLOT',
|
|
||||||
'PSA_ERROR_INSUFFICIENT_CAPACITY',
|
|
||||||
]:
|
|
||||||
# Ad hoc skipping of deprecated error codes, which share
|
|
||||||
# numerical values with non-deprecated error codes
|
|
||||||
return
|
|
||||||
|
|
||||||
self.statuses.add(name)
|
self.statuses.add(name)
|
||||||
elif name.startswith('PSA_KEY_TYPE_') and not parameter:
|
elif name.startswith('PSA_KEY_TYPE_') and not parameter:
|
||||||
self.key_types.add(name)
|
self.key_types.add(name)
|
||||||
|
|
Loading…
Reference in a new issue