mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-27 02:01:16 +00:00
refactor: address review comments
Not sure why VS Code suddenly decides to remove some empty spaces, but they don't make sense anyway
This commit is contained in:
parent
24275b460b
commit
59ed0b1aa9
@ -189,7 +189,7 @@ In order to keep the code clean and consistent, we use `pylint` and `black`:
|
|||||||
|
|
||||||
### Run pylint (ignores build and virtualenv)
|
### Run pylint (ignores build and virtualenv)
|
||||||
|
|
||||||
`pylint tools/`
|
`pylint tools/ --ignore=ncc`
|
||||||
|
|
||||||
### Check code formatting without rewriting files
|
### Check code formatting without rewriting files
|
||||||
|
|
||||||
|
|||||||
@ -119,7 +119,7 @@ def get_func_signature(self, fn: SymbolsEntry) -> Optional[FunctionSignature]:
|
|||||||
def get_function_list(self) -> list[tuple[MatchInfo, FunctionSignature]]:
|
def get_function_list(self) -> list[tuple[MatchInfo, FunctionSignature]]:
|
||||||
handled = (
|
handled = (
|
||||||
self.handle_matched_function(match)
|
self.handle_matched_function(match)
|
||||||
for match in self.compare.db.get_matches_by_type(SymbolType.FUNCTION)
|
for match in self.compare.get_functions()
|
||||||
)
|
)
|
||||||
return [signature for signature in handled if signature is not None]
|
return [signature for signature in handled if signature is not None]
|
||||||
|
|
||||||
|
|||||||
@ -214,11 +214,9 @@ class CvdumpTypesParser:
|
|||||||
|
|
||||||
LF_ENUM_ATTRIBUTES = [
|
LF_ENUM_ATTRIBUTES = [
|
||||||
re.compile(r"^\s*# members = (?P<num_members>\d+)$"),
|
re.compile(r"^\s*# members = (?P<num_members>\d+)$"),
|
||||||
re.compile(
|
|
||||||
r"^\s*type = (?P<underlying_type>\S+) field list type (?P<field_type>0x\w{4})$"
|
|
||||||
),
|
|
||||||
re.compile(r"^\s*enum name = (?P<name>.+)$"),
|
re.compile(r"^\s*enum name = (?P<name>.+)$"),
|
||||||
]
|
]
|
||||||
|
LF_ENUM_TYPES = re.compile(r"^\s*type = (?P<underlying_type>\S+) field list type (?P<field_type>0x\w{4})$")
|
||||||
LF_ENUM_UDT = re.compile(r"^\s*UDT\((?P<udt>0x\w+)\)$")
|
LF_ENUM_UDT = re.compile(r"^\s*UDT\((?P<udt>0x\w+)\)$")
|
||||||
LF_UNION_LINE = re.compile(
|
LF_UNION_LINE = re.compile(
|
||||||
r".*field list type (?P<field_type>0x\w+),.*Size = (?P<size>\d+)\s*,class name = (?P<name>(?:[^,]|,\S)+),\s.*UDT\((?P<udt>0x\w+)\)"
|
r".*field list type (?P<field_type>0x\w+),.*Size = (?P<size>\d+)\s*,class name = (?P<name>(?:[^,]|,\S)+),\s.*UDT\((?P<udt>0x\w+)\)"
|
||||||
@ -628,6 +626,7 @@ def read_enum_line(self, line: str):
|
|||||||
continue
|
continue
|
||||||
obj |= self.parse_enum_attribute(pair)
|
obj |= self.parse_enum_attribute(pair)
|
||||||
|
|
||||||
|
|
||||||
def parse_enum_attribute(self, attribute: str) -> dict[str, Any]:
|
def parse_enum_attribute(self, attribute: str) -> dict[str, Any]:
|
||||||
for attribute_regex in self.LF_ENUM_ATTRIBUTES:
|
for attribute_regex in self.LF_ENUM_ATTRIBUTES:
|
||||||
if (match := attribute_regex.match(attribute)) is not None:
|
if (match := attribute_regex.match(attribute)) is not None:
|
||||||
@ -640,6 +639,10 @@ def parse_enum_attribute(self, attribute: str) -> dict[str, Any]:
|
|||||||
match = self.LF_ENUM_UDT.match(attribute)
|
match = self.LF_ENUM_UDT.match(attribute)
|
||||||
assert match is not None
|
assert match is not None
|
||||||
return {"udt": normalize_type_id(match.group("udt"))}
|
return {"udt": normalize_type_id(match.group("udt"))}
|
||||||
|
if (match := self.LF_ENUM_TYPES.match(attribute)) is not None:
|
||||||
|
result = match.groupdict()
|
||||||
|
result["underlying_type"] = normalize_type_id(result["underlying_type"])
|
||||||
|
return result
|
||||||
logger.error("Unknown attribute in enum: %s", attribute)
|
logger.error("Unknown attribute in enum: %s", attribute)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|||||||
@ -47,16 +47,16 @@
|
|||||||
Element type = T_UCHAR(0020)
|
Element type = T_UCHAR(0020)
|
||||||
Index type = T_SHORT(0011)
|
Index type = T_SHORT(0011)
|
||||||
length = 8
|
length = 8
|
||||||
Name =
|
Name =
|
||||||
|
|
||||||
0x10ea : Length = 14, Leaf = 0x1503 LF_ARRAY
|
0x10ea : Length = 14, Leaf = 0x1503 LF_ARRAY
|
||||||
Element type = 0x1028
|
Element type = 0x1028
|
||||||
Index type = T_SHORT(0011)
|
Index type = T_SHORT(0011)
|
||||||
length = 12
|
length = 12
|
||||||
Name =
|
Name =
|
||||||
|
|
||||||
0x11f0 : Length = 30, Leaf = 0x1504 LF_CLASS
|
0x11f0 : Length = 30, Leaf = 0x1504 LF_CLASS
|
||||||
# members = 0, field list type 0x0000, FORWARD REF,
|
# members = 0, field list type 0x0000, FORWARD REF,
|
||||||
Derivation list type 0x0000, VT shape type 0x0000
|
Derivation list type 0x0000, VT shape type 0x0000
|
||||||
Size = 0, class name = MxRect32, UDT(0x00001214)
|
Size = 0, class name = MxRect32, UDT(0x00001214)
|
||||||
|
|
||||||
@ -98,22 +98,22 @@
|
|||||||
member name = 'm_bottom'
|
member name = 'm_bottom'
|
||||||
|
|
||||||
0x1214 : Length = 30, Leaf = 0x1504 LF_CLASS
|
0x1214 : Length = 30, Leaf = 0x1504 LF_CLASS
|
||||||
# members = 34, field list type 0x1213, CONSTRUCTOR, OVERLOAD,
|
# members = 34, field list type 0x1213, CONSTRUCTOR, OVERLOAD,
|
||||||
Derivation list type 0x0000, VT shape type 0x0000
|
Derivation list type 0x0000, VT shape type 0x0000
|
||||||
Size = 16, class name = MxRect32, UDT(0x00001214)
|
Size = 16, class name = MxRect32, UDT(0x00001214)
|
||||||
|
|
||||||
0x1220 : Length = 30, Leaf = 0x1504 LF_CLASS
|
0x1220 : Length = 30, Leaf = 0x1504 LF_CLASS
|
||||||
# members = 0, field list type 0x0000, FORWARD REF,
|
# members = 0, field list type 0x0000, FORWARD REF,
|
||||||
Derivation list type 0x0000, VT shape type 0x0000
|
Derivation list type 0x0000, VT shape type 0x0000
|
||||||
Size = 0, class name = MxCore, UDT(0x00004060)
|
Size = 0, class name = MxCore, UDT(0x00004060)
|
||||||
|
|
||||||
0x14db : Length = 30, Leaf = 0x1504 LF_CLASS
|
0x14db : Length = 30, Leaf = 0x1504 LF_CLASS
|
||||||
# members = 0, field list type 0x0000, FORWARD REF,
|
# members = 0, field list type 0x0000, FORWARD REF,
|
||||||
Derivation list type 0x0000, VT shape type 0x0000
|
Derivation list type 0x0000, VT shape type 0x0000
|
||||||
Size = 0, class name = MxString, UDT(0x00004db6)
|
Size = 0, class name = MxString, UDT(0x00004db6)
|
||||||
|
|
||||||
0x19b0 : Length = 34, Leaf = 0x1505 LF_STRUCTURE
|
0x19b0 : Length = 34, Leaf = 0x1505 LF_STRUCTURE
|
||||||
# members = 0, field list type 0x0000, FORWARD REF,
|
# members = 0, field list type 0x0000, FORWARD REF,
|
||||||
Derivation list type 0x0000, VT shape type 0x0000
|
Derivation list type 0x0000, VT shape type 0x0000
|
||||||
Size = 0, class name = ROIColorAlias, UDT(0x00002a76)
|
Size = 0, class name = ROIColorAlias, UDT(0x00002a76)
|
||||||
|
|
||||||
@ -136,18 +136,18 @@
|
|||||||
member name = 'm_unk0x10'
|
member name = 'm_unk0x10'
|
||||||
|
|
||||||
0x2a76 : Length = 34, Leaf = 0x1505 LF_STRUCTURE
|
0x2a76 : Length = 34, Leaf = 0x1505 LF_STRUCTURE
|
||||||
# members = 5, field list type 0x2a75,
|
# members = 5, field list type 0x2a75,
|
||||||
Derivation list type 0x0000, VT shape type 0x0000
|
Derivation list type 0x0000, VT shape type 0x0000
|
||||||
Size = 20, class name = ROIColorAlias, UDT(0x00002a76)
|
Size = 20, class name = ROIColorAlias, UDT(0x00002a76)
|
||||||
|
|
||||||
0x22d4 : Length = 154, Leaf = 0x1203 LF_FIELDLIST
|
0x22d4 : Length = 154, Leaf = 0x1203 LF_FIELDLIST
|
||||||
list[0] = LF_VFUNCTAB, type = 0x20FC
|
list[0] = LF_VFUNCTAB, type = 0x20FC
|
||||||
list[1] = LF_METHOD, count = 3, list = 0x22D0, name = 'MxVariable'
|
list[1] = LF_METHOD, count = 3, list = 0x22D0, name = 'MxVariable'
|
||||||
list[2] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x1F0F,
|
list[2] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x1F0F,
|
||||||
vfptr offset = 0, name = 'GetValue'
|
vfptr offset = 0, name = 'GetValue'
|
||||||
list[3] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x1F10,
|
list[3] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x1F10,
|
||||||
vfptr offset = 4, name = 'SetValue'
|
vfptr offset = 4, name = 'SetValue'
|
||||||
list[4] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x1F11,
|
list[4] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x1F11,
|
||||||
vfptr offset = 8, name = '~MxVariable'
|
vfptr offset = 8, name = '~MxVariable'
|
||||||
list[5] = LF_ONEMETHOD, public, VANILLA, index = 0x22D3, name = 'GetKey'
|
list[5] = LF_ONEMETHOD, public, VANILLA, index = 0x22D3, name = 'GetKey'
|
||||||
list[6] = LF_MEMBER, protected, type = 0x14DB, offset = 4
|
list[6] = LF_MEMBER, protected, type = 0x14DB, offset = 4
|
||||||
@ -156,7 +156,7 @@
|
|||||||
member name = 'm_value'
|
member name = 'm_value'
|
||||||
|
|
||||||
0x22d5 : Length = 34, Leaf = 0x1504 LF_CLASS
|
0x22d5 : Length = 34, Leaf = 0x1504 LF_CLASS
|
||||||
# members = 10, field list type 0x22d4, CONSTRUCTOR,
|
# members = 10, field list type 0x22d4, CONSTRUCTOR,
|
||||||
Derivation list type 0x0000, VT shape type 0x20fb
|
Derivation list type 0x0000, VT shape type 0x20fb
|
||||||
Size = 36, class name = MxVariable, UDT(0x00004041)
|
Size = 36, class name = MxVariable, UDT(0x00004041)
|
||||||
|
|
||||||
@ -171,22 +171,22 @@
|
|||||||
0x405f : Length = 158, Leaf = 0x1203 LF_FIELDLIST
|
0x405f : Length = 158, Leaf = 0x1203 LF_FIELDLIST
|
||||||
list[0] = LF_VFUNCTAB, type = 0x2090
|
list[0] = LF_VFUNCTAB, type = 0x2090
|
||||||
list[1] = LF_ONEMETHOD, public, VANILLA, index = 0x176A, name = 'MxCore'
|
list[1] = LF_ONEMETHOD, public, VANILLA, index = 0x176A, name = 'MxCore'
|
||||||
list[2] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x176A,
|
list[2] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x176A,
|
||||||
vfptr offset = 0, name = '~MxCore'
|
vfptr offset = 0, name = '~MxCore'
|
||||||
list[3] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x176B,
|
list[3] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x176B,
|
||||||
vfptr offset = 4, name = 'Notify'
|
vfptr offset = 4, name = 'Notify'
|
||||||
list[4] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x2087,
|
list[4] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x2087,
|
||||||
vfptr offset = 8, name = 'Tickle'
|
vfptr offset = 8, name = 'Tickle'
|
||||||
list[5] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x202F,
|
list[5] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x202F,
|
||||||
vfptr offset = 12, name = 'ClassName'
|
vfptr offset = 12, name = 'ClassName'
|
||||||
list[6] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x2030,
|
list[6] = LF_ONEMETHOD, public, INTRODUCING VIRTUAL, index = 0x2030,
|
||||||
vfptr offset = 16, name = 'IsA'
|
vfptr offset = 16, name = 'IsA'
|
||||||
list[7] = LF_ONEMETHOD, public, VANILLA, index = 0x2091, name = 'GetId'
|
list[7] = LF_ONEMETHOD, public, VANILLA, index = 0x2091, name = 'GetId'
|
||||||
list[8] = LF_MEMBER, private, type = T_UINT4(0075), offset = 4
|
list[8] = LF_MEMBER, private, type = T_UINT4(0075), offset = 4
|
||||||
member name = 'm_id'
|
member name = 'm_id'
|
||||||
|
|
||||||
0x4060 : Length = 30, Leaf = 0x1504 LF_CLASS
|
0x4060 : Length = 30, Leaf = 0x1504 LF_CLASS
|
||||||
# members = 9, field list type 0x405f, CONSTRUCTOR,
|
# members = 9, field list type 0x405f, CONSTRUCTOR,
|
||||||
Derivation list type 0x0000, VT shape type 0x1266
|
Derivation list type 0x0000, VT shape type 0x1266
|
||||||
Size = 8, class name = MxCore, UDT(0x00004060)
|
Size = 8, class name = MxCore, UDT(0x00004060)
|
||||||
|
|
||||||
@ -194,7 +194,7 @@
|
|||||||
Element type = 0x3CC2
|
Element type = 0x3CC2
|
||||||
Index type = T_SHORT(0011)
|
Index type = T_SHORT(0011)
|
||||||
length = 24
|
length = 24
|
||||||
Name =
|
Name =
|
||||||
|
|
||||||
0x432f : Length = 14, Leaf = 0x1503 LF_ARRAY
|
0x432f : Length = 14, Leaf = 0x1503 LF_ARRAY
|
||||||
Element type = T_INT4(0074)
|
Element type = T_INT4(0074)
|
||||||
@ -220,7 +220,7 @@
|
|||||||
member name = 'm_length'
|
member name = 'm_length'
|
||||||
|
|
||||||
0x4db6 : Length = 30, Leaf = 0x1504 LF_CLASS
|
0x4db6 : Length = 30, Leaf = 0x1504 LF_CLASS
|
||||||
# members = 16, field list type 0x4db5, CONSTRUCTOR, OVERLOAD,
|
# members = 16, field list type 0x4db5, CONSTRUCTOR, OVERLOAD,
|
||||||
Derivation list type 0x0000, VT shape type 0x1266
|
Derivation list type 0x0000, VT shape type 0x1266
|
||||||
Size = 16, class name = MxString, UDT(0x00004db6)
|
Size = 16, class name = MxString, UDT(0x00004db6)
|
||||||
"""
|
"""
|
||||||
@ -374,7 +374,7 @@ def test_2d_array(parser):
|
|||||||
def test_enum(parser):
|
def test_enum(parser):
|
||||||
"""LF_ENUM should equal 4-byte int"""
|
"""LF_ENUM should equal 4-byte int"""
|
||||||
assert parser.get("0x3cc2").size == 4
|
assert parser.get("0x3cc2").size == 4
|
||||||
assert parser.get_scalars("0x3cc2") == [(0, None, "T_INT4(0074)")]
|
assert parser.get_scalars("0x3cc2") == [(0, None, "T_INT4")]
|
||||||
|
|
||||||
# Now look at an array of enum, 24 bytes
|
# Now look at an array of enum, 24 bytes
|
||||||
enum_array = parser.get_scalars("0x4262")
|
enum_array = parser.get_scalars("0x4262")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user