Bug 1345074 - Add MOZ_FOR_EACH_SEPARATED which adds separator between items. r=Waldo

MozReview-Commit-ID: IWqs17MLhHD

--HG--
extra : rebase_source : adc004b185501c9fe8109589fb671cd5a6551002
This commit is contained in:
Xidorn Quan 2017-03-07 22:28:49 +11:00
Родитель cfa1d7f8bc
Коммит b7ebe87cdc
3 изменённых файлов: 181 добавлений и 104 удалений

Просмотреть файл

@ -1215,12 +1215,12 @@ nsStyleContext::CalcStyleDifferenceInternal(StyleContextLike* aNewContext,
// |thisVis| (including this function if we skip one of these checks
// due to change being true already or due to the old style context
// not having a style-if-visited), but not the other way around.
#define STYLE_FIELD(name_) thisVisStruct->name_ != otherVisStruct->name_ ||
#define STYLE_FIELD(name_) thisVisStruct->name_ != otherVisStruct->name_
#define STYLE_STRUCT(name_, fields_) \
if (!change && PeekStyle##name_()) { \
const nsStyle##name_* thisVisStruct = thisVis->Style##name_(); \
const nsStyle##name_* otherVisStruct = otherVis->Style##name_(); \
if (MOZ_FOR_EACH(STYLE_FIELD, (), fields_) false) { \
if (MOZ_FOR_EACH_SEPARATED(STYLE_FIELD, (||), (), fields_)) { \
change = true; \
} \
}

Просмотреть файл

@ -34,6 +34,20 @@
* int c = MOZ_FOR_EACH(MACRO_C, (5, 8,), (1, 2)) 0;
* // Expands to: MACRO_B(5, 8, 1) MACRO_B(5, 8, 2) 0;
*
* MOZ_FOR_EACH_SEPARATED(aMacro, aSeparator, aFixedArgs, aArgs) is identical
* to MOZ_FOR_EACH except that it inserts |aSeparator| between each call to
* the macro. |aSeparator| must be wrapped by parens. For example:
*
* #define MACRO_A(x) x
* int a = MOZ_FOR_EACH_SEPARATED(MACRO_A, (+), (), (1, 2, 3));
* // Expands to: MACRO_A(1) + MACRO_A(2) + MACRO_A(3);
* // And further to: 1 + 2 + 3
*
* #define MACRO_B(t, n) t n
* void test(MOZ_FOR_EACH_SEPARATED(MACRO_B, (,), (int,), (a, b)));
* // Expands to: void test(MACRO_B(int, a) , MACRO_B(int, b));
* // And further to: void test(int a , int b);
*
* If the |aFixedArgs| list is not empty, a trailing comma must be included.
*
* The |aArgs| list must be not be empty and may be up to 50 items long. Use
@ -42,11 +56,13 @@
*/
#define MOZ_FOR_EACH_EXPAND_HELPER(...) __VA_ARGS__
#define MOZ_FOR_EACH_GLUE(a, b) a b
#define MOZ_FOR_EACH(aMacro, aFixedArgs, aArgs) \
#define MOZ_FOR_EACH_SEPARATED(aMacro, aSeparator, aFixedArgs, aArgs) \
MOZ_FOR_EACH_GLUE( \
MOZ_PASTE_PREFIX_AND_ARG_COUNT(MOZ_FOR_EACH_, \
MOZ_FOR_EACH_EXPAND_HELPER aArgs), \
(aMacro, aFixedArgs, aArgs))
(aMacro, aSeparator, aFixedArgs, aArgs))
#define MOZ_FOR_EACH(aMacro, aFixedArgs, aArgs) \
MOZ_FOR_EACH_SEPARATED(aMacro, (), aFixedArgs, aArgs)
#define MOZ_FOR_EACH_HELPER_GLUE(a, b) a b
#define MOZ_FOR_EACH_HELPER(aMacro, aFixedArgs, aArgs) \
@ -54,105 +70,154 @@
aMacro, \
(MOZ_FOR_EACH_EXPAND_HELPER aFixedArgs MOZ_ARG_1 aArgs))
#define MOZ_FOR_EACH_1(m, fa, a) \
#define MOZ_FOR_EACH_1(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a)
#define MOZ_FOR_EACH_2(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_1(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_3(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_2(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_4(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_3(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_5(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_4(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_6(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_5(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_7(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_6(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_8(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_7(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_9(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_8(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_10(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_9(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_11(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_10(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_12(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_11(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_13(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_12(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_14(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_13(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_15(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_14(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_16(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_15(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_17(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_16(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_18(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_17(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_19(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_18(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_20(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_19(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_21(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_20(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_22(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_21(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_23(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_22(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_24(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_23(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_25(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_24(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_26(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_25(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_27(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_26(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_28(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_27(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_29(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_28(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_30(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_29(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_31(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_30(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_32(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_31(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_33(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_32(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_34(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_33(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_35(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_34(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_36(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_35(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_37(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_36(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_38(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_37(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_39(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_38(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_40(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_39(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_41(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_40(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_42(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_41(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_43(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_42(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_44(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_43(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_45(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_44(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_46(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_45(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_47(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_46(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_48(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_47(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_49(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_48(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_50(m, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_49(m, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_2(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_1(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_3(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_2(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_4(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_3(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_5(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_4(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_6(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_5(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_7(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_6(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_8(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_7(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_9(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_8(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_10(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_9(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_11(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_10(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_12(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_11(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_13(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_12(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_14(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_13(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_15(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_14(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_16(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_15(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_17(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_16(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_18(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_17(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_19(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_18(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_20(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_19(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_21(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_20(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_22(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_21(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_23(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_22(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_24(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_23(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_25(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_24(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_26(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_25(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_27(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_26(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_28(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_27(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_29(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_28(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_30(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_29(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_31(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_30(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_32(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_31(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_33(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_32(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_34(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_33(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_35(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_34(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_36(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_35(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_37(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_36(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_38(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_37(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_39(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_38(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_40(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_39(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_41(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_40(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_42(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_41(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_43(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_42(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_44(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_43(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_45(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_44(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_46(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_45(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_47(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_46(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_48(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_47(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_49(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_48(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#define MOZ_FOR_EACH_50(m, s, fa, a) \
MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_EXPAND_HELPER s \
MOZ_FOR_EACH_49(m, s, fa, (MOZ_ARGS_AFTER_1 a))
#endif /* mozilla_MacroForEach_h */

