summaryrefslogtreecommitdiff
path: root/python/mediumlevelil.py
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2025-07-17 11:32:16 -0700
committerMark Rowe <mark@vector35.com>2025-12-11 21:09:38 -0800
commit290bbcf333679ffa057d57d1b540608e3bec8ada (patch)
treef8c576eed0fdde52735e4555dfce3dbd7e692f1d /python/mediumlevelil.py
parente902d25c22f2bf1426d2619933587ace06a38921 (diff)
Specify fixed underlying types for enums exposed by core
This allows a few widely-used enums to be shrunk from 4 bytes to 1 byte, improving packing when they're used as struct members. To remain compatible with C, we follow CoreFoundation's approach and use a macro when defining the enum: ``` #if defined(__cplusplus) || __has_extension(c_fixed_enum) #define BN_ENUM(type, name) enum name : type #else #define BN_ENUM(type, name) typedef type name; enum #endif BN_ENUM(uint8_t, SomeEnum) { ... } ``` In C++ and C23 this will expand to an enum with a fixed underlying type. In older C language versions, this will result in the enum type being a typedef of the underlying type, with an unnamed enum providing the enum values. Minor changes were needed within the Python bindings to update places that made assumptions about the underlying type of the enums.
Diffstat (limited to 'python/mediumlevelil.py')
-rw-r--r--python/mediumlevelil.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/python/mediumlevelil.py b/python/mediumlevelil.py
index 61c0bf1b..a38ec0ea 100644
--- a/python/mediumlevelil.py
+++ b/python/mediumlevelil.py
@@ -822,7 +822,7 @@ class MediumLevelILInstruction(BaseILInstruction):
if options is None:
options = []
idx = 0
- option_array = (ctypes.c_int * len(options))()
+ option_array = (core.DataFlowQueryOptionEnum * len(options))()
for option in options:
option_array[idx] = option
idx += 1