diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-08-05 02:04:57 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-08-05 02:06:19 +0400 |
commit | 6b6ea0485f3fee08f87af80caf8f7d3a2b3792cb (patch) | |
tree | 821817b13ddcd4f36b8106487b5fc7c532a364b4 | |
parent | e4a13e40eb39cb35934132ffd9183869a8d8abc5 (diff) |
Macros: replace UNPACK#OP -> UNPACK#_EX, allow suffix
-rw-r--r-- | source/blender/blenlib/BLI_utildefines.h | 14 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_regions.c | 4 |
2 files changed, 9 insertions, 9 deletions
diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index 6a9eb64a686..683b3c4c438 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -379,13 +379,13 @@ #define IN_RANGE_INCL(a, b, c) ((b < c) ? ((b <= a && a <= c) ? 1 : 0) : ((c <= a && a <= b) ? 1 : 0)) /* unpack vector for args */ -#define UNPACK2(a) ((a)[0]), ((a)[1]) -#define UNPACK3(a) ((a)[0]), ((a)[1]), ((a)[2]) -#define UNPACK4(a) ((a)[0]), ((a)[1]), ((a)[2]), ((a)[3]) -/* op may be '&' or '*' */ -#define UNPACK2OP(op, a) op((a)[0]), op((a)[1]) -#define UNPACK3OP(op, a) op((a)[0]), op((a)[1]), op((a)[2]) -#define UNPACK4OP(op, a) op((a)[0]), op((a)[1]), op((a)[2]), op((a)[3]) +#define UNPACK2(a) ((a)[0]), ((a)[1]) +#define UNPACK3(a) UNPACK2(a), ((a)[2]) +#define UNPACK4(a) UNPACK3(a), ((a)[3]) +/* pre may be '&', '*' or func, post may be '->member' */ +#define UNPACK2_EX(pre, a, post) (pre((a)[0])post), (pre((a)[1])post) +#define UNPACK3_EX(pre, a, post) UNPACK2_EX(pre, a, post), (pre((a)[2])post) +#define UNPACK4_EX(pre, a, post) UNPACK3_EX(pre, a, post), (pre((a)[3])post) /* array helpers */ #define ARRAY_LAST_ITEM(arr_start, arr_dtype, tot) \ diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 32fb684f2b6..3629c72ce49 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1872,7 +1872,7 @@ static void ui_update_block_buts_rgb(uiBlock *block, const float rgb[3], bool is if (rgb_gamma[2] > 1.0f) rgb_gamma[2] = modf(rgb_gamma[2], &intpart); rgb_float_to_uchar(rgb_gamma_uchar, rgb_gamma); - BLI_snprintf(col, sizeof(col), "%02X%02X%02X", UNPACK3OP((unsigned int), rgb_gamma_uchar)); + BLI_snprintf(col, sizeof(col), "%02X%02X%02X", UNPACK3_EX((unsigned int), rgb_gamma_uchar, )); strcpy(bt->poin, col); } @@ -2160,7 +2160,7 @@ static void uiBlockPicker(uiBlock *block, float rgba[4], PointerRNA *ptr, Proper } rgb_float_to_uchar(rgb_gamma_uchar, rgb_gamma); - BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", UNPACK3OP((unsigned int), rgb_gamma_uchar)); + BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", UNPACK3_EX((unsigned int), rgb_gamma_uchar, )); yco = -3.0f * UI_UNIT_Y; bt = uiDefBut(block, TEX, 0, IFACE_("Hex: "), 0, yco, butwidth, UI_UNIT_Y, hexcol, 0, 8, 0, 0, TIP_("Hex triplet for color (#RRGGBB)")); |