mirror of
https://github.com/Mbed-TLS/mbedtls-framework.git
synced 2026-10-20 07:27:56 +00:00
psa_wrapper: Changed naming convention for class variables.
Signed-off-by: Minos Galanakis <[email protected]>
This commit is contained in:
@@ -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
|
The method will remove (ident_lv * 4) space-character identations from
|
||||||
input string. It will also remove all whitespace around the text-block.
|
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), "",
|
return re.sub(r"(?m)^ {{{ident}}}".format(ident=ident_lv * 4), "",
|
||||||
@@ -225,7 +225,7 @@ class Base:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
_FUNCTION_GUARDS = {
|
_function_guards = {
|
||||||
} #type: Dict[str, str]
|
} #type: Dict[str, str]
|
||||||
|
|
||||||
def _function_guard(self, function: FunctionInfo) -> Optional[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.
|
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]:
|
def _wrapper_info(self, function: FunctionInfo) -> Optional[WrapperInfo]:
|
||||||
"""Information about the wrapper for one function.
|
"""Information about the wrapper for one function.
|
||||||
|
|||||||
@@ -86,10 +86,10 @@ class PSAWrapper(c_wrapper_generator.Base):
|
|||||||
def read_config(self, cfg: PSAWrapperConfiguration)-> None:
|
def read_config(self, cfg: PSAWrapperConfiguration)-> None:
|
||||||
"""Configure instance's parameters from a user provided config."""
|
"""Configure instance's parameters from a user provided config."""
|
||||||
|
|
||||||
self._CPP_GUARDS = PSAWrapper.parse_def_guards(cfg.cpp_guards)
|
self._cpp_guards = PSAWrapper.parse_def_guards(cfg.cpp_guards)
|
||||||
self._SKIP_FUNCTIONS = cfg.skipped_functions
|
self._skip_functions = cfg.skipped_functions
|
||||||
self._FUNCTION_GUARDS.update(cfg.function_guards)
|
self._function_guards.update(cfg.function_guards)
|
||||||
self._NOT_IMPLEMENTED = cfg.skipped_argument_types
|
self._not_implemented = cfg.skipped_argument_types
|
||||||
|
|
||||||
def read_headers(self, headers: Optional[List[str]]) -> None:
|
def read_headers(self, headers: Optional[List[str]]) -> None:
|
||||||
"""Reads functions to be wrapped from source header files into self.functions."""
|
"""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:
|
def _skip_function(self, function: c_wrapper_generator.FunctionInfo) -> bool:
|
||||||
if function.return_type != 'psa_status_t':
|
if function.return_type != 'psa_status_t':
|
||||||
return True
|
return True
|
||||||
if function.name in self._SKIP_FUNCTIONS:
|
if function.name in self._skip_functions:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@@ -220,8 +220,8 @@ class PSAWrapper(c_wrapper_generator.Base):
|
|||||||
super()._write_prologue(out, header)
|
super()._write_prologue(out, header)
|
||||||
|
|
||||||
prologue = []
|
prologue = []
|
||||||
if self._CPP_GUARDS:
|
if self._cpp_guards:
|
||||||
prologue.append("#if {}".format(self._CPP_GUARDS))
|
prologue.append("#if {}".format(self._cpp_guards))
|
||||||
prologue.append('')
|
prologue.append('')
|
||||||
|
|
||||||
for include in self._PSA_WRAPPER_INCLUDES:
|
for include in self._PSA_WRAPPER_INCLUDES:
|
||||||
@@ -235,8 +235,8 @@ class PSAWrapper(c_wrapper_generator.Base):
|
|||||||
out.write("\n".join(prologue))
|
out.write("\n".join(prologue))
|
||||||
|
|
||||||
def _write_epilogue(self, out: typing_util.Writable, header: bool) -> None:
|
def _write_epilogue(self, out: typing_util.Writable, header: bool) -> None:
|
||||||
if self._CPP_GUARDS:
|
if self._cpp_guards:
|
||||||
out.write("#endif /* {} */\n\n".format(self._CPP_GUARDS))
|
out.write("#endif /* {} */\n\n".format(self._cpp_guards))
|
||||||
super()._write_epilogue(out, header)
|
super()._write_epilogue(out, header)
|
||||||
|
|
||||||
class PSALoggingWrapper(PSAWrapper, c_wrapper_generator.Logging):
|
class PSALoggingWrapper(PSAWrapper, c_wrapper_generator.Logging):
|
||||||
@@ -276,7 +276,7 @@ class PSALoggingWrapper(PSAWrapper, c_wrapper_generator.Logging):
|
|||||||
return '', []
|
return '', []
|
||||||
if typ.endswith('operation_t *'):
|
if typ.endswith('operation_t *'):
|
||||||
return '', []
|
return '', []
|
||||||
if typ in self._NOT_IMPLEMENTED:
|
if typ in self._not_implemented:
|
||||||
return '', []
|
return '', []
|
||||||
if typ == 'psa_key_attributes_t *':
|
if typ == 'psa_key_attributes_t *':
|
||||||
return (var + '={id=%u, lifetime=0x%08x, type=0x%08x, bits=%u, alg=%08x, usage=%08x}',
|
return (var + '={id=%u, lifetime=0x%08x, type=0x%08x, bits=%u, alg=%08x, usage=%08x}',
|
||||||
|
|||||||
Reference in New Issue
Block a user