From 9397116241069777614336493120489779020689 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Fri, 12 Dec 2025 02:14:32 -0500 Subject: Generator: Detect flag enums and use IntFlag instead Made possible by the new attributes in binja's type system. --- python/generator.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/python/generator.cpp b/python/generator.cpp index 50cfe073..96b74d90 100644 --- a/python/generator.cpp +++ b/python/generator.cpp @@ -381,7 +381,11 @@ int main(int argc, char* argv[]) } fprintf(out, "%sEnum = %s\n", name.c_str(), ctypesType); - fprintf(enums, "\n\nclass %s(enum.IntEnum):\n", name.c_str()); + if (i.second->GetAttribute("options").has_value()) + fprintf(enums, "\n\nclass %s(enum.IntFlag):\n", name.c_str()); + else + fprintf(enums, "\n\nclass %s(enum.IntEnum):\n", name.c_str()); + for (auto& j : i.second->GetEnumeration()->GetMembers()) { if (i.second->IsSigned()) -- cgit v1.3.1