Page MenuHome

Cleanup: Use enum for return values in context callbacks
ClosedPublic

Authored by Sybren A. Stüvel (sybren) on Oct 2 2020, 5:29 PM.

Details

Summary

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*/.

No functional changes.

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.

Diff Detail

Repository
rB Blender