diff options
author | Sybren A. Stüvel <sybren@blender.org> | 2020-10-02 19:56:25 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@blender.org> | 2020-10-02 19:56:25 +0300 |
commit | 90a27d5aa91a1b6a25ea14e11c889d47f77f4cf7 (patch) | |
tree | 3916b5139f9e48ca543a1f017f82b62101dd717a /source/blender/editors/space_image | |
parent | 0db98b214d468864630fc9bba72be4ff9b2548e5 (diff) |
Cleanup: Use enum for return values in context callbacks
Define enum `eContextResult` and use its values for returns, instead of
just returning 1, 0, or -1 (and always having some comment that explains
what -1 means).
This also cleans up the mixup between returning `0` and `false`, and `1`
and `true`. An inconsistency was discovered during this cleanup, and
marked with `TODO(sybren)`. It's not fixed here, as it would consititute
a functional change.
The enum isn't used everywhere, as enums in C and C++ can have different
storage sizes. To prevent issues, callback functions are still declared
as returning`int`. To at least make things easier to understand for
humans, I marked those with `int /*eContextResult*/`.
This is a followup of D9090, and is intended to unify how context
callbacks return values. This will make it easier to extend the approach
in D9090 to those functions.
No functional changes.
Differential Revision: https://developer.blender.org/D9095
Diffstat (limited to 'source/blender/editors/space_image')
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index 1d23a409748..510c638d227 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -442,25 +442,28 @@ static void image_listener(wmWindow *win, ScrArea *area, wmNotifier *wmn, Scene const char *image_context_dir[] = {"edit_image", "edit_mask", NULL}; -static int image_context(const bContext *C, const char *member, bContextDataResult *result) +static int /*eContextResult*/ image_context(const bContext *C, + const char *member, + bContextDataResult *result) { SpaceImage *sima = CTX_wm_space_image(C); if (CTX_data_dir(member)) { CTX_data_dir_set(result, image_context_dir); + /* TODO(sybren): return CTX_RESULT_OK; */ } else if (CTX_data_equals(member, "edit_image")) { CTX_data_id_pointer_set(result, (ID *)ED_space_image(sima)); - return 1; + return CTX_RESULT_OK; } else if (CTX_data_equals(member, "edit_mask")) { Mask *mask = ED_space_image_get_mask(sima); if (mask) { CTX_data_id_pointer_set(result, &mask->id); } - return true; + return CTX_RESULT_OK; } - return 0; + return CTX_RESULT_MEMBER_NOT_FOUND; } static void IMAGE_GGT_gizmo2d(wmGizmoGroupType *gzgt) |