Skip to content

Conversation

@jwaxy
Copy link

@jwaxy jwaxy commented Nov 8, 2025

This pull request renames bit_setify to bit_setify_enum and implements a new feature "bit_setify_macro". Closes #85

Here's an example on it's usage:

bindgen.sjson:

inputs = [
    "."
]

rename = {
    "NX_Flags": "InitFlags"
}

bit_setify_macro = {
    "NX_Flags": {
        "member_prefix": "NX_FLAG_",
        "new_enum_name": "InitFlag"
    }
}

C header file:

#include <stdint.h>

typedef uint64_t NX_Flags;

#define NX_FLAG_VSYNC_HINT              (1 <<  0)  ///< Enable vertical synchronization hint
#define NX_FLAG_FULLSCREEN              (1 <<  1)  ///< Create window in fullscreen mode
#define NX_FLAG_WINDOW_OCCLUDED         (1 <<  2)  ///< Window is occluded by other windows
#define NX_FLAG_WINDOW_HIDDEN           (1 <<  3)  ///< Create window initially hidden
#define NX_FLAG_WINDOW_BORDERLESS       (1 <<  4)  ///< Create borderless window
#define NX_FLAG_WINDOW_RESIZABLE        (1 <<  5)  ///< Window can be resized by user

Resulting Odin file:

package test

InitFlag :: enum {
	VSYNC_HINT        = 0,
	FULLSCREEN        = 1,
	WINDOW_OCCLUDED   = 2,
	WINDOW_HIDDEN     = 3,
	WINDOW_BORDERLESS = 4,
	WINDOW_RESIZABLE  = 5,
}

InitFlags :: bit_set[InitFlag; u64]

I'm open for suggestions regarding code refactoring, renaming or other changes.

@karl-zylinski
Copy link
Owner

Thank you. I will review this sometime soon. I'm a bit swamped and also sick right now, hehe

@jwaxy
Copy link
Author

jwaxy commented Nov 15, 2025

No worries, get well soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: Bit-setify macros

2 participants