-
Notifications
You must be signed in to change notification settings - Fork 0
/
STRENUM.h
executable file
·115 lines (102 loc) · 7.93 KB
/
STRENUM.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
//
// STRENUM.h
// EnumTest
//
// Created by Jesus on 05.09.2018.
// Copyright © 2018 Jesus. All rights reserved.
//
#ifndef STRENUM_h
#define STRENUM_h
#define STRINGIFY2(X) #X
#define STRINGIFY(X) STRINGIFY2(X)
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
#define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); }))
#define PP_NARG(...) \
PP_NARG_(__VA_ARGS__,PP_RSEQ_N())
#define PP_NARG_(...) \
PP_ARG_N(__VA_ARGS__)
#define PP_ARG_N( \
_1, _2, _3, _4, _5, _6, _7, _8, _9,_10, \
_11,_12,_13,_14,_15,_16,_17,_18,_19,_20, \
_21,_22,_23,_24,_25,_26,_27,_28,_29,_30, \
_31,_32,_33,_34,_35,_36,_37,_38,_39,_40, \
_41,_42,_43,_44,_45,_46,_47,_48,_49,_50, \
_51,_52,_53,_54,_55,_56,_57,_58,_59,_60, \
_61,_62,_63,N,...) N
#define PP_RSEQ_N() \
63,62,61,60, \
59,58,57,56,55,54,53,52,51,50, \
49,48,47,46,45,44,43,42,41,40, \
39,38,37,36,35,34,33,32,31,30, \
29,28,27,26,25,24,23,22,21,20, \
19,18,17,16,15,14,13,12,11,10, \
9,8,7,6,5,4,3,2,1,0
#define CONCAT_(x,y) x##y
#define CONCAT(x,y) CONCAT_(x,y)
#define VAR_ARG_INIT_M(TYPE,...) \
CONCAT(VAR_ARG_INIT_ , PP_NARG(__VA_ARGS__)) (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_1(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A);
#define VAR_ARG_INIT_2(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_1 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_3(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_2 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_4(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_3 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_5(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_4 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_6(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_5 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_7(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_6 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_8(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_7 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_9(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_8 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_10(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_9 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_11(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_10 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_12(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_11 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_13(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_12 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_14(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_13 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_15(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_14 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_16(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_15 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_17(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_16 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_18(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_17 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_19(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_18 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_20(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_19 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_21(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_20 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_22(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_21 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_23(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_22 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_24(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_23 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_25(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_24 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_26(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_25 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_27(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_26 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_28(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_27 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_29(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_28 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_30(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_29 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_31(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_30 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_32(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_31 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_33(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_32 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_34(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_33 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_35(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_34 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_36(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_35 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_37(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_36 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_38(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_37 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_39(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_38 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_40(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_39 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_41(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_40 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_42(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_41 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_43(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_42 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_44(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_43 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_45(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_44 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_46(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_45 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_47(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_46 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_48(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_47 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_49(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_48 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_50(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_49 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_51(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_50 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_52(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_51 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_53(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_52 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_54(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_53 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_55(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_54 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_56(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_55 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_57(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_56 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_58(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_57 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_59(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_58 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_60(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_59 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_61(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_60 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_62(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_61 (TYPE, __VA_ARGS__);
#define VAR_ARG_INIT_63(TYPE, A, ...) TYPE *A = (TYPE *)@ STRINGIFY(A); VAR_ARG_INIT_62 (TYPE, __VA_ARGS__);
#define STRING_ENUM(SType, ...) @protocol SType @end typedef NSString<SType> SType; VAR_ARG_INIT_M(SType, __VA_ARGS__);
#endif /* STRENUM_h */