mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-03 11:54:02 +00:00
Add a bit of documentation
This commit is contained in:
parent
0bbad741f4
commit
9d4d750041
@ -1,4 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
"""Generate programs/psa/psa_constant_names_generated.c
|
||||||
|
which is included by programs/psa/psa_constant_names.c.
|
||||||
|
The code generated by this module is only meant to be used in the context
|
||||||
|
of that program.
|
||||||
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@ -179,6 +186,12 @@ bit_test_template = '''\
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
class MacroCollector:
|
class MacroCollector:
|
||||||
|
"""Collect PSA crypto macro definitions from C header files.
|
||||||
|
|
||||||
|
1. Call `read_file` on the input header file(s).
|
||||||
|
2. Call `write_file` to write ``psa_constant_names_generated.c``.
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.statuses = set()
|
self.statuses = set()
|
||||||
self.key_types = set()
|
self.key_types = set()
|
||||||
@ -198,6 +211,10 @@ class MacroCollector:
|
|||||||
definition_re = re.compile(r'\s*#\s*define\s+(\w+)(?:\s+|\((\w+)\)\s*)(.+)(?:/[*/])?')
|
definition_re = re.compile(r'\s*#\s*define\s+(\w+)(?:\s+|\((\w+)\)\s*)(.+)(?:/[*/])?')
|
||||||
|
|
||||||
def read_line(self, line):
|
def read_line(self, line):
|
||||||
|
"""Parse a C header line and record the PSA identifier it defines if any.
|
||||||
|
This function analyzes lines that start with "#define PSA_"
|
||||||
|
(up to non-significant whitespace) and skips all non-matching lines."""
|
||||||
|
# pylint: disable=too-many-branches
|
||||||
m = re.match(self.definition_re, line)
|
m = re.match(self.definition_re, line)
|
||||||
if not m:
|
if not m:
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user