forked from KolibriOS/kolibrios
[kernel][asmxygen.py] Implement variable doxygen generation
git-svn-id: svn://kolibrios.org@8841 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
4dea14e6e3
commit
41b1b667fc
@ -43,7 +43,7 @@ kernel_structure = {}
|
|||||||
def get_declarations(asm_file_contents, asm_file_name):
|
def get_declarations(asm_file_contents, asm_file_name):
|
||||||
kernel_structure[asm_file_name] = [ [], [], [], [], [] ]
|
kernel_structure[asm_file_name] = [ [], [], [], [], [] ]
|
||||||
|
|
||||||
variable_pattern = re.compile(r'^\s*([\w\.]+)\s+d[bwdq] .*')
|
variable_pattern = re.compile(r'^\s*([\w\.]+)\s+d([bwdq])\s+([^;]*)\s*([;].*)?')
|
||||||
macro_pattern = re.compile(r'^\s*macro\s+([\w]+).*')
|
macro_pattern = re.compile(r'^\s*macro\s+([\w]+).*')
|
||||||
proc_pattern = re.compile(r'^\s*proc\s+([\w\.]+).*')
|
proc_pattern = re.compile(r'^\s*proc\s+([\w\.]+).*')
|
||||||
label_pattern = re.compile(r'^(?!;)\s*([\w\.]+):.*')
|
label_pattern = re.compile(r'^(?!;)\s*([\w\.]+):.*')
|
||||||
@ -56,9 +56,19 @@ def get_declarations(asm_file_contents, asm_file_name):
|
|||||||
|
|
||||||
match = variable_pattern.findall(line)
|
match = variable_pattern.findall(line)
|
||||||
if len(match) > 0:
|
if len(match) > 0:
|
||||||
var_name = match[0]
|
(var_name, var_type, var_init, var_comm) = match[0]
|
||||||
#print(f"Variable '{var_name}' at {line_idx + 1}")
|
if var_comm == "":
|
||||||
kernel_structure[asm_file_name][VARIABLES].append([ line_idx + 1, var_name ])
|
var_comm = "Undocumented"
|
||||||
|
else:
|
||||||
|
var_comm = var_comm[1:].lstrip()
|
||||||
|
if (len(var_comm) == 0):
|
||||||
|
var_comm = "!!! EMPTY_COMMENT"
|
||||||
|
if var_comm[0].islower(): var_comm = "!!! LOWERCASE COMMENT " + var_comm
|
||||||
|
if var_type == "b": var_type = "byte"
|
||||||
|
if var_type == "w": var_type = "word"
|
||||||
|
if var_type == "d": var_type = "dword"
|
||||||
|
if var_type == "q": var_type = "qword"
|
||||||
|
kernel_structure[asm_file_name][VARIABLES].append([ line_idx + 1, var_name, var_type, var_init, var_comm ])
|
||||||
line_idx += 1
|
line_idx += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -108,6 +118,7 @@ def get_declarations(asm_file_contents, asm_file_name):
|
|||||||
line_idx += 1
|
line_idx += 1
|
||||||
|
|
||||||
def handle_file(handled_files, asm_file_name, subdir = "."):
|
def handle_file(handled_files, asm_file_name, subdir = "."):
|
||||||
|
if dump_symbols:
|
||||||
print(f"Handling {asm_file_name}")
|
print(f"Handling {asm_file_name}")
|
||||||
handled_files.append(asm_file_name)
|
handled_files.append(asm_file_name)
|
||||||
try:
|
try:
|
||||||
@ -170,6 +181,7 @@ if print_stats:
|
|||||||
macro_count += len(kernel_structure[source][MACROS])
|
macro_count += len(kernel_structure[source][MACROS])
|
||||||
struct_count += len(kernel_structure[source][STRUCTURES])
|
struct_count += len(kernel_structure[source][STRUCTURES])
|
||||||
|
|
||||||
|
print(f"File count: {len(kernel_structure)}")
|
||||||
print(f"Variable count: {var_count}")
|
print(f"Variable count: {var_count}")
|
||||||
print(f"Procedures count: {proc_count}")
|
print(f"Procedures count: {proc_count}")
|
||||||
print(f"Global labels count: {label_count}")
|
print(f"Global labels count: {label_count}")
|
||||||
@ -180,8 +192,7 @@ print(f"Writing doumented sources to {doxygen_src_path}")
|
|||||||
|
|
||||||
created_files = []
|
created_files = []
|
||||||
|
|
||||||
def write_variable(source, line, name, type = "int", brief = "Undocumented",
|
def write_variable(source, line, name, type, init, brief):
|
||||||
init = None):
|
|
||||||
source = source.replace("./", "")
|
source = source.replace("./", "")
|
||||||
full_path = doxygen_src_path + '/' + source
|
full_path = doxygen_src_path + '/' + source
|
||||||
# Remove the file on first access if it was created by previous generation
|
# Remove the file on first access if it was created by previous generation
|
||||||
@ -202,11 +213,7 @@ def write_variable(source, line, name, type = "int", brief = "Undocumented",
|
|||||||
f.write(f" * @par Source\n")
|
f.write(f" * @par Source\n")
|
||||||
f.write(f" * <a href='{link_root}/{source}#line-{line}'>{source}:{line}</a>\n")
|
f.write(f" * <a href='{link_root}/{source}#line-{line}'>{source}:{line}</a>\n")
|
||||||
f.write(f" */\n")
|
f.write(f" */\n")
|
||||||
if init == None:
|
f.write(f"{type} {name};\n\n")
|
||||||
set_init = ""
|
|
||||||
else:
|
|
||||||
set_init = f" = {init}"
|
|
||||||
f.write(f"{type} {name}{set_init};\n\n")
|
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
i = 1
|
i = 1
|
||||||
@ -216,5 +223,5 @@ for source in kernel_structure:
|
|||||||
# Write variables doxygen of the source file
|
# Write variables doxygen of the source file
|
||||||
if len(kernel_structure[source][VARIABLES]) > 0:
|
if len(kernel_structure[source][VARIABLES]) > 0:
|
||||||
for variable in kernel_structure[source][VARIABLES]:
|
for variable in kernel_structure[source][VARIABLES]:
|
||||||
write_variable(source, variable[0], variable[1])
|
write_variable(source, variable[0], variable[1], variable[2], variable[3], variable[4])
|
||||||
i += 1
|
i += 1
|
||||||
|
Loading…
Reference in New Issue
Block a user