| 1 |
// This file is part of the JoinPoint Template Library (JPTL) |
| 2 |
// |
| 3 |
// JPTL is free software: you can redistribute it and/or modify |
| 4 |
// it under the terms of the GNU General Public License as published by |
| 5 |
// the Free Software Foundation, either version 3 of the License, or |
| 6 |
// (at your option) any later version. |
| 7 |
// |
| 8 |
// JPTL is distributed in the hope that it will be useful, |
| 9 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
// GNU General Public License for more details. |
| 12 |
// |
| 13 |
// You should have received a copy of the GNU General Public License |
| 14 |
// along with JPTL. If not, see <http://www.gnu.org/licenses/>. |
| 15 |
// |
| 16 |
// Copyright (C) 2012-2014 Christoph Borchert |
| 17 |
|
| 18 |
#ifndef __JPTL_H__ |
| 19 |
#define __JPTL_H__ |
| 20 |
|
| 21 |
namespace JPTL { |
| 22 |
|
| 23 |
|
| 24 |
namespace SFINAE_CHECK { |
| 25 |
|
| 26 |
namespace EXEC { |
| 27 |
// static check, whether <T> has an attribute 'EXEC' |
| 28 |
template<typename T> long ttest(...); // overload resolution matches always |
| 29 |
template<typename T> char ttest(typename T::EXEC const volatile *); // preferred by overload resolution |
| 30 |
|
| 31 |
template<typename T, unsigned hasEXEC = ((sizeof(ttest<T>(0))==sizeof(char))?1:0) > |
| 32 |
struct GET { |
| 33 |
typedef typename T::EXEC Type; |
| 34 |
}; |
| 35 |
template<typename T> |
| 36 |
struct GET<T, 0> { |
| 37 |
typedef void Type; |
| 38 |
}; |
| 39 |
} // namespace EXEC |
| 40 |
|
| 41 |
// For looking up EXEC, use this dummy ones if the real one has no members/functions |
| 42 |
// FIXME: this needs maintenance if future ac++ versions change this structures |
| 43 |
template <int __D=0> struct DummyMember { typedef char Type; typedef AC::Referred<Type>::type ReferredType; static const AC::Protection prot = AC::PROT_PRIVATE; static const AC::Specifiers spec = AC::SPEC_NONE; static ReferredType *pointer (const void* const obj = 0) { return 0; } static const char *name () { return "null"; } }; |
| 44 |
template <int __D=0> struct DummyFunction { static const AC::Protection prot = AC::PROT_PRIVATE; static const AC::Specifiers spec = AC::SPEC_NONE; }; |
| 45 |
template <int __D=0> struct DummyConstructor { static const AC::Protection prot = AC::PROT_PRIVATE; static const AC::Specifiers spec = AC::SPEC_NONE; }; |
| 46 |
template <int __D=0> struct DummyDestructor { static const AC::Protection prot = AC::PROT_PRIVATE; static const AC::Specifiers spec = AC::SPEC_NONE; }; |
| 47 |
|
| 48 |
template<typename TypeInfo, unsigned MEMBERS=TypeInfo::MEMBERS> |
| 49 |
struct GetFirstMember { |
| 50 |
typedef typename TypeInfo::template Member<0> MemberInfo; |
| 51 |
}; |
| 52 |
template<typename TypeInfo> |
| 53 |
struct GetFirstMember<TypeInfo, 0> { |
| 54 |
typedef DummyMember<> MemberInfo; |
| 55 |
}; |
| 56 |
|
| 57 |
template<typename TypeInfo, unsigned FUNCTIONS=TypeInfo::FUNCTIONS> |
| 58 |
struct GetFirstFunction { |
| 59 |
typedef typename TypeInfo::template Function<0> FunctionInfo; |
| 60 |
}; |
| 61 |
template<typename TypeInfo> |
| 62 |
struct GetFirstFunction<TypeInfo, 0> { |
| 63 |
typedef DummyFunction<> FunctionInfo; |
| 64 |
}; |
| 65 |
|
| 66 |
template<typename TypeInfo, unsigned CONSTRUCTORS=TypeInfo::CONSTRUCTORS> |
| 67 |
struct GetFirstConstructor { |
| 68 |
typedef typename TypeInfo::template Constructor<0> ConstructorInfo; |
| 69 |
}; |
| 70 |
template<typename TypeInfo> |
| 71 |
struct GetFirstConstructor<TypeInfo, 0> { |
| 72 |
typedef DummyConstructor<> ConstructorInfo; |
| 73 |
}; |
| 74 |
|
| 75 |
template<typename TypeInfo, unsigned DESTRUCTORS=TypeInfo::DESTRUCTORS> |
| 76 |
struct GetFirstDestructor { |
| 77 |
typedef typename TypeInfo::template Destructor<0> DestructorInfo; |
| 78 |
}; |
| 79 |
template<typename TypeInfo> |
| 80 |
struct GetFirstDestructor<TypeInfo, 0> { |
| 81 |
typedef DummyDestructor<> DestructorInfo; |
| 82 |
}; |
| 83 |
|
| 84 |
} // namespace SFINAE_CHECK |
| 85 |
|
| 86 |
//------------------------------------------------------------------------------------------------------------------------------- |
| 87 |
|
| 88 |
#ifndef __acweaving |
| 89 |
|
| 90 |
template<typename TypeInfo, |
| 91 |
template <typename, typename> class Action, |
| 92 |
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action<TypeInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature |
| 93 |
unsigned I=TypeInfo::BASECLASSES> |
| 94 |
struct BaseIterator { |
| 95 |
|
| 96 |
//base type information |
| 97 |
typedef typename TypeInfo::template BaseClass<I-1>::Type BASE_TYPE; |
| 98 |
typedef AC::TypeInfo<BASE_TYPE> BASE_TYPE_INFO; |
| 99 |
|
| 100 |
// try to cast (a pointer) from TypeInfo::That* to BASE_TYPE* |
| 101 |
// if that fails, return the original value |
| 102 |
template<typename T> |
| 103 |
__attribute__((always_inline)) inline static T base_cast(T arg) { return arg; } |
| 104 |
__attribute__((always_inline)) inline static BASE_TYPE* base_cast(typename TypeInfo::That* arg) { |
| 105 |
return (BASE_TYPE*)arg; |
| 106 |
} |
| 107 |
__attribute__((always_inline)) inline static const BASE_TYPE* base_cast(const typename TypeInfo::That* arg) { |
| 108 |
return (const BASE_TYPE*)arg; |
| 109 |
} |
| 110 |
__attribute__((always_inline)) inline static volatile BASE_TYPE* base_cast(volatile typename TypeInfo::That* arg) { |
| 111 |
return (volatile BASE_TYPE*)arg; |
| 112 |
} |
| 113 |
__attribute__((always_inline)) inline static const volatile BASE_TYPE* base_cast(const volatile typename TypeInfo::That* arg) { |
| 114 |
return (const volatile BASE_TYPE*)arg; |
| 115 |
} |
| 116 |
|
| 117 |
// calculation of the context type |
| 118 |
typedef typename BaseIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::EXEC PREV_EXEC; // recursion to the current base class |
| 119 |
typedef typename BaseIterator<TypeInfo, Action, PREV_EXEC, I-1>::EXEC EXEC; // process next base class |
| 120 |
|
| 121 |
// the exec(...) function |
| 122 |
__attribute__((always_inline)) inline static void exec() { // rule: I > 0 |
| 123 |
BaseIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec(); // recursion to the current base class |
| 124 |
BaseIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(); // process next base class |
| 125 |
} |
| 126 |
template<typename ARG_0> |
| 127 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { // rule: I > 0 |
| 128 |
BaseIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) ); // recursion to the current base class |
| 129 |
BaseIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0); // process next base class |
| 130 |
} |
| 131 |
template<typename ARG_0, typename ARG_1> |
| 132 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { // rule: I > 0 |
| 133 |
BaseIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) , base_cast(arg1) ); // recursion to the current base class |
| 134 |
BaseIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0, arg1); // process next base class |
| 135 |
} |
| 136 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 137 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { // rule: I > 0 |
| 138 |
BaseIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) , base_cast(arg1) , base_cast(arg2) ); // recursion to the current base class |
| 139 |
BaseIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0, arg1, arg2); // process next base class |
| 140 |
} |
| 141 |
}; |
| 142 |
|
| 143 |
// Specialization for I=0 |
| 144 |
template<typename TypeInfo, |
| 145 |
template <typename, typename> class Action, |
| 146 |
typename LAST_EXEC> |
| 147 |
struct BaseIterator<TypeInfo, Action, LAST_EXEC, 0> { |
| 148 |
|
| 149 |
// calculation of the context type |
| 150 |
typedef typename SFINAE_CHECK::EXEC::GET< Action<TypeInfo, LAST_EXEC> >::Type EXEC; |
| 151 |
|
| 152 |
// the exec(...) function |
| 153 |
__attribute__((always_inline)) inline static void exec() { |
| 154 |
Action<TypeInfo, LAST_EXEC>::exec(); |
| 155 |
} |
| 156 |
template<typename ARG_0> |
| 157 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { |
| 158 |
Action<TypeInfo, LAST_EXEC>::exec(arg0); |
| 159 |
} |
| 160 |
template<typename ARG_0, typename ARG_1> |
| 161 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { |
| 162 |
Action<TypeInfo, LAST_EXEC>::exec(arg0, arg1); |
| 163 |
} |
| 164 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 165 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { |
| 166 |
Action<TypeInfo, LAST_EXEC>::exec(arg0, arg1, arg2); |
| 167 |
} |
| 168 |
}; |
| 169 |
|
| 170 |
//------------------------------------------------------------------------------------------------------------------------------- |
| 171 |
|
| 172 |
|
| 173 |
template<typename TypeInfo, |
| 174 |
template <typename, typename> class Action, |
| 175 |
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action<typename SFINAE_CHECK::GetFirstMember<TypeInfo>::MemberInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature |
| 176 |
unsigned I=TypeInfo::MEMBERS> |
| 177 |
struct MemberIterator { |
| 178 |
|
| 179 |
//member type info |
| 180 |
typedef typename TypeInfo::template Member<I-1> MEMBER_TYPE_INFO; |
| 181 |
|
| 182 |
// calculation of the context type |
| 183 |
typedef typename MemberIterator<TypeInfo, Action, LAST_EXEC, I-1>::EXEC PREV_EXEC; |
| 184 |
typedef typename SFINAE_CHECK::EXEC::GET< Action<MEMBER_TYPE_INFO, PREV_EXEC> >::Type EXEC; |
| 185 |
|
| 186 |
// the exec(...) function |
| 187 |
__attribute__((always_inline)) inline static void exec() { |
| 188 |
MemberIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(); |
| 189 |
Action<MEMBER_TYPE_INFO, PREV_EXEC>::exec(); |
| 190 |
} |
| 191 |
template<typename ARG_0> |
| 192 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { |
| 193 |
MemberIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(arg0); |
| 194 |
Action<MEMBER_TYPE_INFO, PREV_EXEC>::exec(arg0); |
| 195 |
} |
| 196 |
template<typename ARG_0, typename ARG_1> |
| 197 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { |
| 198 |
MemberIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(arg0, arg1); |
| 199 |
Action<MEMBER_TYPE_INFO, PREV_EXEC>::exec(arg0, arg1); |
| 200 |
} |
| 201 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 202 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { |
| 203 |
MemberIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(arg0, arg1, arg2); |
| 204 |
Action<MEMBER_TYPE_INFO, PREV_EXEC>::exec(arg0, arg1, arg2); |
| 205 |
} |
| 206 |
}; |
| 207 |
|
| 208 |
// Specialization for I=0 (end of recursion) |
| 209 |
template<typename TypeInfo, |
| 210 |
template <typename, typename> class Action, |
| 211 |
typename LAST_EXEC> |
| 212 |
struct MemberIterator<TypeInfo, Action, LAST_EXEC, 0> { |
| 213 |
|
| 214 |
// calculation of the context type |
| 215 |
typedef LAST_EXEC EXEC; |
| 216 |
|
| 217 |
// the exec(...) function |
| 218 |
__attribute__((always_inline)) inline static void exec() {} |
| 219 |
template<typename ARG_0> |
| 220 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 221 |
template<typename ARG_0, typename ARG_1> |
| 222 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 223 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 224 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 225 |
}; |
| 226 |
|
| 227 |
//------------------------------------------------------------------------------------------------------------------------------- |
| 228 |
|
| 229 |
|
| 230 |
template<typename TypeInfo, |
| 231 |
template <typename, typename> class Action, |
| 232 |
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action<typename SFINAE_CHECK::GetFirstFunction<TypeInfo>::FunctionInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature |
| 233 |
unsigned I=TypeInfo::FUNCTIONS> |
| 234 |
struct FunctionIterator { |
| 235 |
|
| 236 |
//member type info |
| 237 |
typedef typename TypeInfo::template Function<I-1> FUNCTION_INFO; |
| 238 |
|
| 239 |
// calculation of the context type |
| 240 |
typedef typename FunctionIterator<TypeInfo, Action, LAST_EXEC, I-1>::EXEC PREV_EXEC; |
| 241 |
typedef typename SFINAE_CHECK::EXEC::GET< Action<FUNCTION_INFO, PREV_EXEC> >::Type EXEC; |
| 242 |
|
| 243 |
// the exec(...) function |
| 244 |
__attribute__((always_inline)) inline static void exec() { |
| 245 |
FunctionIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(); |
| 246 |
Action<FUNCTION_INFO, PREV_EXEC>::exec(); |
| 247 |
} |
| 248 |
template<typename ARG_0> |
| 249 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { |
| 250 |
FunctionIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(arg0); |
| 251 |
Action<FUNCTION_INFO, PREV_EXEC>::exec(arg0); |
| 252 |
} |
| 253 |
template<typename ARG_0, typename ARG_1> |
| 254 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { |
| 255 |
FunctionIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(arg0, arg1); |
| 256 |
Action<FUNCTION_INFO, PREV_EXEC>::exec(arg0, arg1); |
| 257 |
} |
| 258 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 259 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { |
| 260 |
FunctionIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(arg0, arg1, arg2); |
| 261 |
Action<FUNCTION_INFO, PREV_EXEC>::exec(arg0, arg1, arg2); |
| 262 |
} |
| 263 |
}; |
| 264 |
|
| 265 |
// Specialization for I=0 (end of recursion) |
| 266 |
template<typename TypeInfo, |
| 267 |
template <typename, typename> class Action, |
| 268 |
typename LAST_EXEC> |
| 269 |
struct FunctionIterator<TypeInfo, Action, LAST_EXEC, 0> { |
| 270 |
|
| 271 |
// calculation of the context type |
| 272 |
typedef LAST_EXEC EXEC; |
| 273 |
|
| 274 |
// the exec(...) function |
| 275 |
__attribute__((always_inline)) inline static void exec() {} |
| 276 |
template<typename ARG_0> |
| 277 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 278 |
template<typename ARG_0, typename ARG_1> |
| 279 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 280 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 281 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 282 |
}; |
| 283 |
|
| 284 |
//------------------------------------------------------------------------------------------------------------------------------- |
| 285 |
|
| 286 |
template<typename TypeInfo, |
| 287 |
template <typename, typename> class Action, |
| 288 |
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action<typename SFINAE_CHECK::GetFirstConstructor<TypeInfo>::ConstructorInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature |
| 289 |
unsigned I=TypeInfo::CONSTRUCTORS> |
| 290 |
struct ConstructorIterator { |
| 291 |
|
| 292 |
//member type info |
| 293 |
typedef typename TypeInfo::template Constructor<I-1> CONSTRUCTOR_INFO; |
| 294 |
|
| 295 |
// calculation of the context type |
| 296 |
typedef typename ConstructorIterator<TypeInfo, Action, LAST_EXEC, I-1>::EXEC PREV_EXEC; |
| 297 |
typedef typename SFINAE_CHECK::EXEC::GET< Action<CONSTRUCTOR_INFO, PREV_EXEC> >::Type EXEC; |
| 298 |
|
| 299 |
// the exec(...) function |
| 300 |
__attribute__((always_inline)) inline static void exec() { |
| 301 |
ConstructorIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(); |
| 302 |
Action<CONSTRUCTOR_INFO, PREV_EXEC>::exec(); |
| 303 |
} |
| 304 |
template<typename ARG_0> |
| 305 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { |
| 306 |
ConstructorIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(arg0); |
| 307 |
Action<CONSTRUCTOR_INFO, PREV_EXEC>::exec(arg0); |
| 308 |
} |
| 309 |
template<typename ARG_0, typename ARG_1> |
| 310 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { |
| 311 |
ConstructorIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(arg0, arg1); |
| 312 |
Action<CONSTRUCTOR_INFO, PREV_EXEC>::exec(arg0, arg1); |
| 313 |
} |
| 314 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 315 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { |
| 316 |
ConstructorIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(arg0, arg1, arg2); |
| 317 |
Action<CONSTRUCTOR_INFO, PREV_EXEC>::exec(arg0, arg1, arg2); |
| 318 |
} |
| 319 |
}; |
| 320 |
|
| 321 |
// Specialization for I=0 (end of recursion) |
| 322 |
template<typename TypeInfo, |
| 323 |
template <typename, typename> class Action, |
| 324 |
typename LAST_EXEC> |
| 325 |
struct ConstructorIterator<TypeInfo, Action, LAST_EXEC, 0> { |
| 326 |
|
| 327 |
// calculation of the context type |
| 328 |
typedef LAST_EXEC EXEC; |
| 329 |
|
| 330 |
// the exec(...) function |
| 331 |
__attribute__((always_inline)) inline static void exec() {} |
| 332 |
template<typename ARG_0> |
| 333 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 334 |
template<typename ARG_0, typename ARG_1> |
| 335 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 336 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 337 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 338 |
}; |
| 339 |
|
| 340 |
//------------------------------------------------------------------------------------------------------------------------------- |
| 341 |
|
| 342 |
template<typename TypeInfo, |
| 343 |
template <typename, typename> class Action, |
| 344 |
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action<typename SFINAE_CHECK::GetFirstDestructor<TypeInfo>::DestructorInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature |
| 345 |
unsigned I=TypeInfo::DESTRUCTORS> |
| 346 |
struct DestructorIterator { |
| 347 |
|
| 348 |
//member type info |
| 349 |
typedef typename TypeInfo::template Destructor<I-1> DESTRUCTOR_INFO; |
| 350 |
|
| 351 |
// calculation of the context type |
| 352 |
typedef typename DestructorIterator<TypeInfo, Action, LAST_EXEC, I-1>::EXEC PREV_EXEC; |
| 353 |
typedef typename SFINAE_CHECK::EXEC::GET< Action<DESTRUCTOR_INFO, PREV_EXEC> >::Type EXEC; |
| 354 |
|
| 355 |
// the exec(...) function |
| 356 |
__attribute__((always_inline)) inline static void exec() { |
| 357 |
DestructorIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(); |
| 358 |
Action<DESTRUCTOR_INFO, PREV_EXEC>::exec(); |
| 359 |
} |
| 360 |
template<typename ARG_0> |
| 361 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { |
| 362 |
DestructorIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(arg0); |
| 363 |
Action<DESTRUCTOR_INFO, PREV_EXEC>::exec(arg0); |
| 364 |
} |
| 365 |
template<typename ARG_0, typename ARG_1> |
| 366 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { |
| 367 |
DestructorIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(arg0, arg1); |
| 368 |
Action<DESTRUCTOR_INFO, PREV_EXEC>::exec(arg0, arg1); |
| 369 |
} |
| 370 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 371 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { |
| 372 |
DestructorIterator<TypeInfo, Action, LAST_EXEC, I-1>::exec(arg0, arg1, arg2); |
| 373 |
Action<DESTRUCTOR_INFO, PREV_EXEC>::exec(arg0, arg1, arg2); |
| 374 |
} |
| 375 |
}; |
| 376 |
|
| 377 |
// Specialization for I=0 (end of recursion) |
| 378 |
template<typename TypeInfo, |
| 379 |
template <typename, typename> class Action, |
| 380 |
typename LAST_EXEC> |
| 381 |
struct DestructorIterator<TypeInfo, Action, LAST_EXEC, 0> { |
| 382 |
|
| 383 |
// calculation of the context type |
| 384 |
typedef LAST_EXEC EXEC; |
| 385 |
|
| 386 |
// the exec(...) function |
| 387 |
__attribute__((always_inline)) inline static void exec() {} |
| 388 |
template<typename ARG_0> |
| 389 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 390 |
template<typename ARG_0, typename ARG_1> |
| 391 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 392 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 393 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 394 |
}; |
| 395 |
|
| 396 |
//------------------------------------------------------------------------------------------------------------------------------- |
| 397 |
|
| 398 |
|
| 399 |
template<typename TypeInfo, |
| 400 |
template <typename, typename> class Action, |
| 401 |
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action<typename SFINAE_CHECK::GetFirstMember<TypeInfo>::MemberInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature |
| 402 |
unsigned I=TypeInfo::BASECLASSES> |
| 403 |
struct BaseMemberIterator { |
| 404 |
|
| 405 |
//base type information |
| 406 |
typedef typename TypeInfo::template BaseClass<I-1>::Type BASE_TYPE; |
| 407 |
typedef AC::TypeInfo<BASE_TYPE> BASE_TYPE_INFO; |
| 408 |
|
| 409 |
// try to cast (a pointer) from TypeInfo::That* to BASE_TYPE* |
| 410 |
// if that fails, return the original value |
| 411 |
template<typename T> |
| 412 |
__attribute__((always_inline)) inline static T base_cast(T arg) { return arg; } |
| 413 |
__attribute__((always_inline)) inline static BASE_TYPE* base_cast(typename TypeInfo::That* arg) { |
| 414 |
return (BASE_TYPE*)arg; |
| 415 |
} |
| 416 |
__attribute__((always_inline)) inline static const BASE_TYPE* base_cast(const typename TypeInfo::That* arg) { |
| 417 |
return (const BASE_TYPE*)arg; |
| 418 |
} |
| 419 |
__attribute__((always_inline)) inline static volatile BASE_TYPE* base_cast(volatile typename TypeInfo::That* arg) { |
| 420 |
return (volatile BASE_TYPE*)arg; |
| 421 |
} |
| 422 |
__attribute__((always_inline)) inline static const volatile BASE_TYPE* base_cast(const volatile typename TypeInfo::That* arg) { |
| 423 |
return (const volatile BASE_TYPE*)arg; |
| 424 |
} |
| 425 |
|
| 426 |
// calculation of the context type |
| 427 |
typedef typename BaseMemberIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::EXEC PREV_EXEC; // recursion to the current base class |
| 428 |
typedef typename BaseMemberIterator<TypeInfo, Action, PREV_EXEC, I-1>::EXEC EXEC; // process next base class |
| 429 |
|
| 430 |
// the exec(...) function |
| 431 |
__attribute__((always_inline)) inline static void exec() { // rule: I > 0 |
| 432 |
BaseMemberIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec(); // recursion to the current base class |
| 433 |
BaseMemberIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(); // process next base class |
| 434 |
} |
| 435 |
template<typename ARG_0> |
| 436 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { // rule: I > 0 |
| 437 |
BaseMemberIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) ); // recursion to the current base class |
| 438 |
BaseMemberIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0); // process next base class |
| 439 |
} |
| 440 |
template<typename ARG_0, typename ARG_1> |
| 441 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { // rule: I > 0 |
| 442 |
BaseMemberIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) , base_cast(arg1) ); // recursion to the current base class |
| 443 |
BaseMemberIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0, arg1); // process next base class |
| 444 |
} |
| 445 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 446 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { // rule: I > 0 |
| 447 |
BaseMemberIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) , base_cast(arg1) , base_cast(arg2) ); // recursion to the current base class |
| 448 |
BaseMemberIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0, arg1, arg2); // process next base class |
| 449 |
} |
| 450 |
}; |
| 451 |
|
| 452 |
// Specialization for I=0 |
| 453 |
template<typename TypeInfo, |
| 454 |
template <typename, typename> class Action, |
| 455 |
typename LAST_EXEC> |
| 456 |
struct BaseMemberIterator<TypeInfo, Action, LAST_EXEC, 0> { |
| 457 |
|
| 458 |
// use the MemberIterator for now, as we reached a child node |
| 459 |
typedef MemberIterator<TypeInfo, Action, LAST_EXEC> MIT; |
| 460 |
|
| 461 |
// calculation of the context type |
| 462 |
typedef typename MIT::EXEC EXEC; |
| 463 |
|
| 464 |
// the exec(...) function |
| 465 |
__attribute__((always_inline)) inline static void exec() { |
| 466 |
MIT::exec(); |
| 467 |
} |
| 468 |
template<typename ARG_0> |
| 469 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { |
| 470 |
MIT::exec(arg0); |
| 471 |
} |
| 472 |
template<typename ARG_0, typename ARG_1> |
| 473 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { |
| 474 |
MIT::exec(arg0, arg1); |
| 475 |
} |
| 476 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 477 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { |
| 478 |
MIT::exec(arg0, arg1, arg2); |
| 479 |
} |
| 480 |
}; |
| 481 |
|
| 482 |
//------------------------------------------------------------------------------------------------------------------------------- |
| 483 |
|
| 484 |
|
| 485 |
template<typename TypeInfo, |
| 486 |
template <typename, typename> class Action, |
| 487 |
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action<typename SFINAE_CHECK::GetFirstFunction<TypeInfo>::FunctionInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature |
| 488 |
unsigned I=TypeInfo::BASECLASSES> |
| 489 |
struct BaseFunctionIterator { |
| 490 |
|
| 491 |
//base type information |
| 492 |
typedef typename TypeInfo::template BaseClass<I-1>::Type BASE_TYPE; |
| 493 |
typedef AC::TypeInfo<BASE_TYPE> BASE_TYPE_INFO; |
| 494 |
|
| 495 |
// try to cast (a pointer) from TypeInfo::That* to BASE_TYPE* |
| 496 |
// if that fails, return the original value |
| 497 |
template<typename T> |
| 498 |
__attribute__((always_inline)) inline static T base_cast(T arg) { return arg; } |
| 499 |
__attribute__((always_inline)) inline static BASE_TYPE* base_cast(typename TypeInfo::That* arg) { |
| 500 |
return (BASE_TYPE*)arg; |
| 501 |
} |
| 502 |
__attribute__((always_inline)) inline static const BASE_TYPE* base_cast(const typename TypeInfo::That* arg) { |
| 503 |
return (const BASE_TYPE*)arg; |
| 504 |
} |
| 505 |
__attribute__((always_inline)) inline static volatile BASE_TYPE* base_cast(volatile typename TypeInfo::That* arg) { |
| 506 |
return (volatile BASE_TYPE*)arg; |
| 507 |
} |
| 508 |
__attribute__((always_inline)) inline static const volatile BASE_TYPE* base_cast(const volatile typename TypeInfo::That* arg) { |
| 509 |
return (const volatile BASE_TYPE*)arg; |
| 510 |
} |
| 511 |
|
| 512 |
// calculation of the context type |
| 513 |
typedef typename BaseFunctionIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::EXEC PREV_EXEC; // recursion to the current base class |
| 514 |
typedef typename BaseFunctionIterator<TypeInfo, Action, PREV_EXEC, I-1>::EXEC EXEC; // process next base class |
| 515 |
|
| 516 |
// the exec(...) function |
| 517 |
__attribute__((always_inline)) inline static void exec() { // rule: I > 0 |
| 518 |
BaseFunctionIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec(); // recursion to the current base class |
| 519 |
BaseFunctionIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(); // process next base class |
| 520 |
} |
| 521 |
template<typename ARG_0> |
| 522 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { // rule: I > 0 |
| 523 |
BaseFunctionIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) ); // recursion to the current base class |
| 524 |
BaseFunctionIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0); // process next base class |
| 525 |
} |
| 526 |
template<typename ARG_0, typename ARG_1> |
| 527 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { // rule: I > 0 |
| 528 |
BaseFunctionIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) , base_cast(arg1) ); // recursion to the current base class |
| 529 |
BaseFunctionIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0, arg1); // process next base class |
| 530 |
} |
| 531 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 532 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { // rule: I > 0 |
| 533 |
BaseFunctionIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) , base_cast(arg1) , base_cast(arg2) ); // recursion to the current base class |
| 534 |
BaseFunctionIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0, arg1, arg2); // process next base class |
| 535 |
} |
| 536 |
}; |
| 537 |
|
| 538 |
// Specialization for I=0 |
| 539 |
template<typename TypeInfo, |
| 540 |
template <typename, typename> class Action, |
| 541 |
typename LAST_EXEC> |
| 542 |
struct BaseFunctionIterator<TypeInfo, Action, LAST_EXEC, 0> { |
| 543 |
|
| 544 |
// use the FunctionIterator for now, as we reached a child node |
| 545 |
typedef FunctionIterator<TypeInfo, Action, LAST_EXEC> FIT; |
| 546 |
|
| 547 |
// calculation of the context type |
| 548 |
typedef typename FIT::EXEC EXEC; |
| 549 |
|
| 550 |
// the exec(...) function |
| 551 |
__attribute__((always_inline)) inline static void exec() { |
| 552 |
FIT::exec(); |
| 553 |
} |
| 554 |
template<typename ARG_0> |
| 555 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { |
| 556 |
FIT::exec(arg0); |
| 557 |
} |
| 558 |
template<typename ARG_0, typename ARG_1> |
| 559 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { |
| 560 |
FIT::exec(arg0, arg1); |
| 561 |
} |
| 562 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 563 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { |
| 564 |
FIT::exec(arg0, arg1, arg2); |
| 565 |
} |
| 566 |
}; |
| 567 |
|
| 568 |
//------------------------------------------------------------------------------------------------------------------------------- |
| 569 |
|
| 570 |
|
| 571 |
template<typename TypeInfo, |
| 572 |
template <typename, typename> class Action, |
| 573 |
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action<typename SFINAE_CHECK::GetFirstConstructor<TypeInfo>::ConstructorInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature |
| 574 |
unsigned I=TypeInfo::BASECLASSES> |
| 575 |
struct BaseConstructorIterator { |
| 576 |
|
| 577 |
//base type information |
| 578 |
typedef typename TypeInfo::template BaseClass<I-1>::Type BASE_TYPE; |
| 579 |
typedef AC::TypeInfo<BASE_TYPE> BASE_TYPE_INFO; |
| 580 |
|
| 581 |
// try to cast (a pointer) from TypeInfo::That* to BASE_TYPE* |
| 582 |
// if that fails, return the original value |
| 583 |
template<typename T> |
| 584 |
__attribute__((always_inline)) inline static T base_cast(T arg) { return arg; } |
| 585 |
__attribute__((always_inline)) inline static BASE_TYPE* base_cast(typename TypeInfo::That* arg) { |
| 586 |
return (BASE_TYPE*)arg; |
| 587 |
} |
| 588 |
__attribute__((always_inline)) inline static const BASE_TYPE* base_cast(const typename TypeInfo::That* arg) { |
| 589 |
return (const BASE_TYPE*)arg; |
| 590 |
} |
| 591 |
__attribute__((always_inline)) inline static volatile BASE_TYPE* base_cast(volatile typename TypeInfo::That* arg) { |
| 592 |
return (volatile BASE_TYPE*)arg; |
| 593 |
} |
| 594 |
__attribute__((always_inline)) inline static const volatile BASE_TYPE* base_cast(const volatile typename TypeInfo::That* arg) { |
| 595 |
return (const volatile BASE_TYPE*)arg; |
| 596 |
} |
| 597 |
|
| 598 |
// calculation of the context type |
| 599 |
typedef typename BaseConstructorIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::EXEC PREV_EXEC; // recursion to the current base class |
| 600 |
typedef typename BaseConstructorIterator<TypeInfo, Action, PREV_EXEC, I-1>::EXEC EXEC; // process next base class |
| 601 |
|
| 602 |
// the exec(...) function |
| 603 |
__attribute__((always_inline)) inline static void exec() { // rule: I > 0 |
| 604 |
BaseConstructorIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec(); // recursion to the current base class |
| 605 |
BaseConstructorIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(); // process next base class |
| 606 |
} |
| 607 |
template<typename ARG_0> |
| 608 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { // rule: I > 0 |
| 609 |
BaseConstructorIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) ); // recursion to the current base class |
| 610 |
BaseConstructorIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0); // process next base class |
| 611 |
} |
| 612 |
template<typename ARG_0, typename ARG_1> |
| 613 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { // rule: I > 0 |
| 614 |
BaseConstructorIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) , base_cast(arg1) ); // recursion to the current base class |
| 615 |
BaseConstructorIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0, arg1); // process next base class |
| 616 |
} |
| 617 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 618 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { // rule: I > 0 |
| 619 |
BaseConstructorIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) , base_cast(arg1) , base_cast(arg2) ); // recursion to the current base class |
| 620 |
BaseConstructorIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0, arg1, arg2); // process next base class |
| 621 |
} |
| 622 |
}; |
| 623 |
|
| 624 |
// Specialization for I=0 |
| 625 |
template<typename TypeInfo, |
| 626 |
template <typename, typename> class Action, |
| 627 |
typename LAST_EXEC> |
| 628 |
struct BaseConstructorIterator<TypeInfo, Action, LAST_EXEC, 0> { |
| 629 |
|
| 630 |
// use the FunctionIterator for now, as we reached a child node |
| 631 |
typedef ConstructorIterator<TypeInfo, Action, LAST_EXEC> CIT; |
| 632 |
|
| 633 |
// calculation of the context type |
| 634 |
typedef typename CIT::EXEC EXEC; |
| 635 |
|
| 636 |
// the exec(...) function |
| 637 |
__attribute__((always_inline)) inline static void exec() { |
| 638 |
CIT::exec(); |
| 639 |
} |
| 640 |
template<typename ARG_0> |
| 641 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { |
| 642 |
CIT::exec(arg0); |
| 643 |
} |
| 644 |
template<typename ARG_0, typename ARG_1> |
| 645 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { |
| 646 |
CIT::exec(arg0, arg1); |
| 647 |
} |
| 648 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 649 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { |
| 650 |
CIT::exec(arg0, arg1, arg2); |
| 651 |
} |
| 652 |
}; |
| 653 |
|
| 654 |
//------------------------------------------------------------------------------------------------------------------------------- |
| 655 |
|
| 656 |
|
| 657 |
template<typename TypeInfo, |
| 658 |
template <typename, typename> class Action, |
| 659 |
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action<typename SFINAE_CHECK::GetFirstDestructor<TypeInfo>::DestructorInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature |
| 660 |
unsigned I=TypeInfo::BASECLASSES> |
| 661 |
struct BaseDestructorIterator { |
| 662 |
|
| 663 |
//base type information |
| 664 |
typedef typename TypeInfo::template BaseClass<I-1>::Type BASE_TYPE; |
| 665 |
typedef AC::TypeInfo<BASE_TYPE> BASE_TYPE_INFO; |
| 666 |
|
| 667 |
// try to cast (a pointer) from TypeInfo::That* to BASE_TYPE* |
| 668 |
// if that fails, return the original value |
| 669 |
template<typename T> |
| 670 |
__attribute__((always_inline)) inline static T base_cast(T arg) { return arg; } |
| 671 |
__attribute__((always_inline)) inline static BASE_TYPE* base_cast(typename TypeInfo::That* arg) { |
| 672 |
return (BASE_TYPE*)arg; |
| 673 |
} |
| 674 |
__attribute__((always_inline)) inline static const BASE_TYPE* base_cast(const typename TypeInfo::That* arg) { |
| 675 |
return (const BASE_TYPE*)arg; |
| 676 |
} |
| 677 |
__attribute__((always_inline)) inline static volatile BASE_TYPE* base_cast(volatile typename TypeInfo::That* arg) { |
| 678 |
return (volatile BASE_TYPE*)arg; |
| 679 |
} |
| 680 |
__attribute__((always_inline)) inline static const volatile BASE_TYPE* base_cast(const volatile typename TypeInfo::That* arg) { |
| 681 |
return (const volatile BASE_TYPE*)arg; |
| 682 |
} |
| 683 |
|
| 684 |
// calculation of the context type |
| 685 |
typedef typename BaseDestructorIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::EXEC PREV_EXEC; // recursion to the current base class |
| 686 |
typedef typename BaseDestructorIterator<TypeInfo, Action, PREV_EXEC, I-1>::EXEC EXEC; // process next base class |
| 687 |
|
| 688 |
// the exec(...) function |
| 689 |
__attribute__((always_inline)) inline static void exec() { // rule: I > 0 |
| 690 |
BaseDestructorIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec(); // recursion to the current base class |
| 691 |
BaseDestructorIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(); // process next base class |
| 692 |
} |
| 693 |
template<typename ARG_0> |
| 694 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { // rule: I > 0 |
| 695 |
BaseDestructorIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) ); // recursion to the current base class |
| 696 |
BaseDestructorIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0); // process next base class |
| 697 |
} |
| 698 |
template<typename ARG_0, typename ARG_1> |
| 699 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { // rule: I > 0 |
| 700 |
BaseDestructorIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) , base_cast(arg1) ); // recursion to the current base class |
| 701 |
BaseDestructorIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0, arg1); // process next base class |
| 702 |
} |
| 703 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 704 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { // rule: I > 0 |
| 705 |
BaseDestructorIterator<BASE_TYPE_INFO, Action, LAST_EXEC>::exec( base_cast(arg0) , base_cast(arg1) , base_cast(arg2) ); // recursion to the current base class |
| 706 |
BaseDestructorIterator<TypeInfo, Action, PREV_EXEC, I-1>::exec(arg0, arg1, arg2); // process next base class |
| 707 |
} |
| 708 |
}; |
| 709 |
|
| 710 |
// Specialization for I=0 |
| 711 |
template<typename TypeInfo, |
| 712 |
template <typename, typename> class Action, |
| 713 |
typename LAST_EXEC> |
| 714 |
struct BaseDestructorIterator<TypeInfo, Action, LAST_EXEC, 0> { |
| 715 |
|
| 716 |
// use the FunctionIterator for now, as we reached a child node |
| 717 |
typedef DestructorIterator<TypeInfo, Action, LAST_EXEC> DIT; |
| 718 |
|
| 719 |
// calculation of the context type |
| 720 |
typedef typename DIT::EXEC EXEC; |
| 721 |
|
| 722 |
// the exec(...) function |
| 723 |
__attribute__((always_inline)) inline static void exec() { |
| 724 |
DIT::exec(); |
| 725 |
} |
| 726 |
template<typename ARG_0> |
| 727 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { |
| 728 |
DIT::exec(arg0); |
| 729 |
} |
| 730 |
template<typename ARG_0, typename ARG_1> |
| 731 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { |
| 732 |
DIT::exec(arg0, arg1); |
| 733 |
} |
| 734 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 735 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { |
| 736 |
DIT::exec(arg0, arg1, arg2); |
| 737 |
} |
| 738 |
}; |
| 739 |
|
| 740 |
#else // __acweaving |
| 741 |
|
| 742 |
// These are dummy iterators to speed up the weaving phase (no recursion). |
| 743 |
// Thus, the real iterators get only instantiated once during the final compilation. |
| 744 |
|
| 745 |
template<typename TypeInfo, |
| 746 |
template <typename, typename> class Action, |
| 747 |
typename LAST_EXEC=void, |
| 748 |
unsigned I=0> |
| 749 |
struct BaseIterator { |
| 750 |
typedef typename SFINAE_CHECK::EXEC::GET< Action<TypeInfo, LAST_EXEC> >::Type EXEC; |
| 751 |
// the exec(...) function |
| 752 |
__attribute__((always_inline)) inline static void exec() {} |
| 753 |
template<typename ARG_0> |
| 754 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 755 |
template<typename ARG_0, typename ARG_1> |
| 756 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 757 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 758 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 759 |
}; |
| 760 |
|
| 761 |
template<typename TypeInfo, |
| 762 |
template <typename, typename> class Action, |
| 763 |
typename LAST_EXEC=void, |
| 764 |
unsigned I=0> |
| 765 |
struct MemberIterator { |
| 766 |
typedef typename SFINAE_CHECK::EXEC::GET< Action<typename SFINAE_CHECK::DummyMember<>, LAST_EXEC> >::Type EXEC; |
| 767 |
// the exec(...) function |
| 768 |
__attribute__((always_inline)) inline static void exec() {} |
| 769 |
template<typename ARG_0> |
| 770 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 771 |
template<typename ARG_0, typename ARG_1> |
| 772 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 773 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 774 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 775 |
}; |
| 776 |
|
| 777 |
template<typename TypeInfo, |
| 778 |
template <typename, typename> class Action, |
| 779 |
typename LAST_EXEC=void, |
| 780 |
unsigned I=0> |
| 781 |
struct FunctionIterator { |
| 782 |
typedef typename SFINAE_CHECK::EXEC::GET< Action<typename SFINAE_CHECK::DummyFunction<>, LAST_EXEC> >::Type EXEC; |
| 783 |
// the exec(...) function |
| 784 |
__attribute__((always_inline)) inline static void exec() {} |
| 785 |
template<typename ARG_0> |
| 786 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 787 |
template<typename ARG_0, typename ARG_1> |
| 788 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 789 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 790 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 791 |
}; |
| 792 |
|
| 793 |
template<typename TypeInfo, |
| 794 |
template <typename, typename> class Action, |
| 795 |
typename LAST_EXEC=void, |
| 796 |
unsigned I=0> |
| 797 |
struct ConstructorIterator { |
| 798 |
typedef typename SFINAE_CHECK::EXEC::GET< Action<typename SFINAE_CHECK::DummyConstructor<>, LAST_EXEC> >::Type EXEC; |
| 799 |
// the exec(...) function |
| 800 |
__attribute__((always_inline)) inline static void exec() {} |
| 801 |
template<typename ARG_0> |
| 802 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 803 |
template<typename ARG_0, typename ARG_1> |
| 804 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 805 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 806 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 807 |
}; |
| 808 |
|
| 809 |
template<typename TypeInfo, |
| 810 |
template <typename, typename> class Action, |
| 811 |
typename LAST_EXEC=void, |
| 812 |
unsigned I=0> |
| 813 |
struct DestructorIterator { |
| 814 |
typedef typename SFINAE_CHECK::EXEC::GET< Action<typename SFINAE_CHECK::DummyDestructor<>, LAST_EXEC> >::Type EXEC; |
| 815 |
// the exec(...) function |
| 816 |
__attribute__((always_inline)) inline static void exec() {} |
| 817 |
template<typename ARG_0> |
| 818 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 819 |
template<typename ARG_0, typename ARG_1> |
| 820 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 821 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 822 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 823 |
}; |
| 824 |
|
| 825 |
template<typename TypeInfo, |
| 826 |
template <typename, typename> class Action, |
| 827 |
typename LAST_EXEC=void, |
| 828 |
unsigned I=0> |
| 829 |
struct BaseMemberIterator { |
| 830 |
typedef typename MemberIterator<TypeInfo, Action, LAST_EXEC>::EXEC EXEC; |
| 831 |
// the exec(...) function |
| 832 |
__attribute__((always_inline)) inline static void exec() {} |
| 833 |
template<typename ARG_0> |
| 834 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 835 |
template<typename ARG_0, typename ARG_1> |
| 836 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 837 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 838 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 839 |
}; |
| 840 |
|
| 841 |
template<typename TypeInfo, |
| 842 |
template <typename, typename> class Action, |
| 843 |
typename LAST_EXEC=void, |
| 844 |
unsigned I=0> |
| 845 |
struct BaseFunctionIterator { |
| 846 |
typedef typename FunctionIterator<TypeInfo, Action, LAST_EXEC>::EXEC EXEC; |
| 847 |
// the exec(...) function |
| 848 |
__attribute__((always_inline)) inline static void exec() {} |
| 849 |
template<typename ARG_0> |
| 850 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 851 |
template<typename ARG_0, typename ARG_1> |
| 852 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 853 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 854 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 855 |
}; |
| 856 |
|
| 857 |
template<typename TypeInfo, |
| 858 |
template <typename, typename> class Action, |
| 859 |
typename LAST_EXEC=void, |
| 860 |
unsigned I=0> |
| 861 |
struct BaseConstructorIterator { |
| 862 |
typedef typename ConstructorIterator<TypeInfo, Action, LAST_EXEC>::EXEC EXEC; |
| 863 |
// the exec(...) function |
| 864 |
__attribute__((always_inline)) inline static void exec() {} |
| 865 |
template<typename ARG_0> |
| 866 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 867 |
template<typename ARG_0, typename ARG_1> |
| 868 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 869 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 870 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 871 |
}; |
| 872 |
|
| 873 |
template<typename TypeInfo, |
| 874 |
template <typename, typename> class Action, |
| 875 |
typename LAST_EXEC=void, |
| 876 |
unsigned I=0> |
| 877 |
struct BaseDestructorIterator { |
| 878 |
typedef typename DestructorIterator<TypeInfo, Action, LAST_EXEC>::EXEC EXEC; |
| 879 |
// the exec(...) function |
| 880 |
__attribute__((always_inline)) inline static void exec() {} |
| 881 |
template<typename ARG_0> |
| 882 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {} |
| 883 |
template<typename ARG_0, typename ARG_1> |
| 884 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {} |
| 885 |
template<typename ARG_0, typename ARG_1, typename ARG_2> |
| 886 |
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {} |
| 887 |
}; |
| 888 |
#endif // __acweaving |
| 889 |
|
| 890 |
} // namespace JPTL |
| 891 |
|
| 892 |
#endif // __JPTL_H__ |
| 893 |
|