summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorGlenn Smith <glenn@vector35.com>2025-12-12 02:14:32 -0500
committerGlenn Smith <glenn@vector35.com>2025-12-12 15:26:24 -0500
commit9397116241069777614336493120489779020689 (patch)
tree15820c2f83ba8763680c153157c3ce680d1c617d /python
parent0238488101541494701887783104734147250961 (diff)
Generator: Detect flag enums and use IntFlag instead
Made possible by the new attributes in binja's type system.
Diffstat (limited to 'python')
-rw-r--r--python/generator.cpp6
1 files changed, 5 insertions, 1 deletions
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())