Tue, 06 Jul 2021 10:22:49 +0300
* Image/Bitmap rotate
793
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
1 | #pragma once |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
2 | |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
3 | #include <typeinfo> |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
4 | #include "TMP.h" |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
5 | |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
6 | namespace Gorgon { |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
7 | |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
8 | template <int N, class ...T_> |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
9 | struct GetElm { |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
10 | }; |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
11 | |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
12 | template <class T1_, class ...T_> |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
13 | struct GetElm<0, T1_, T_...> { |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
14 | template <T1_ V1_, T_ ...V_> |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
15 | struct Inner { |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
16 | static constexpr T1_ Value = V1_; |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
17 | }; |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
18 | }; |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
19 | |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
20 | template <int N, class T1_, class ...T_> |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
21 | struct GetElm<N, T1_, T_...> { |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
22 | template <T1_ V1_, T_ ...V_> |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
23 | struct Inner { |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
24 | static constexpr auto Value = GetElm<N-1, T_...>::template Inner<V_...>::Value; |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
25 | }; |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
26 | }; |
1100 | 27 | |
793
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
28 | |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
29 | template<class C_, class ...MT_> |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
30 | class StructDefiner { |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
31 | public: |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
32 | template<MT_ ...M_> |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
33 | struct Inner { |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
34 | |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
35 | template<class ...S_> |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
36 | constexpr Inner(const S_ &...names) : Names{names...} { |
795
4368c8f894af
* Visual studio fixes for Struct definition (partial)
cemkalyoncu
parents:
794
diff
changeset
|
37 | static_assert(sizeof...(S_) == sizeof...(MT_), "Number of element names does not match with the number of elements"); |
793
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
38 | } |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
39 | |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
40 | template<int N> |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
41 | struct Member { |
805
8c4c1caa0172
* Name based data to structure transformation
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
803
diff
changeset
|
42 | using Type = typename TMP::RemoveRValueReference<decltype(std::declval<C_>().*(GetElm<N, MT_...>::template Inner<M_...>::Value))>::Type; |
803
f4d29a67618e
* A Gorgon defined struct can now be turned into a data resource
cemkalyoncu
parents:
798
diff
changeset
|
43 | |
f4d29a67618e
* A Gorgon defined struct can now be turned into a data resource
cemkalyoncu
parents:
798
diff
changeset
|
44 | static constexpr decltype(GetElm<N, MT_...>::template Inner<M_...>::Value) |
f4d29a67618e
* A Gorgon defined struct can now be turned into a data resource
cemkalyoncu
parents:
798
diff
changeset
|
45 | MemberPointer() { |
f4d29a67618e
* A Gorgon defined struct can now be turned into a data resource
cemkalyoncu
parents:
798
diff
changeset
|
46 | return std::get<N>(std::tuple<MT_...>(M_...)); |
f4d29a67618e
* A Gorgon defined struct can now be turned into a data resource
cemkalyoncu
parents:
798
diff
changeset
|
47 | } |
793
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
48 | }; |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
49 | |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
50 | const char *Names[sizeof...(MT_)]; |
803
f4d29a67618e
* A Gorgon defined struct can now be turned into a data resource
cemkalyoncu
parents:
798
diff
changeset
|
51 | |
f4d29a67618e
* A Gorgon defined struct can now be turned into a data resource
cemkalyoncu
parents:
798
diff
changeset
|
52 | static constexpr int MemberCount = sizeof...(MT_); |
794
ec7895c817e6
* Initial design for Data resource
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
793
diff
changeset
|
53 | |
ec7895c817e6
* Initial design for Data resource
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
793
diff
changeset
|
54 | static constexpr int IsGorgonReflection = true; |
793
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
55 | }; |
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
56 | }; |
795
4368c8f894af
* Visual studio fixes for Struct definition (partial)
cemkalyoncu
parents:
794
diff
changeset
|
57 | |
798
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
58 | |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
59 | #ifdef _MSC_VER |
807 | 60 | #define CALLER(F, P) CALL_(F, P) |
61 | #define CALL_(F, P) F##P | |
62 | ||
63 | #define CONC(A, B) CONC_(A, B) | |
64 | #define CONC_(A, B) CONC__(A, B) | |
65 | #define CONC__(A, B) CONC___(A, B) | |
66 | #define CONC___(A, B) CONC____(A, B) | |
67 | #define CONC____(A, B) CONC_____(A, B) | |
68 | #define CONC_____(A, B) CONC______(A, B) | |
69 | #define CONC______(A, B) A##B | |
70 | ||
798
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
71 | #define NARGS(...) CALL_(NARGS_,(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
72 | #define NARGS_(_16, _15, _14, _13, _12, _11, _10, _9, _8, _7, _6, _5, _4, _3, _2, _1, N, ...) N |
795
4368c8f894af
* Visual studio fixes for Struct definition (partial)
cemkalyoncu
parents:
794
diff
changeset
|
73 | |
4368c8f894af
* Visual studio fixes for Struct definition (partial)
cemkalyoncu
parents:
794
diff
changeset
|
74 | |
807 | 75 | #define StructDefiner_types_1(C, E) decltype(&C::E) |
76 | #define StructDefiner_types_2(C, E, F) decltype(&C::E), StructDefiner_types_1 (C, F) | |
77 | #define StructDefiner_types_3(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_2 , (C, __VA_ARGS__)) | |
78 | #define StructDefiner_types_4(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_3 , (C, __VA_ARGS__)) | |
79 | #define StructDefiner_types_5(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_4 , (C, __VA_ARGS__)) | |
80 | #define StructDefiner_types_6(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_5 , (C, __VA_ARGS__)) | |
81 | #define StructDefiner_types_7(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_6 , (C, __VA_ARGS__)) | |
82 | #define StructDefiner_types_8(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_7 , (C, __VA_ARGS__)) | |
83 | #define StructDefiner_types_9(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_8 , (C, __VA_ARGS__)) | |
84 | #define StructDefiner_types_10(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_9 , (C, __VA_ARGS__)) | |
85 | #define StructDefiner_types_11(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_10, (C, __VA_ARGS__)) | |
86 | #define StructDefiner_types_12(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_11, (C, __VA_ARGS__)) | |
87 | #define StructDefiner_types_13(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_12, (C, __VA_ARGS__)) | |
88 | #define StructDefiner_types_14(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_13, (C, __VA_ARGS__)) | |
89 | #define StructDefiner_types_15(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_14, (C, __VA_ARGS__)) | |
90 | #define StructDefiner_types_16(C, E, ...) decltype(&C::E), CALL_(StructDefiner_types_15, (C, __VA_ARGS__)) | |
793
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
91 | |
807 | 92 | #define StructDefiner_values_1(C, E) &C::E |
93 | #define StructDefiner_values_2(C, E, F) &C::E, StructDefiner_values_1 (C, F) | |
94 | #define StructDefiner_values_3(C, E, ...) &C::E, CALL_(StructDefiner_values_2 , (C, __VA_ARGS__)) | |
95 | #define StructDefiner_values_4(C, E, ...) &C::E, CALL_(StructDefiner_values_3 , (C, __VA_ARGS__)) | |
96 | #define StructDefiner_values_5(C, E, ...) &C::E, CALL_(StructDefiner_values_4 , (C, __VA_ARGS__)) | |
97 | #define StructDefiner_values_6(C, E, ...) &C::E, CALL_(StructDefiner_values_5 , (C, __VA_ARGS__)) | |
98 | #define StructDefiner_values_7(C, E, ...) &C::E, CALL_(StructDefiner_values_6 , (C, __VA_ARGS__)) | |
99 | #define StructDefiner_values_8(C, E, ...) &C::E, CALL_(StructDefiner_values_7 , (C, __VA_ARGS__)) | |
100 | #define StructDefiner_values_9(C, E, ...) &C::E, CALL_(StructDefiner_values_8 , (C, __VA_ARGS__)) | |
101 | #define StructDefiner_values_10(C, E, ...) &C::E, CALL_(StructDefiner_values_9 , (C, __VA_ARGS__)) | |
102 | #define StructDefiner_values_11(C, E, ...) &C::E, CALL_(StructDefiner_values_10, (C, __VA_ARGS__)) | |
103 | #define StructDefiner_values_12(C, E, ...) &C::E, CALL_(StructDefiner_values_11, (C, __VA_ARGS__)) | |
104 | #define StructDefiner_values_13(C, E, ...) &C::E, CALL_(StructDefiner_values_12, (C, __VA_ARGS__)) | |
105 | #define StructDefiner_values_14(C, E, ...) &C::E, CALL_(StructDefiner_values_13, (C, __VA_ARGS__)) | |
106 | #define StructDefiner_values_15(C, E, ...) &C::E, CALL_(StructDefiner_values_14, (C, __VA_ARGS__)) | |
107 | #define StructDefiner_values_16(C, E, ...) &C::E, CALL_(StructDefiner_values_15, (C, __VA_ARGS__)) | |
798
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
108 | |
807 | 109 | #define StructDefiner_names_1(C, E) #E |
110 | #define StructDefiner_names_2(C, E, F) #E, StructDefiner_names_1 (C, F) | |
111 | #define StructDefiner_names_3(C, E, ...) #E, CALL_(StructDefiner_names_2 , (C, __VA_ARGS__)) | |
112 | #define StructDefiner_names_4(C, E, ...) #E, CALL_(StructDefiner_names_3 , (C, __VA_ARGS__)) | |
113 | #define StructDefiner_names_5(C, E, ...) #E, CALL_(StructDefiner_names_4 , (C, __VA_ARGS__)) | |
114 | #define StructDefiner_names_6(C, E, ...) #E, CALL_(StructDefiner_names_5 , (C, __VA_ARGS__)) | |
115 | #define StructDefiner_names_7(C, E, ...) #E, CALL_(StructDefiner_names_6 , (C, __VA_ARGS__)) | |
116 | #define StructDefiner_names_8(C, E, ...) #E, CALL_(StructDefiner_names_7 , (C, __VA_ARGS__)) | |
117 | #define StructDefiner_names_9(C, E, ...) #E, CALL_(StructDefiner_names_8 , (C, __VA_ARGS__)) | |
118 | #define StructDefiner_names_10(C, E, ...) #E, CALL_(StructDefiner_names_9 , (C, __VA_ARGS__)) | |
119 | #define StructDefiner_names_11(C, E, ...) #E, CALL_(StructDefiner_names_10, (C, __VA_ARGS__)) | |
120 | #define StructDefiner_names_12(C, E, ...) #E, CALL_(StructDefiner_names_11, (C, __VA_ARGS__)) | |
121 | #define StructDefiner_names_13(C, E, ...) #E, CALL_(StructDefiner_names_12, (C, __VA_ARGS__)) | |
122 | #define StructDefiner_names_14(C, E, ...) #E, CALL_(StructDefiner_names_13, (C, __VA_ARGS__)) | |
123 | #define StructDefiner_names_15(C, E, ...) #E, CALL_(StructDefiner_names_14, (C, __VA_ARGS__)) | |
124 | #define StructDefiner_names_16(C, E, ...) #E, CALL_(StructDefiner_names_15, (C, __VA_ARGS__)) | |
798
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
125 | |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
126 | /// Defines a struct members with the given name. The first parameter is the name of the class. |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
127 | /// This macro should be called inside the class/struct scope. This reflection is geared towards |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
128 | /// POD objects. Might not behave as intented on polymorphic objects. After calling this function |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
129 | /// the class will have ReflectionType and Reflection() that returns reflection object with names. |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
130 | #define DefineStructMembers(C, ...) \ |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
131 | using ReflectionType = StructDefiner<C, CALLER(CALL_(CONC, (StructDefiner_types_, CONC(NARGS,(__VA_ARGS__))) ),(C, __VA_ARGS__))>::\ |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
132 | Inner<CALLER(CALL_(CONC, (StructDefiner_values_, CONC(NARGS,(__VA_ARGS__))) ),(C, __VA_ARGS__))>; \ |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
133 | static constexpr ReflectionType Reflection() { return {CALLER(CALL_(CONC, (StructDefiner_names_, CONC(NARGS,(__VA_ARGS__))) ),(C, __VA_ARGS__))}; } |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
134 | |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
135 | |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
136 | /// Defines a struct members with the given name. The first parameter is the name of the class. |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
137 | /// This macro should be called inside the class/struct scope. This reflection is geared towards |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
138 | /// POD objects. Might not behave as intented on polymorphic objects. This variant allows naming |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
139 | /// Reflection object function and type. After calling this function the class will have |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
140 | /// {Name}Type and {Name}() that returns reflection object with names. |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
141 | #define DefineStructMembersWithName(C, Name, ...) \ |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
142 | using Name##Type = StructDefiner<C, CALLER(CALL_(CONC, (StructDefiner_types_, CONC(NARGS,(__VA_ARGS__))) ),(C, __VA_ARGS__))>::\ |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
143 | Inner<CALLER(CALL_(CONC, (StructDefiner_values_, CONC(NARGS,(__VA_ARGS__))) ),(C, __VA_ARGS__))>; \ |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
144 | static constexpr Name##Type Name() { return {CALLER(CALL_(CONC, (StructDefiner_names_, CONC(NARGS,(__VA_ARGS__))) ),(C, __VA_ARGS__))}; } |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
145 | #else |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
146 | #define CONC(A, B) CONC_(A, B) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
147 | #define CONC_(A, B) A##B |
1099
42b5a506665b
* A limitation in struction definition system is fixed.
cemkalyoncu
parents:
829
diff
changeset
|
148 | #define NARGS(...) NARGS_(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) |
42b5a506665b
* A limitation in struction definition system is fixed.
cemkalyoncu
parents:
829
diff
changeset
|
149 | #define NARGS_(_16, _15, _14, _13, _12, _11, _10, _9, _8, _7, _6, _5, _4, _3, _2, _1, N, ...) N |
793
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
150 | |
798
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
151 | #define StructDefiner_types_1(C, E) decltype(&C::E) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
152 | #define StructDefiner_types_2(C, E, ...) decltype(&C::E), StructDefiner_types_1(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
153 | #define StructDefiner_types_3(C, E, ...) decltype(&C::E), StructDefiner_types_2(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
154 | #define StructDefiner_types_4(C, E, ...) decltype(&C::E), StructDefiner_types_3(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
155 | #define StructDefiner_types_5(C, E, ...) decltype(&C::E), StructDefiner_types_4(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
156 | #define StructDefiner_types_6(C, E, ...) decltype(&C::E), StructDefiner_types_5(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
157 | #define StructDefiner_types_7(C, E, ...) decltype(&C::E), StructDefiner_types_6(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
158 | #define StructDefiner_types_8(C, E, ...) decltype(&C::E), StructDefiner_types_7(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
159 | #define StructDefiner_types_9(C, E, ...) decltype(&C::E), StructDefiner_types_8(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
160 | #define StructDefiner_types_10(C, E, ...) decltype(&C::E), StructDefiner_types_9(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
161 | #define StructDefiner_types_11(C, E, ...) decltype(&C::E), StructDefiner_types_10(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
162 | #define StructDefiner_types_12(C, E, ...) decltype(&C::E), StructDefiner_types_11(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
163 | #define StructDefiner_types_13(C, E, ...) decltype(&C::E), StructDefiner_types_12(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
164 | #define StructDefiner_types_14(C, E, ...) decltype(&C::E), StructDefiner_types_13(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
165 | #define StructDefiner_types_15(C, E, ...) decltype(&C::E), StructDefiner_types_14(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
166 | #define StructDefiner_types_16(C, E, ...) decltype(&C::E), StructDefiner_types_15(C, __VA_ARGS__) |
794
ec7895c817e6
* Initial design for Data resource
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
793
diff
changeset
|
167 | |
798
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
168 | #define StructDefiner_values_1(C, E) &C::E |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
169 | #define StructDefiner_values_2(C, E, ...) &C::E, StructDefiner_values_1(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
170 | #define StructDefiner_values_3(C, E, ...) &C::E, StructDefiner_values_2(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
171 | #define StructDefiner_values_4(C, E, ...) &C::E, StructDefiner_values_3(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
172 | #define StructDefiner_values_5(C, E, ...) &C::E, StructDefiner_values_4(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
173 | #define StructDefiner_values_6(C, E, ...) &C::E, StructDefiner_values_5(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
174 | #define StructDefiner_values_7(C, E, ...) &C::E, StructDefiner_values_6(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
175 | #define StructDefiner_values_8(C, E, ...) &C::E, StructDefiner_values_7(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
176 | #define StructDefiner_values_9(C, E, ...) &C::E, StructDefiner_values_8(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
177 | #define StructDefiner_values_10(C, E, ...) &C::E, StructDefiner_values_9(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
178 | #define StructDefiner_values_11(C, E, ...) &C::E, StructDefiner_values_10(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
179 | #define StructDefiner_values_12(C, E, ...) &C::E, StructDefiner_values_11(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
180 | #define StructDefiner_values_13(C, E, ...) &C::E, StructDefiner_values_12(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
181 | #define StructDefiner_values_14(C, E, ...) &C::E, StructDefiner_values_13(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
182 | #define StructDefiner_values_15(C, E, ...) &C::E, StructDefiner_values_14(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
183 | #define StructDefiner_values_16(C, E, ...) &C::E, StructDefiner_values_15(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
184 | |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
185 | #define StructDefiner_names_1(C, E) #E |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
186 | #define StructDefiner_names_2(C, E, ...) #E, StructDefiner_names_1(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
187 | #define StructDefiner_names_3(C, E, ...) #E, StructDefiner_names_2(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
188 | #define StructDefiner_names_4(C, E, ...) #E, StructDefiner_names_3(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
189 | #define StructDefiner_names_5(C, E, ...) #E, StructDefiner_names_4(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
190 | #define StructDefiner_names_6(C, E, ...) #E, StructDefiner_names_5(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
191 | #define StructDefiner_names_7(C, E, ...) #E, StructDefiner_names_6(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
192 | #define StructDefiner_names_8(C, E, ...) #E, StructDefiner_names_7(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
193 | #define StructDefiner_names_9(C, E, ...) #E, StructDefiner_names_8(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
194 | #define StructDefiner_names_10(C, E, ...) #E, StructDefiner_names_9(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
195 | #define StructDefiner_names_11(C, E, ...) #E, StructDefiner_names_10(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
196 | #define StructDefiner_names_12(C, E, ...) #E, StructDefiner_names_11(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
197 | #define StructDefiner_names_13(C, E, ...) #E, StructDefiner_names_12(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
198 | #define StructDefiner_names_14(C, E, ...) #E, StructDefiner_names_13(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
199 | #define StructDefiner_names_15(C, E, ...) #E, StructDefiner_names_14(C, __VA_ARGS__) |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
200 | #define StructDefiner_names_16(C, E, ...) #E, StructDefiner_names_15(C, __VA_ARGS__) |
794
ec7895c817e6
* Initial design for Data resource
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
793
diff
changeset
|
201 | |
798
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
202 | /// Defines a struct members with the given name. The first parameter is the name of the class. |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
203 | /// This macro should be called inside the class/struct scope. This reflection is geared towards |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
204 | /// POD objects. Might not behave as intented on polymorphic objects. After calling this function |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
205 | /// the class will have ReflectionType and Reflection() that returns reflection object with names. |
829
6ef7ca904191
* Fixes to struct definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
807
diff
changeset
|
206 | #define DefineStructMembers(C, ...) using ReflectionType = Gorgon::StructDefiner<C, CONC(StructDefiner_types_, NARGS(__VA_ARGS__)) (C, __VA_ARGS__)>::Inner<CONC(StructDefiner_values_, NARGS(__VA_ARGS__)) (C, __VA_ARGS__)>; \ |
798
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
207 | static constexpr ReflectionType Reflection() { return {CONC(StructDefiner_names_, NARGS(__VA_ARGS__))(C, __VA_ARGS__)}; } |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
208 | |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
209 | /// Defines a struct members with the given name. The first parameter is the name of the class. |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
210 | /// This macro should be called inside the class/struct scope. This reflection is geared towards |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
211 | /// POD objects. Might not behave as intented on polymorphic objects. This variant allows naming |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
212 | /// Reflection object function and type. After calling this function the class will have |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
213 | /// {Name}Type and {Name}() that returns reflection object with names. |
829
6ef7ca904191
* Fixes to struct definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
807
diff
changeset
|
214 | #define DefineStructMembersWithName(C, Name, ...) using Name##Type = Gorgon::StructDefiner<C, CONC(StructDefiner_types_, NARGS(__VA_ARGS__)) (C, __VA_ARGS__)>::Inner<CONC(StructDefiner_values_, NARGS(__VA_ARGS__)) (C, __VA_ARGS__)>; \ |
798
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
215 | static constexpr Name##Type Name() { return {CONC(StructDefiner_names_, NARGS(__VA_ARGS__))(C, __VA_ARGS__)}; } |
795
4368c8f894af
* Visual studio fixes for Struct definition (partial)
cemkalyoncu
parents:
794
diff
changeset
|
216 | |
798
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
217 | #endif |
881c2be09297
* Splitted gcc and vc versions of define struct macro
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
795
diff
changeset
|
218 | |
793
a5471d749e9b
* Initial work on structure definition
cemkalyoncu <cemkalyoncu@gmail.com>
parents:
diff
changeset
|
219 | } |