From 0238488101541494701887783104734147250961 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Fri, 12 Dec 2025 01:31:16 -0500 Subject: Generator: Fix <4 byte signed enums with negative members Literally only affects InvalidILViewType --- python/generator.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'python/generator.cpp') 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) -- cgit v1.3.1