mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-05-23 06:34:18 -04:00
Updating decompctx script for Python 3.8 compatability
This commit is contained in:
+8
-7
@@ -8,6 +8,7 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
import typing
|
||||
import argparse
|
||||
import pyperclip
|
||||
from glob import glob
|
||||
@@ -42,14 +43,14 @@ cast_patterns = re.compile(r"\(int\)")
|
||||
#endregion
|
||||
|
||||
#region Defaults
|
||||
default_defines: dict[str, str] = {"__MWERKS__" : "1", "_LANGUAGE_C": "1", "F3DEX_GBI_2": "1"}
|
||||
default_defines: typing.Dict[str, str] = {"__MWERKS__" : "1", "_LANGUAGE_C": "1", "F3DEX_GBI_2": "1"}
|
||||
|
||||
src_dir = "src"
|
||||
include_dir = "include"
|
||||
cwd_dir = os.getcwd()
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
root_dir = os.path.abspath(os.path.join(script_dir, ".."))
|
||||
default_include_directories: list[str] = [
|
||||
default_include_directories: typing.List[str] = [
|
||||
os.path.join(root_dir, src_dir),
|
||||
os.path.join(root_dir, include_dir),
|
||||
os.path.join(script_dir, src_dir),
|
||||
@@ -231,7 +232,7 @@ def replace_enums_with_numeric_values(text_to_strip: str)->str:
|
||||
return text_to_strip
|
||||
|
||||
preprocessor = Preprocessor()
|
||||
enum_to_numeric_dict : dict[str, int] = {}
|
||||
enum_to_numeric_dict : typing.Dict[str, int] = {}
|
||||
for enum_declaration in enum_declarations:
|
||||
enum_members = enum_declaration[1]
|
||||
split_enum_members = enum_members.split(",")
|
||||
@@ -304,7 +305,7 @@ def replace_enums_with_numeric_values(text_to_strip: str)->str:
|
||||
#endregion
|
||||
|
||||
#region Preprocessing
|
||||
def generate_context(preprocessor_arguments: list[str], context_options: ContextGenerationOptions)->str:
|
||||
def generate_context(preprocessor_arguments: typing.List[str], context_options: ContextGenerationOptions)->str:
|
||||
# Create the temp string writer to pass to the preprocessor since we still want to modify
|
||||
# the contents for project-specific conditions
|
||||
with StringIO() as preprocessor_string_writer:
|
||||
@@ -400,7 +401,7 @@ def main():
|
||||
return
|
||||
|
||||
# Append in the default include directories
|
||||
include_directories: list[str] = []
|
||||
include_directories: typing.List[str] = []
|
||||
include_directories.extend(default_include_directories)
|
||||
n64_sdk = get_n64_sdk(known_args.n64_sdk)
|
||||
if n64_sdk:
|
||||
@@ -411,7 +412,7 @@ def main():
|
||||
|
||||
# Check if we have any passed in defines
|
||||
include_defines = []
|
||||
known_defines: list[str] = []
|
||||
known_defines: typing.List[str] = []
|
||||
if known_args.defines:
|
||||
argument_defines = [x[0] for x in known_args.defines]
|
||||
for define in argument_defines:
|
||||
@@ -421,7 +422,7 @@ def main():
|
||||
if not known_args.c_file:
|
||||
# If not file is specified it is assumed we want to create a mega context
|
||||
# file that is the aggregate of all include files
|
||||
include_files : set[str, str] = set()
|
||||
include_files : typing.Set[str, str] = set()
|
||||
for include_directory in default_include_directories:
|
||||
files = [y for x in os.walk(include_directory) for y in glob(os.path.join(x[0], '*.h'))]
|
||||
for include_file in files:
|
||||
|
||||
+1
-1
@@ -178,7 +178,7 @@ def gather_symbols_for_section(address_offset: int, file_reader:TextIOWrapper, s
|
||||
section.symbols.append(symbol)
|
||||
|
||||
def gather_tu_symbols(tu_name: str, map_path: str)->typing.Dict[str, SliceInfo]:
|
||||
gathered_symbols: dict[str, SliceInfo] = {}
|
||||
gathered_symbols: typing.Dict[str, SliceInfo] = {}
|
||||
tu_regex = re.compile(specific_tu_pattern_format.format(tu_name = tu_name))
|
||||
|
||||
with open(map_path, "r", encoding="utf-8", newline="\n") as file_reader:
|
||||
|
||||
Reference in New Issue
Block a user