From 290bbcf333679ffa057d57d1b540608e3bec8ada Mon Sep 17 00:00:00 2001 From: Mark Rowe Date: Thu, 17 Jul 2025 11:32:16 -0700 Subject: 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. --- python/pluginmanager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python/pluginmanager.py') diff --git a/python/pluginmanager.py b/python/pluginmanager.py index 62066397..75f7bfe2 100644 --- a/python/pluginmanager.py +++ b/python/pluginmanager.py @@ -34,7 +34,7 @@ class RepoPlugin: ``RepoPlugin`` is mostly read-only, however you can install/uninstall enable/disable plugins. RepoPlugins are created by parsing the plugins.json in a plugin repository. """ - def __init__(self, handle: core.BNRepoPluginHandle): + def __init__(self, handle: 'core.BNRepoPluginHandle'): self.handle = handle def __del__(self): -- cgit v1.3.1