Rev 8837 | Rev 8842 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8837 | Rev 8841 | ||
---|---|---|---|
Line 41... | Line 41... | ||
41 | kernel_structure = {} |
41 | kernel_structure = {} |
Line 42... | Line 42... | ||
42 | 42 | ||
43 | def get_declarations(asm_file_contents, asm_file_name): |
43 | def get_declarations(asm_file_contents, asm_file_name): |
Line 44... | Line 44... | ||
44 | kernel_structure[asm_file_name] = [ [], [], [], [], [] ] |
44 | kernel_structure[asm_file_name] = [ [], [], [], [], [] ] |
45 | 45 | ||
46 | variable_pattern = re.compile(r'^\s*([\w\.]+)\s+d[bwdq] .*') |
46 | variable_pattern = re.compile(r'^\s*([\w\.]+)\s+d([bwdq])\s+([^;]*)\s*([;].*)?') |
47 | macro_pattern = re.compile(r'^\s*macro\s+([\w]+).*') |
47 | macro_pattern = re.compile(r'^\s*macro\s+([\w]+).*') |
48 | proc_pattern = re.compile(r'^\s*proc\s+([\w\.]+).*') |
48 | proc_pattern = re.compile(r'^\s*proc\s+([\w\.]+).*') |
Line 54... | Line 54... | ||
54 | while line_idx < len(lines): |
54 | while line_idx < len(lines): |
55 | line = lines[line_idx] |
55 | line = lines[line_idx] |
Line 56... | Line 56... | ||
56 | 56 | ||
57 | match = variable_pattern.findall(line) |
57 | match = variable_pattern.findall(line) |
- | 58 | if len(match) > 0: |
|
- | 59 | (var_name, var_type, var_init, var_comm) = match[0] |
|
58 | if len(match) > 0: |
60 | if var_comm == "": |
- | 61 | var_comm = "Undocumented" |
|
- | 62 | else: |
|
- | 63 | var_comm = var_comm[1:].lstrip() |
|
- | 64 | if (len(var_comm) == 0): |
|
- | 65 | var_comm = "!!! EMPTY_COMMENT" |
|
59 | var_name = match[0] |
66 | if var_comm[0].islower(): var_comm = "!!! LOWERCASE COMMENT " + var_comm |
- | 67 | if var_type == "b": var_type = "byte" |
|
- | 68 | if var_type == "w": var_type = "word" |
|
- | 69 | if var_type == "d": var_type = "dword" |
|
60 | #print(f"Variable '{var_name}' at {line_idx + 1}") |
70 | if var_type == "q": var_type = "qword" |
61 | kernel_structure[asm_file_name][VARIABLES].append([ line_idx + 1, var_name ]) |
71 | kernel_structure[asm_file_name][VARIABLES].append([ line_idx + 1, var_name, var_type, var_init, var_comm ]) |
62 | line_idx += 1 |
72 | line_idx += 1 |
Line 63... | Line 73... | ||
63 | continue |
73 | continue |
64 | 74 | ||
Line 106... | Line 116... | ||
106 | continue |
116 | continue |
Line 107... | Line 117... | ||
107 | 117 | ||
Line 108... | Line 118... | ||
108 | line_idx += 1 |
118 | line_idx += 1 |
- | 119 | ||
109 | 120 | def handle_file(handled_files, asm_file_name, subdir = "."): |
|
110 | def handle_file(handled_files, asm_file_name, subdir = "."): |
121 | if dump_symbols: |
111 | print(f"Handling {asm_file_name}") |
122 | print(f"Handling {asm_file_name}") |
112 | handled_files.append(asm_file_name) |
123 | handled_files.append(asm_file_name) |
113 | try: |
124 | try: |
Line 168... | Line 179... | ||
168 | proc_count += len(kernel_structure[source][PROCEDURES]) |
179 | proc_count += len(kernel_structure[source][PROCEDURES]) |
169 | label_count += len(kernel_structure[source][LABELS]) |
180 | label_count += len(kernel_structure[source][LABELS]) |
170 | macro_count += len(kernel_structure[source][MACROS]) |
181 | macro_count += len(kernel_structure[source][MACROS]) |
171 | struct_count += len(kernel_structure[source][STRUCTURES]) |
182 | struct_count += len(kernel_structure[source][STRUCTURES]) |
Line -... | Line 183... | ||
- | 183 | ||
172 | 184 | print(f"File count: {len(kernel_structure)}") |
|
173 | print(f"Variable count: {var_count}") |
185 | print(f"Variable count: {var_count}") |
174 | print(f"Procedures count: {proc_count}") |
186 | print(f"Procedures count: {proc_count}") |
175 | print(f"Global labels count: {label_count}") |
187 | print(f"Global labels count: {label_count}") |
176 | print(f"Macroses count: {macro_count}") |
188 | print(f"Macroses count: {macro_count}") |
Line 177... | Line 189... | ||
177 | print(f"Structures count: {struct_count}") |
189 | print(f"Structures count: {struct_count}") |
Line 178... | Line 190... | ||
178 | 190 | ||
Line 179... | Line 191... | ||
179 | print(f"Writing doumented sources to {doxygen_src_path}") |
191 | print(f"Writing doumented sources to {doxygen_src_path}") |
180 | - | ||
181 | created_files = [] |
192 | |
182 | 193 | created_files = [] |
|
183 | def write_variable(source, line, name, type = "int", brief = "Undocumented", |
194 | |
184 | init = None): |
195 | def write_variable(source, line, name, type, init, brief): |
185 | source = source.replace("./", "") |
196 | source = source.replace("./", "") |
Line 200... | Line 211... | ||
200 | f.write(f" * @par Initial value\n") |
211 | f.write(f" * @par Initial value\n") |
201 | f.write(f" * {init}\n") |
212 | f.write(f" * {init}\n") |
202 | f.write(f" * @par Source\n") |
213 | f.write(f" * @par Source\n") |
203 | f.write(f" * {source}:{line}\n") |
214 | f.write(f" * {source}:{line}\n") |
204 | f.write(f" */\n") |
215 | f.write(f" */\n") |
205 | if init == None: |
- | |
206 | set_init = "" |
- | |
207 | else: |
- | |
208 | set_init = f" = {init}" |
- | |
209 | f.write(f"{type} {name}{set_init};\n\n") |
216 | f.write(f"{type} {name};\n\n") |
210 | f.close() |
217 | f.close() |
Line 211... | Line 218... | ||
211 | 218 | ||
212 | i = 1 |
219 | i = 1 |
213 | for source in kernel_structure: |
220 | for source in kernel_structure: |
214 | # Print progress: current/total |
221 | # Print progress: current/total |
215 | print(f"{i}/{len(kernel_structure)} Writing {source}") |
222 | print(f"{i}/{len(kernel_structure)} Writing {source}") |
216 | # Write variables doxygen of the source file |
223 | # Write variables doxygen of the source file |
217 | if len(kernel_structure[source][VARIABLES]) > 0: |
224 | if len(kernel_structure[source][VARIABLES]) > 0: |
218 | for variable in kernel_structure[source][VARIABLES]: |
225 | for variable in kernel_structure[source][VARIABLES]: |
219 | write_variable(source, variable[0], variable[1]) |
226 | write_variable(source, variable[0], variable[1], variable[2], variable[3], variable[4]) |