Cleanup: Create/use types for generic WM callbacks

Makes it less of a hassle to pass these callbacks around as function
arguments, and deduplicates their signature when doing so.
This commit is contained in:
Julian Eisel 2021-04-21 15:01:18 +02:00
parent 2e3f072d5d
commit 0b458e8322
1 changed files with 7 additions and 3 deletions

View File

@ -132,17 +132,21 @@ struct wmWindowManager;
extern "C" {
#endif
typedef void (*wmGenericUserDataFreeFn)(void *data);
typedef struct wmGenericUserData {
void *data;
/** When NULL, use #MEM_freeN. */
void (*free_fn)(void *data);
wmGenericUserDataFreeFn free_fn;
bool use_free;
} wmGenericUserData;
typedef void (*wmGenericCallbackFn)(struct bContext *C, void *user_data);
typedef struct wmGenericCallback {
void (*exec)(struct bContext *C, void *user_data);
wmGenericCallbackFn exec;
void *user_data;
void (*free_user_data)(void *user_data);
wmGenericUserDataFreeFn free_user_data;
} wmGenericCallback;
/* ************** wmOperatorType ************************ */