// This file is part of the JoinPoint Template Library (JPTL)
//
// JPTL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// JPTL is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with JPTL. If not, see .
//
// Copyright (C) 2012-2014 Christoph Borchert
#ifndef __JPTL_H__
#define __JPTL_H__
namespace JPTL {
namespace SFINAE_CHECK {
namespace EXEC {
// static check, whether has an attribute 'EXEC'
template long ttest(...); // overload resolution matches always
template char ttest(typename T::EXEC const volatile *); // preferred by overload resolution
template(0))==sizeof(char))?1:0) >
struct GET {
typedef typename T::EXEC Type;
};
template
struct GET {
typedef void Type;
};
} // namespace EXEC
// For looking up EXEC, use this dummy ones if the real one has no members/functions
// FIXME: this needs maintenance if future ac++ versions change this structures
template struct DummyMember { typedef char Type; typedef AC::Referred::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"; } };
template struct DummyFunction { static const AC::Protection prot = AC::PROT_PRIVATE; static const AC::Specifiers spec = AC::SPEC_NONE; };
template struct DummyConstructor { static const AC::Protection prot = AC::PROT_PRIVATE; static const AC::Specifiers spec = AC::SPEC_NONE; };
template struct DummyDestructor { static const AC::Protection prot = AC::PROT_PRIVATE; static const AC::Specifiers spec = AC::SPEC_NONE; };
template
struct GetFirstMember {
typedef typename TypeInfo::template Member<0> MemberInfo;
};
template
struct GetFirstMember {
typedef DummyMember<> MemberInfo;
};
template
struct GetFirstFunction {
typedef typename TypeInfo::template Function<0> FunctionInfo;
};
template
struct GetFirstFunction {
typedef DummyFunction<> FunctionInfo;
};
template
struct GetFirstConstructor {
typedef typename TypeInfo::template Constructor<0> ConstructorInfo;
};
template
struct GetFirstConstructor {
typedef DummyConstructor<> ConstructorInfo;
};
template
struct GetFirstDestructor {
typedef typename TypeInfo::template Destructor<0> DestructorInfo;
};
template
struct GetFirstDestructor {
typedef DummyDestructor<> DestructorInfo;
};
} // namespace SFINAE_CHECK
//-------------------------------------------------------------------------------------------------------------------------------
#ifndef __acweaving
template class Action,
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature
unsigned I=TypeInfo::BASECLASSES>
struct BaseIterator {
//base type information
typedef typename TypeInfo::template BaseClass::Type BASE_TYPE;
typedef AC::TypeInfo BASE_TYPE_INFO;
// try to cast (a pointer) from TypeInfo::That* to BASE_TYPE*
// if that fails, return the original value
template
__attribute__((always_inline)) inline static T base_cast(T arg) { return arg; }
__attribute__((always_inline)) inline static BASE_TYPE* base_cast(typename TypeInfo::That* arg) {
return (BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static const BASE_TYPE* base_cast(const typename TypeInfo::That* arg) {
return (const BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static volatile BASE_TYPE* base_cast(volatile typename TypeInfo::That* arg) {
return (volatile BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static const volatile BASE_TYPE* base_cast(const volatile typename TypeInfo::That* arg) {
return (const volatile BASE_TYPE*)arg;
}
// calculation of the context type
typedef typename BaseIterator::EXEC PREV_EXEC; // recursion to the current base class
typedef typename BaseIterator::EXEC EXEC; // process next base class
// the exec(...) function
__attribute__((always_inline)) inline static void exec() { // rule: I > 0
BaseIterator::exec(); // recursion to the current base class
BaseIterator::exec(); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { // rule: I > 0
BaseIterator::exec( base_cast(arg0) ); // recursion to the current base class
BaseIterator::exec(arg0); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { // rule: I > 0
BaseIterator::exec( base_cast(arg0) , base_cast(arg1) ); // recursion to the current base class
BaseIterator::exec(arg0, arg1); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { // rule: I > 0
BaseIterator::exec( base_cast(arg0) , base_cast(arg1) , base_cast(arg2) ); // recursion to the current base class
BaseIterator::exec(arg0, arg1, arg2); // process next base class
}
};
// Specialization for I=0
template class Action,
typename LAST_EXEC>
struct BaseIterator {
// calculation of the context type
typedef typename SFINAE_CHECK::EXEC::GET< Action >::Type EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {
Action::exec();
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {
Action::exec(arg0);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {
Action::exec(arg0, arg1);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {
Action::exec(arg0, arg1, arg2);
}
};
//-------------------------------------------------------------------------------------------------------------------------------
template class Action,
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action::MemberInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature
unsigned I=TypeInfo::MEMBERS>
struct MemberIterator {
//member type info
typedef typename TypeInfo::template Member MEMBER_TYPE_INFO;
// calculation of the context type
typedef typename MemberIterator::EXEC PREV_EXEC;
typedef typename SFINAE_CHECK::EXEC::GET< Action >::Type EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {
MemberIterator::exec();
Action::exec();
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {
MemberIterator::exec(arg0);
Action::exec(arg0);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {
MemberIterator::exec(arg0, arg1);
Action::exec(arg0, arg1);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {
MemberIterator::exec(arg0, arg1, arg2);
Action::exec(arg0, arg1, arg2);
}
};
// Specialization for I=0 (end of recursion)
template class Action,
typename LAST_EXEC>
struct MemberIterator {
// calculation of the context type
typedef LAST_EXEC EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {}
};
//-------------------------------------------------------------------------------------------------------------------------------
template class Action,
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action::FunctionInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature
unsigned I=TypeInfo::FUNCTIONS>
struct FunctionIterator {
//member type info
typedef typename TypeInfo::template Function FUNCTION_INFO;
// calculation of the context type
typedef typename FunctionIterator::EXEC PREV_EXEC;
typedef typename SFINAE_CHECK::EXEC::GET< Action >::Type EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {
FunctionIterator::exec();
Action::exec();
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {
FunctionIterator::exec(arg0);
Action::exec(arg0);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {
FunctionIterator::exec(arg0, arg1);
Action::exec(arg0, arg1);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {
FunctionIterator::exec(arg0, arg1, arg2);
Action::exec(arg0, arg1, arg2);
}
};
// Specialization for I=0 (end of recursion)
template class Action,
typename LAST_EXEC>
struct FunctionIterator {
// calculation of the context type
typedef LAST_EXEC EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {}
};
//-------------------------------------------------------------------------------------------------------------------------------
template class Action,
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action::ConstructorInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature
unsigned I=TypeInfo::CONSTRUCTORS>
struct ConstructorIterator {
//member type info
typedef typename TypeInfo::template Constructor CONSTRUCTOR_INFO;
// calculation of the context type
typedef typename ConstructorIterator::EXEC PREV_EXEC;
typedef typename SFINAE_CHECK::EXEC::GET< Action >::Type EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {
ConstructorIterator::exec();
Action::exec();
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {
ConstructorIterator::exec(arg0);
Action::exec(arg0);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {
ConstructorIterator::exec(arg0, arg1);
Action::exec(arg0, arg1);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {
ConstructorIterator::exec(arg0, arg1, arg2);
Action::exec(arg0, arg1, arg2);
}
};
// Specialization for I=0 (end of recursion)
template class Action,
typename LAST_EXEC>
struct ConstructorIterator {
// calculation of the context type
typedef LAST_EXEC EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {}
};
//-------------------------------------------------------------------------------------------------------------------------------
template class Action,
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action::DestructorInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature
unsigned I=TypeInfo::DESTRUCTORS>
struct DestructorIterator {
//member type info
typedef typename TypeInfo::template Destructor DESTRUCTOR_INFO;
// calculation of the context type
typedef typename DestructorIterator::EXEC PREV_EXEC;
typedef typename SFINAE_CHECK::EXEC::GET< Action >::Type EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {
DestructorIterator::exec();
Action::exec();
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {
DestructorIterator::exec(arg0);
Action::exec(arg0);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {
DestructorIterator::exec(arg0, arg1);
Action::exec(arg0, arg1);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {
DestructorIterator::exec(arg0, arg1, arg2);
Action::exec(arg0, arg1, arg2);
}
};
// Specialization for I=0 (end of recursion)
template class Action,
typename LAST_EXEC>
struct DestructorIterator {
// calculation of the context type
typedef LAST_EXEC EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {}
};
//-------------------------------------------------------------------------------------------------------------------------------
template class Action,
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action::MemberInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature
unsigned I=TypeInfo::BASECLASSES>
struct BaseMemberIterator {
//base type information
typedef typename TypeInfo::template BaseClass::Type BASE_TYPE;
typedef AC::TypeInfo BASE_TYPE_INFO;
// try to cast (a pointer) from TypeInfo::That* to BASE_TYPE*
// if that fails, return the original value
template
__attribute__((always_inline)) inline static T base_cast(T arg) { return arg; }
__attribute__((always_inline)) inline static BASE_TYPE* base_cast(typename TypeInfo::That* arg) {
return (BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static const BASE_TYPE* base_cast(const typename TypeInfo::That* arg) {
return (const BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static volatile BASE_TYPE* base_cast(volatile typename TypeInfo::That* arg) {
return (volatile BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static const volatile BASE_TYPE* base_cast(const volatile typename TypeInfo::That* arg) {
return (const volatile BASE_TYPE*)arg;
}
// calculation of the context type
typedef typename BaseMemberIterator::EXEC PREV_EXEC; // recursion to the current base class
typedef typename BaseMemberIterator::EXEC EXEC; // process next base class
// the exec(...) function
__attribute__((always_inline)) inline static void exec() { // rule: I > 0
BaseMemberIterator::exec(); // recursion to the current base class
BaseMemberIterator::exec(); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { // rule: I > 0
BaseMemberIterator::exec( base_cast(arg0) ); // recursion to the current base class
BaseMemberIterator::exec(arg0); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { // rule: I > 0
BaseMemberIterator::exec( base_cast(arg0) , base_cast(arg1) ); // recursion to the current base class
BaseMemberIterator::exec(arg0, arg1); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { // rule: I > 0
BaseMemberIterator::exec( base_cast(arg0) , base_cast(arg1) , base_cast(arg2) ); // recursion to the current base class
BaseMemberIterator::exec(arg0, arg1, arg2); // process next base class
}
};
// Specialization for I=0
template class Action,
typename LAST_EXEC>
struct BaseMemberIterator {
// use the MemberIterator for now, as we reached a child node
typedef MemberIterator MIT;
// calculation of the context type
typedef typename MIT::EXEC EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {
MIT::exec();
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {
MIT::exec(arg0);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {
MIT::exec(arg0, arg1);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {
MIT::exec(arg0, arg1, arg2);
}
};
//-------------------------------------------------------------------------------------------------------------------------------
template class Action,
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action::FunctionInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature
unsigned I=TypeInfo::BASECLASSES>
struct BaseFunctionIterator {
//base type information
typedef typename TypeInfo::template BaseClass::Type BASE_TYPE;
typedef AC::TypeInfo BASE_TYPE_INFO;
// try to cast (a pointer) from TypeInfo::That* to BASE_TYPE*
// if that fails, return the original value
template
__attribute__((always_inline)) inline static T base_cast(T arg) { return arg; }
__attribute__((always_inline)) inline static BASE_TYPE* base_cast(typename TypeInfo::That* arg) {
return (BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static const BASE_TYPE* base_cast(const typename TypeInfo::That* arg) {
return (const BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static volatile BASE_TYPE* base_cast(volatile typename TypeInfo::That* arg) {
return (volatile BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static const volatile BASE_TYPE* base_cast(const volatile typename TypeInfo::That* arg) {
return (const volatile BASE_TYPE*)arg;
}
// calculation of the context type
typedef typename BaseFunctionIterator::EXEC PREV_EXEC; // recursion to the current base class
typedef typename BaseFunctionIterator::EXEC EXEC; // process next base class
// the exec(...) function
__attribute__((always_inline)) inline static void exec() { // rule: I > 0
BaseFunctionIterator::exec(); // recursion to the current base class
BaseFunctionIterator::exec(); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { // rule: I > 0
BaseFunctionIterator::exec( base_cast(arg0) ); // recursion to the current base class
BaseFunctionIterator::exec(arg0); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { // rule: I > 0
BaseFunctionIterator::exec( base_cast(arg0) , base_cast(arg1) ); // recursion to the current base class
BaseFunctionIterator::exec(arg0, arg1); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { // rule: I > 0
BaseFunctionIterator::exec( base_cast(arg0) , base_cast(arg1) , base_cast(arg2) ); // recursion to the current base class
BaseFunctionIterator::exec(arg0, arg1, arg2); // process next base class
}
};
// Specialization for I=0
template class Action,
typename LAST_EXEC>
struct BaseFunctionIterator {
// use the FunctionIterator for now, as we reached a child node
typedef FunctionIterator FIT;
// calculation of the context type
typedef typename FIT::EXEC EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {
FIT::exec();
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {
FIT::exec(arg0);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {
FIT::exec(arg0, arg1);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {
FIT::exec(arg0, arg1, arg2);
}
};
//-------------------------------------------------------------------------------------------------------------------------------
template class Action,
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action::ConstructorInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature
unsigned I=TypeInfo::BASECLASSES>
struct BaseConstructorIterator {
//base type information
typedef typename TypeInfo::template BaseClass::Type BASE_TYPE;
typedef AC::TypeInfo BASE_TYPE_INFO;
// try to cast (a pointer) from TypeInfo::That* to BASE_TYPE*
// if that fails, return the original value
template
__attribute__((always_inline)) inline static T base_cast(T arg) { return arg; }
__attribute__((always_inline)) inline static BASE_TYPE* base_cast(typename TypeInfo::That* arg) {
return (BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static const BASE_TYPE* base_cast(const typename TypeInfo::That* arg) {
return (const BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static volatile BASE_TYPE* base_cast(volatile typename TypeInfo::That* arg) {
return (volatile BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static const volatile BASE_TYPE* base_cast(const volatile typename TypeInfo::That* arg) {
return (const volatile BASE_TYPE*)arg;
}
// calculation of the context type
typedef typename BaseConstructorIterator::EXEC PREV_EXEC; // recursion to the current base class
typedef typename BaseConstructorIterator::EXEC EXEC; // process next base class
// the exec(...) function
__attribute__((always_inline)) inline static void exec() { // rule: I > 0
BaseConstructorIterator::exec(); // recursion to the current base class
BaseConstructorIterator::exec(); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { // rule: I > 0
BaseConstructorIterator::exec( base_cast(arg0) ); // recursion to the current base class
BaseConstructorIterator::exec(arg0); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { // rule: I > 0
BaseConstructorIterator::exec( base_cast(arg0) , base_cast(arg1) ); // recursion to the current base class
BaseConstructorIterator::exec(arg0, arg1); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { // rule: I > 0
BaseConstructorIterator::exec( base_cast(arg0) , base_cast(arg1) , base_cast(arg2) ); // recursion to the current base class
BaseConstructorIterator::exec(arg0, arg1, arg2); // process next base class
}
};
// Specialization for I=0
template class Action,
typename LAST_EXEC>
struct BaseConstructorIterator {
// use the FunctionIterator for now, as we reached a child node
typedef ConstructorIterator CIT;
// calculation of the context type
typedef typename CIT::EXEC EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {
CIT::exec();
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {
CIT::exec(arg0);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {
CIT::exec(arg0, arg1);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {
CIT::exec(arg0, arg1, arg2);
}
};
//-------------------------------------------------------------------------------------------------------------------------------
template class Action,
typename LAST_EXEC=typename SFINAE_CHECK::EXEC::GET< Action::DestructorInfo, void> >::Type, // look for EXEC in Action<...> //TODO: improve readability of this particular feature
unsigned I=TypeInfo::BASECLASSES>
struct BaseDestructorIterator {
//base type information
typedef typename TypeInfo::template BaseClass::Type BASE_TYPE;
typedef AC::TypeInfo BASE_TYPE_INFO;
// try to cast (a pointer) from TypeInfo::That* to BASE_TYPE*
// if that fails, return the original value
template
__attribute__((always_inline)) inline static T base_cast(T arg) { return arg; }
__attribute__((always_inline)) inline static BASE_TYPE* base_cast(typename TypeInfo::That* arg) {
return (BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static const BASE_TYPE* base_cast(const typename TypeInfo::That* arg) {
return (const BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static volatile BASE_TYPE* base_cast(volatile typename TypeInfo::That* arg) {
return (volatile BASE_TYPE*)arg;
}
__attribute__((always_inline)) inline static const volatile BASE_TYPE* base_cast(const volatile typename TypeInfo::That* arg) {
return (const volatile BASE_TYPE*)arg;
}
// calculation of the context type
typedef typename BaseDestructorIterator::EXEC PREV_EXEC; // recursion to the current base class
typedef typename BaseDestructorIterator::EXEC EXEC; // process next base class
// the exec(...) function
__attribute__((always_inline)) inline static void exec() { // rule: I > 0
BaseDestructorIterator::exec(); // recursion to the current base class
BaseDestructorIterator::exec(); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) { // rule: I > 0
BaseDestructorIterator::exec( base_cast(arg0) ); // recursion to the current base class
BaseDestructorIterator::exec(arg0); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) { // rule: I > 0
BaseDestructorIterator::exec( base_cast(arg0) , base_cast(arg1) ); // recursion to the current base class
BaseDestructorIterator::exec(arg0, arg1); // process next base class
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) { // rule: I > 0
BaseDestructorIterator::exec( base_cast(arg0) , base_cast(arg1) , base_cast(arg2) ); // recursion to the current base class
BaseDestructorIterator::exec(arg0, arg1, arg2); // process next base class
}
};
// Specialization for I=0
template class Action,
typename LAST_EXEC>
struct BaseDestructorIterator {
// use the FunctionIterator for now, as we reached a child node
typedef DestructorIterator DIT;
// calculation of the context type
typedef typename DIT::EXEC EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {
DIT::exec();
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {
DIT::exec(arg0);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {
DIT::exec(arg0, arg1);
}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {
DIT::exec(arg0, arg1, arg2);
}
};
#else // __acweaving
// These are dummy iterators to speed up the weaving phase (no recursion).
// Thus, the real iterators get only instantiated once during the final compilation.
template class Action,
typename LAST_EXEC=void,
unsigned I=0>
struct BaseIterator {
typedef typename SFINAE_CHECK::EXEC::GET< Action >::Type EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {}
};
template class Action,
typename LAST_EXEC=void,
unsigned I=0>
struct MemberIterator {
typedef typename SFINAE_CHECK::EXEC::GET< Action, LAST_EXEC> >::Type EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {}
};
template class Action,
typename LAST_EXEC=void,
unsigned I=0>
struct FunctionIterator {
typedef typename SFINAE_CHECK::EXEC::GET< Action, LAST_EXEC> >::Type EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {}
};
template class Action,
typename LAST_EXEC=void,
unsigned I=0>
struct ConstructorIterator {
typedef typename SFINAE_CHECK::EXEC::GET< Action, LAST_EXEC> >::Type EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1) {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0, ARG_1 arg1, ARG_2 arg2) {}
};
template class Action,
typename LAST_EXEC=void,
unsigned I=0>
struct DestructorIterator {
typedef typename SFINAE_CHECK::EXEC::GET< Action, LAST_EXEC> >::Type EXEC;
// the exec(...) function
__attribute__((always_inline)) inline static void exec() {}
template
__attribute__((always_inline)) inline static void exec(ARG_0 arg0) {}
template