Просмотреть файл

@ -7,9 +7,14 @@
#include "mozilla/Assertions.h"
#include "mozilla/MacroForEach.h"
#define HELPER_IDENTITY(x) x
#define HELPER_IDENTITY_PLUS(x) x +
static_assert(MOZ_FOR_EACH(HELPER_IDENTITY_PLUS, (), (10)) 0 == 10, "");
static_assert(MOZ_FOR_EACH(HELPER_IDENTITY_PLUS, (), (1, 1, 1)) 0 == 3, "");
static_assert(MOZ_FOR_EACH_SEPARATED(HELPER_IDENTITY, (+),
(), (10)) == 10, "");
static_assert(MOZ_FOR_EACH_SEPARATED(HELPER_IDENTITY, (+),
(), (1, 1, 1)) == 3, "");
#define HELPER_DEFINE_VAR(x) const int test1_##x = x;
MOZ_FOR_EACH(HELPER_DEFINE_VAR, (), (10, 20))
@ -19,11 +24,18 @@ static_assert(test1_10 == 10 && test1_20 == 20, "");
MOZ_FOR_EACH(HELPER_DEFINE_VAR2, (5,), (10, 20))
static_assert(test2_10 == 15 && test2_20 == 25, "");
#define HELPER_IDENTITY_COMMA(k1, k2, x) k1, k2, x,
#define HELPER_DEFINE_PARAM(t, n) t n
constexpr int
test(MOZ_FOR_EACH_SEPARATED(HELPER_DEFINE_PARAM, (,), (int,), (a, b, c)))
{
return a + b + c;
}
static_assert(test(1, 2, 3) == 6, "");
int
main()
{
#define HELPER_IDENTITY_COMMA(k1, k2, x) k1, k2, x,
const int a[] = {
MOZ_FOR_EACH(HELPER_IDENTITY_COMMA, (1, 2,), (10, 20, 30))
};