summaryrefslogtreecommitdiff
path: root/python/generator.cpp
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2025-12-12 01:31:16 -0500
committerGlenn Smith <glenn@vector35.com>2025-12-12 15:26:15 -0500
commit0238488101541494701887783104734147250961 (patch)
treee92cb4ea446d5edec92cd7dc94489c49185f0ff9 /python/generator.cpp
parent0344316931677147651727551529197967388655 (diff)
Generator: Fix <4 byte signed enums with negative members
Literally only affects InvalidILViewType
Diffstat (limited to 'python/generator.cpp')
-rw-r--r--python/generator.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/python/generator.cpp b/python/generator.cpp
index 45ca1e4a..50cfe073 100644
--- a/python/generator.cpp
+++ b/python/generator.cpp
@@ -384,7 +384,14 @@ int main(int argc, char* argv[])
fprintf(enums, "\n\nclass %s(enum.IntEnum):\n", name.c_str());
for (auto& j : i.second->GetEnumeration()->GetMembers())
{
- fprintf(enums, "\t%s = %" PRId32 "\n", j.name.c_str(), (int32_t)j.value);
+ if (i.second->IsSigned())
+ {
+ fprintf(enums, "\t%s = %" PRId64 "\n", j.name.c_str(), (int64_t)BNSignExtend(j.value, i.second->GetWidth(), 8));
+ }
+ else
+ {
+ fprintf(enums, "\t%s = %" PRIu64 "\n", j.name.c_str(), j.value);
+ }
}
}
else if ((i.second->GetClass() == BoolTypeClass) || (i.second->GetClass() == IntegerTypeClass)