diff --git a/scripts/mbedtls_framework/c_wrapper_generator.py b/scripts/mbedtls_framework/c_wrapper_generator.py index f2d29aa4e..6ef44234b 100644 --- a/scripts/mbedtls_framework/c_wrapper_generator.py +++ b/scripts/mbedtls_framework/c_wrapper_generator.py @@ -35,7 +35,7 @@ def strip_indentation(in_str: str, new_lines: int = 1, ident_lv: int = 4) -> str The method will remove (ident_lv * 4) space-character identations from input string. It will also remove all whitespace around the text-block. - At the end of the stream a `new_lines` ammount of empty lines will be added. + At the end of the string a `new_lines` amount of empty lines will be added. """ return re.sub(r"(?m)^ {{{ident}}}".format(ident=ident_lv * 4), "", @@ -225,7 +225,7 @@ class Base: return True return False - _FUNCTION_GUARDS = { + _function_guards = { } #type: Dict[str, str] def _function_guard(self, function: FunctionInfo) -> Optional[str]: @@ -233,7 +233,7 @@ class Base: The wrapper will be guarded with `#if` on this condition, if not None. """ - return self._FUNCTION_GUARDS.get(function.name) + return self._function_guards.get(function.name) def _wrapper_info(self, function: FunctionInfo) -> Optional[WrapperInfo]: """Information about the wrapper for one function. diff --git a/scripts/mbedtls_framework/code_wrapper/psa_wrapper.py b/scripts/mbedtls_framework/code_wrapper/psa_wrapper.py index ae226ce06..d49ad14b2 100644 --- a/scripts/mbedtls_framework/code_wrapper/psa_wrapper.py +++ b/scripts/mbedtls_framework/code_wrapper/psa_wrapper.py @@ -86,10 +86,10 @@ class PSAWrapper(c_wrapper_generator.Base): def read_config(self, cfg: PSAWrapperConfiguration)-> None: """Configure instance's parameters from a user provided config.""" - self._CPP_GUARDS = PSAWrapper.parse_def_guards(cfg.cpp_guards) - self._SKIP_FUNCTIONS = cfg.skipped_functions - self._FUNCTION_GUARDS.update(cfg.function_guards) - self._NOT_IMPLEMENTED = cfg.skipped_argument_types + self._cpp_guards = PSAWrapper.parse_def_guards(cfg.cpp_guards) + self._skip_functions = cfg.skipped_functions + self._function_guards.update(cfg.function_guards) + self._not_implemented = cfg.skipped_argument_types def read_headers(self, headers: Optional[List[str]]) -> None: """Reads functions to be wrapped from source header files into self.functions.""" @@ -204,7 +204,7 @@ class PSAWrapper(c_wrapper_generator.Base): def _skip_function(self, function: c_wrapper_generator.FunctionInfo) -> bool: if function.return_type != 'psa_status_t': return True - if function.name in self._SKIP_FUNCTIONS: + if function.name in self._skip_functions: return True return False @@ -220,8 +220,8 @@ class PSAWrapper(c_wrapper_generator.Base): super()._write_prologue(out, header) prologue = [] - if self._CPP_GUARDS: - prologue.append("#if {}".format(self._CPP_GUARDS)) + if self._cpp_guards: + prologue.append("#if {}".format(self._cpp_guards)) prologue.append('') for include in self._PSA_WRAPPER_INCLUDES: @@ -235,8 +235,8 @@ class PSAWrapper(c_wrapper_generator.Base): out.write("\n".join(prologue)) def _write_epilogue(self, out: typing_util.Writable, header: bool) -> None: - if self._CPP_GUARDS: - out.write("#endif /* {} */\n\n".format(self._CPP_GUARDS)) + if self._cpp_guards: + out.write("#endif /* {} */\n\n".format(self._cpp_guards)) super()._write_epilogue(out, header) class PSALoggingWrapper(PSAWrapper, c_wrapper_generator.Logging): @@ -276,7 +276,7 @@ class PSALoggingWrapper(PSAWrapper, c_wrapper_generator.Logging): return '', [] if typ.endswith('operation_t *'): return '', [] - if typ in self._NOT_IMPLEMENTED: + if typ in self._not_implemented: return '', [] if typ == 'psa_key_attributes_t *': return (var + '={id=%u, lifetime=0x%08x, type=0x%08x, bits=%u, alg=%08x, usage=%08x}',