From f8deb759ba34622e744763d0179b834ef9664869 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 25 Jan 2021 22:41:45 +0100 Subject: [PATCH] Factor out is_internal_name as a separate method Signed-off-by: Gilles Peskine --- scripts/mbedtls_dev/macro_collector.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scripts/mbedtls_dev/macro_collector.py b/scripts/mbedtls_dev/macro_collector.py index f6f26f8c88..0f7be604d7 100644 --- a/scripts/mbedtls_dev/macro_collector.py +++ b/scripts/mbedtls_dev/macro_collector.py @@ -35,6 +35,10 @@ class PSAMacroCollector: self.algorithms_from_hash = {} self.key_usages = set() + def is_internal_name(self, name): + """Whether this is an internal macro. Internal macros will be skipped.""" + return name.endswith('_FLAG') or name.endswith('MASK') + # "#define" followed by a macro name with either no parameters # or a single parameter and a non-empty expansion. # Grab the macro name in group 1, the parameter name if any in group 2 @@ -60,7 +64,7 @@ class PSAMacroCollector: # backward compatibility aliases that share # numerical values with non-deprecated values. return - if name.endswith('_FLAG') or name.endswith('MASK'): + if self.is_internal_name(name): # Macro only to build actual values return elif (name.startswith('PSA_ERROR_') or name == 'PSA_SUCCESS') \