diff options
author | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-09 06:51:41 -0800 |
---|---|---|
committer | olpc user <olpc@xo-5d-f7-86.localdomain> | 2019-12-09 06:51:41 -0800 |
commit | e6f2b95fb543b535b1914bd4954e240dbd724275 (patch) | |
tree | dcd081c1098489bc5c2172e5e535abb56094e763 /starts/meaning-vm/level-0 | |
parent | 8ceeb5f83f22ed3db06fc02bb23710ccc1dbbb90 (diff) | |
download | standingwithresilience-e6f2b95fb543b535b1914bd4954e240dbd724275.tar.gz standingwithresilience-e6f2b95fb543b535b1914bd4954e240dbd724275.zip |
positional argument sugar for habits
Diffstat (limited to 'starts/meaning-vm/level-0')
-rw-r--r-- | starts/meaning-vm/level-0/common.hpp | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/starts/meaning-vm/level-0/common.hpp b/starts/meaning-vm/level-0/common.hpp index e06e478..d75229d 100644 --- a/starts/meaning-vm/level-0/common.hpp +++ b/starts/meaning-vm/level-0/common.hpp @@ -2,24 +2,48 @@ #define self (*this) +// macro tools +#define _macro_expand_to_args(...) __VA_ARGS__ +#define _macro_expand_to_comma_args(...) ,##__VA_ARGS__ +#define _macro_call(funcormacro, ...) funcormacro(__VA_ARGS__) +#define _macro_remove_parens(args) _macro_expand_to_args args +#define _macro_comma_remove_parens(args) _macro_expand_to_comma_args args + +#define _macro_expand_to_arg1(arg, ...) arg +#define _macro_expand_to_arg2(_1, arg, ...) arg + // macro argument iteration, from stackoverflow.com/questions/1872220 #define _macro_for_each(funcormacro,...) \ - _macro_fe_get(__VA_ARGS__, \ + _macro_fe_get(_0,##__VA_ARGS__, \ _macro_fe_9,_macro_fe_8,_macro_fe_7,_macro_fe_6,_macro_fe_5,_macro_fe_4,_macro_fe_3,_macro_fe_2,_macro_fe_1,_macro_fe_0 \ )(funcormacro,__VA_ARGS__) - #define _macro_fe_0(what, x, ...) what(x) - #define _macro_fe_1(what, x, ...) what(x)fe_0(what, __VA_ARGS__) - #define _macro_fe_2(what, x, ...) what(x)fe_1(what, __VA_ARGS__) - #define _macro_fe_3(what, x, ...) what(x)fe_2(what, __VA_ARGS__) - #define _macro_fe_4(what, x, ...) what(x)fe_3(what, __VA_ARGS__) - #define _macro_fe_5(what, x, ...) what(x)fe_4(what, __VA_ARGS__) - #define _macro_fe_6(what, x, ...) what(x)fe_5(what, __VA_ARGS__) - #define _macro_fe_7(what, x, ...) what(x)fe_6(what, __VA_ARGS__) - #define _macro_fe_8(what, x, ...) what(x)fe_7(what, __VA_ARGS__) - #define _macro_fe_9(what, x, ...) what(x)fe_8(what, __VA_ARGS__) + #define _macro_fe_0(what, ...) + #define _macro_fe_1(what, x, ...) what(x)_macro_fe_0(what, __VA_ARGS__) + #define _macro_fe_2(what, x, ...) what(x)_macro_fe_1(what, __VA_ARGS__) + #define _macro_fe_3(what, x, ...) what(x)_macro_fe_2(what, __VA_ARGS__) + #define _macro_fe_4(what, x, ...) what(x)_macro_fe_3(what, __VA_ARGS__) + #define _macro_fe_5(what, x, ...) what(x)_macro_fe_4(what, __VA_ARGS__) + #define _macro_fe_6(what, x, ...) what(x)_macro_fe_5(what, __VA_ARGS__) + #define _macro_fe_7(what, x, ...) what(x)_macro_fe_6(what, __VA_ARGS__) + #define _macro_fe_8(what, x, ...) what(x)_macro_fe_7(what, __VA_ARGS__) + #define _macro_fe_9(what, x, ...) what(x)_macro_fe_8(what, __VA_ARGS__) #define _macro_fe_get( \ _0,_1,_2,_3,_4,_5,_6,_7,_8,_9, \ name,...) name +#define _macro_for_each_parens(funcormacro,...) \ + _macro_fe_get(_0,##__VA_ARGS__, \ + _macro_fep9,_macro_fep8,_macro_fep7,_macro_fe_6,_macro_fep5,_macro_fep4,_macro_fep3,_macro_fep2,_macro_fep1,_macro_fep0 \ + )(funcormacro,__VA_ARGS__) + #define _macro_fep0(what, ...) + #define _macro_fep1(what, x, ...) what x _macro_fep0(what, __VA_ARGS__) + #define _macro_fep2(what, x, ...) what x _macro_fep1(what, __VA_ARGS__) + #define _macro_fep3(what, x, ...) what x _macro_fep2(what, __VA_ARGS__) + #define _macro_fep4(what, x, ...) what x _macro_fep3(what, __VA_ARGS__) + #define _macro_fep5(what, x, ...) what x _macro_fep4(what, __VA_ARGS__) + #define _macro_fep6(what, x, ...) what x _macro_fep5(what, __VA_ARGS__) + #define _macro_fep7(what, x, ...) what x _macro_fep6(what, __VA_ARGS__) + #define _macro_fep8(what, x, ...) what x _macro_fep7(what, __VA_ARGS__) + #define _macro_fep9(what, x, ...) what x _macro_fep8(what, __VA_ARGS__) namespace intellect { namespace level0 { |