Added explicit void specialization in callbacks

One limitation of C++ is that implicit casts do not occur when
matching template overloads, as a consequence the callback's
argument type requires a strict match.

Unfortunately, the prevents the previously common pattern of using
void pointers as function arguments, causing unnecessary problems
for users porting code.

        Thing *t;
        void doit(void *p) { blablabla }

        Callback<void()> cb(t, doit);

To avoid this, explicit overloads on void pointers were added. This
avoids a template expansion, and allows the implicit cast to occur
as the user would expect.
pull/2549/head
Christopher Haster 2016-08-25 12:25:01 -05:00
parent 5c0f39f190
commit 756a09003c
3 changed files with 1292 additions and 136 deletions

View File

@ -8,17 +8,23 @@ using namespace utest::v1;
// static functions
template <typename T>
T static_func0() { return 0; }
T static_func0()
{ return 0; }
template <typename T>
T static_func1(T a0) { return 0 | a0; }
T static_func1(T a0)
{ return 0 | a0; }
template <typename T>
T static_func2(T a0, T a1) { return 0 | a0 | a1; }
T static_func2(T a0, T a1)
{ return 0 | a0 | a1; }
template <typename T>
T static_func3(T a0, T a1, T a2) { return 0 | a0 | a1 | a2; }
T static_func3(T a0, T a1, T a2)
{ return 0 | a0 | a1 | a2; }
template <typename T>
T static_func4(T a0, T a1, T a2, T a3) { return 0 | a0 | a1 | a2 | a3; }
T static_func4(T a0, T a1, T a2, T a3)
{ return 0 | a0 | a1 | a2 | a3; }
template <typename T>
T static_func5(T a0, T a1, T a2, T a3, T a4) { return 0 | a0 | a1 | a2 | a3 | a4; }
T static_func5(T a0, T a1, T a2, T a3, T a4)
{ return 0 | a0 | a1 | a2 | a3 | a4; }
// class functions
template <typename T>
@ -26,90 +32,206 @@ struct Thing {
T t;
Thing() : t(0x80) {}
T member_func0() { return t; }
T member_func1(T a0) { return t | a0; }
T member_func2(T a0, T a1) { return t | a0 | a1; }
T member_func3(T a0, T a1, T a2) { return t | a0 | a1 | a2; }
T member_func4(T a0, T a1, T a2, T a3) { return t | a0 | a1 | a2 | a3; }
T member_func5(T a0, T a1, T a2, T a3, T a4) { return t | a0 | a1 | a2 | a3 | a4; }
T member_func0()
{ return t; }
T member_func1(T a0)
{ return t | a0; }
T member_func2(T a0, T a1)
{ return t | a0 | a1; }
T member_func3(T a0, T a1, T a2)
{ return t | a0 | a1 | a2; }
T member_func4(T a0, T a1, T a2, T a3)
{ return t | a0 | a1 | a2 | a3; }
T member_func5(T a0, T a1, T a2, T a3, T a4)
{ return t | a0 | a1 | a2 | a3 | a4; }
T const_member_func0() const { return t; }
T const_member_func1(T a0) const { return t | a0; }
T const_member_func2(T a0, T a1) const { return t | a0 | a1; }
T const_member_func3(T a0, T a1, T a2) const { return t | a0 | a1 | a2; }
T const_member_func4(T a0, T a1, T a2, T a3) const { return t | a0 | a1 | a2 | a3; }
T const_member_func5(T a0, T a1, T a2, T a3, T a4) const { return t | a0 | a1 | a2 | a3 | a4; }
T const_member_func0() const
{ return t; }
T const_member_func1(T a0) const
{ return t | a0; }
T const_member_func2(T a0, T a1) const
{ return t | a0 | a1; }
T const_member_func3(T a0, T a1, T a2) const
{ return t | a0 | a1 | a2; }
T const_member_func4(T a0, T a1, T a2, T a3) const
{ return t | a0 | a1 | a2 | a3; }
T const_member_func5(T a0, T a1, T a2, T a3, T a4) const
{ return t | a0 | a1 | a2 | a3 | a4; }
T volatile_member_func0() volatile { return t; }
T volatile_member_func1(T a0) volatile { return t | a0; }
T volatile_member_func2(T a0, T a1) volatile { return t | a0 | a1; }
T volatile_member_func3(T a0, T a1, T a2) volatile { return t | a0 | a1 | a2; }
T volatile_member_func4(T a0, T a1, T a2, T a3) volatile { return t | a0 | a1 | a2 | a3; }
T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile { return t | a0 | a1 | a2 | a3 | a4; }
T volatile_member_func0() volatile
{ return t; }
T volatile_member_func1(T a0) volatile
{ return t | a0; }
T volatile_member_func2(T a0, T a1) volatile
{ return t | a0 | a1; }
T volatile_member_func3(T a0, T a1, T a2) volatile
{ return t | a0 | a1 | a2; }
T volatile_member_func4(T a0, T a1, T a2, T a3) volatile
{ return t | a0 | a1 | a2 | a3; }
T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile
{ return t | a0 | a1 | a2 | a3 | a4; }
T const_volatile_member_func0() const volatile { return t; }
T const_volatile_member_func1(T a0) const volatile { return t | a0; }
T const_volatile_member_func2(T a0, T a1) const volatile { return t | a0 | a1; }
T const_volatile_member_func3(T a0, T a1, T a2) const volatile { return t | a0 | a1 | a2; }
T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile { return t | a0 | a1 | a2 | a3; }
T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile { return t | a0 | a1 | a2 | a3 | a4; }
T const_volatile_member_func0() const volatile
{ return t; }
T const_volatile_member_func1(T a0) const volatile
{ return t | a0; }
T const_volatile_member_func2(T a0, T a1) const volatile
{ return t | a0 | a1; }
T const_volatile_member_func3(T a0, T a1, T a2) const volatile
{ return t | a0 | a1 | a2; }
T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile
{ return t | a0 | a1 | a2 | a3; }
T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile
{ return t | a0 | a1 | a2 | a3 | a4; }
};
// bound functions
template <typename T>
T bound_func0(Thing<T> *t) { return t->t; }
T bound_func0(Thing<T> *t)
{ return t->t; }
template <typename T>
T bound_func1(Thing<T> *t, T a0) { return t->t | a0; }
T bound_func1(Thing<T> *t, T a0)
{ return t->t | a0; }
template <typename T>
T bound_func2(Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
T bound_func2(Thing<T> *t, T a0, T a1)
{ return t->t | a0 | a1; }
template <typename T>
T bound_func3(Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
T bound_func3(Thing<T> *t, T a0, T a1, T a2)
{ return t->t | a0 | a1 | a2; }
template <typename T>
T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3)
{ return t->t | a0 | a1 | a2 | a3; }
template <typename T>
T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
{ return t->t | a0 | a1 | a2 | a3 | a4; }
template <typename T>
T const_bound_func0(const Thing<T> *t)
{ return t->t; }
template <typename T>
T const_bound_func1(const Thing<T> *t, T a0)
{ return t->t | a0; }
template <typename T>
T const_bound_func2(const Thing<T> *t, T a0, T a1)
{ return t->t | a0 | a1; }
template <typename T>
T const_bound_func3(const Thing<T> *t, T a0, T a1, T a2)
{ return t->t | a0 | a1 | a2; }
template <typename T>
T const_bound_func4(const Thing<T> *t, T a0, T a1, T a2, T a3)
{ return t->t | a0 | a1 | a2 | a3; }
template <typename T>
T const_bound_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
{ return t->t | a0 | a1 | a2 | a3 | a4; }
template <typename T>
T volatile_bound_func0(volatile Thing<T> *t)
{ return t->t; }
template <typename T>
T volatile_bound_func1(volatile Thing<T> *t, T a0)
{ return t->t | a0; }
template <typename T>
T volatile_bound_func2(volatile Thing<T> *t, T a0, T a1)
{ return t->t | a0 | a1; }
template <typename T>
T volatile_bound_func3(volatile Thing<T> *t, T a0, T a1, T a2)
{ return t->t | a0 | a1 | a2; }
template <typename T>
T volatile_bound_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3)
{ return t->t | a0 | a1 | a2 | a3; }
template <typename T>
T volatile_bound_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
{ return t->t | a0 | a1 | a2 | a3 | a4; }
template <typename T>
T const_volatile_bound_func0(const volatile Thing<T> *t)
{ return t->t; }
template <typename T>
T const_volatile_bound_func1(const volatile Thing<T> *t, T a0)
{ return t->t | a0; }
template <typename T>
T const_volatile_bound_func2(const volatile Thing<T> *t, T a0, T a1)
{ return t->t | a0 | a1; }
template <typename T>
T const_volatile_bound_func3(const volatile Thing<T> *t, T a0, T a1, T a2)
{ return t->t | a0 | a1 | a2; }
template <typename T>
T const_volatile_bound_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3)
{ return t->t | a0 | a1 | a2 | a3; }
template <typename T>
T const_volatile_bound_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
{ return t->t | a0 | a1 | a2 | a3 | a4; }
// const bound functions
// void functions
template <typename T>
T const_func0(const Thing<T> *t) { return t->t; }
T void_func0(void *t)
{ return static_cast<Thing<T>*>(t)->t; }
template <typename T>
T const_func1(const Thing<T> *t, T a0) { return t->t | a0; }
T void_func1(void *t, T a0)
{ return static_cast<Thing<T>*>(t)->t | a0; }
template <typename T>
T const_func2(const Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
T void_func2(void *t, T a0, T a1)
{ return static_cast<Thing<T>*>(t)->t | a0 | a1; }
template <typename T>
T const_func3(const Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
T void_func3(void *t, T a0, T a1, T a2)
{ return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2; }
template <typename T>
T const_func4(const Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
T void_func4(void *t, T a0, T a1, T a2, T a3)
{ return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
template <typename T>
T const_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
// volatile bound functions
T void_func5(void *t, T a0, T a1, T a2, T a3, T a4)
{ return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
template <typename T>
T volatile_func0(volatile Thing<T> *t) { return t->t; }
T const_void_func0(const void *t)
{ return static_cast<const Thing<T>*>(t)->t; }
template <typename T>
T volatile_func1(volatile Thing<T> *t, T a0) { return t->t | a0; }
T const_void_func1(const void *t, T a0)
{ return static_cast<const Thing<T>*>(t)->t | a0; }
template <typename T>
T volatile_func2(volatile Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
T const_void_func2(const void *t, T a0, T a1)
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1; }
template <typename T>
T volatile_func3(volatile Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
T const_void_func3(const void *t, T a0, T a1, T a2)
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2; }
template <typename T>
T volatile_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
T const_void_func4(const void *t, T a0, T a1, T a2, T a3)
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
template <typename T>
T volatile_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
// const volatile bound functions
T const_void_func5(const void *t, T a0, T a1, T a2, T a3, T a4)
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
template <typename T>
T const_volatile_func0(const volatile Thing<T> *t) { return t->t; }
T volatile_void_func0(volatile void *t)
{ return static_cast<volatile Thing<T>*>(t)->t; }
template <typename T>
T const_volatile_func1(const volatile Thing<T> *t, T a0) { return t->t | a0; }
T volatile_void_func1(volatile void *t, T a0)
{ return static_cast<volatile Thing<T>*>(t)->t | a0; }
template <typename T>
T const_volatile_func2(const volatile Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
T volatile_void_func2(volatile void *t, T a0, T a1)
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1; }
template <typename T>
T const_volatile_func3(const volatile Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
T volatile_void_func3(volatile void *t, T a0, T a1, T a2)
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2; }
template <typename T>
T const_volatile_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
T volatile_void_func4(volatile void *t, T a0, T a1, T a2, T a3)
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
template <typename T>
T const_volatile_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
T volatile_void_func5(volatile void *t, T a0, T a1, T a2, T a3, T a4)
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
template <typename T>
T const_volatile_void_func0(const volatile void *t)
{ return static_cast<const volatile Thing<T>*>(t)->t; }
template <typename T>
T const_volatile_void_func1(const volatile void *t, T a0)
{ return static_cast<const volatile Thing<T>*>(t)->t | a0; }
template <typename T>
T const_volatile_void_func2(const volatile void *t, T a0, T a1)
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1; }
template <typename T>
T const_volatile_void_func3(const volatile void *t, T a0, T a1, T a2)
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2; }
template <typename T>
T const_volatile_void_func4(const volatile void *t, T a0, T a1, T a2, T a3)
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
template <typename T>
T const_volatile_void_func5(const volatile void *t, T a0, T a1, T a2, T a3, T a4)
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
// function call and result verification
@ -199,9 +321,13 @@ void test_dispatch0() {
Verifier<T>::verify0((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func0);
Verifier<T>::verify0((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func0);
Verifier<T>::verify0(&thing, &bound_func0<T>);
Verifier<T>::verify0((const Thing<T>*)&thing, &const_func0<T>);
Verifier<T>::verify0((volatile Thing<T>*)&thing, &volatile_func0<T>);
Verifier<T>::verify0((const volatile Thing<T>*)&thing, &const_volatile_func0<T>);
Verifier<T>::verify0((const Thing<T>*)&thing, &const_bound_func0<T>);
Verifier<T>::verify0((volatile Thing<T>*)&thing, &volatile_bound_func0<T>);
Verifier<T>::verify0((const volatile Thing<T>*)&thing, &const_volatile_bound_func0<T>);
Verifier<T>::verify0(&thing, &void_func0<T>);
Verifier<T>::verify0((const Thing<T>*)&thing, &const_void_func0<T>);
Verifier<T>::verify0((volatile Thing<T>*)&thing, &volatile_void_func0<T>);
Verifier<T>::verify0((const volatile Thing<T>*)&thing, &const_volatile_void_func0<T>);
Verifier<T>::verify0(callback(static_func0<T>));
Callback<T()> cb(static_func0);
@ -222,9 +348,13 @@ void test_dispatch1() {
Verifier<T>::verify1((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func1);
Verifier<T>::verify1((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func1);
Verifier<T>::verify1(&thing, &bound_func1<T>);
Verifier<T>::verify1((const Thing<T>*)&thing, &const_func1<T>);
Verifier<T>::verify1((volatile Thing<T>*)&thing, &volatile_func1<T>);
Verifier<T>::verify1((const volatile Thing<T>*)&thing, &const_volatile_func1<T>);
Verifier<T>::verify1((const Thing<T>*)&thing, &const_bound_func1<T>);
Verifier<T>::verify1((volatile Thing<T>*)&thing, &volatile_bound_func1<T>);
Verifier<T>::verify1((const volatile Thing<T>*)&thing, &const_volatile_bound_func1<T>);
Verifier<T>::verify1(&thing, &void_func1<T>);
Verifier<T>::verify1((const Thing<T>*)&thing, &const_void_func1<T>);
Verifier<T>::verify1((volatile Thing<T>*)&thing, &volatile_void_func1<T>);
Verifier<T>::verify1((const volatile Thing<T>*)&thing, &const_volatile_void_func1<T>);
Verifier<T>::verify1(callback(static_func1<T>));
Callback<T(T)> cb(static_func1);
@ -245,9 +375,13 @@ void test_dispatch2() {
Verifier<T>::verify2((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func2);
Verifier<T>::verify2((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func2);
Verifier<T>::verify2(&thing, &bound_func2<T>);
Verifier<T>::verify2((const Thing<T>*)&thing, &const_func2<T>);
Verifier<T>::verify2((volatile Thing<T>*)&thing, &volatile_func2<T>);
Verifier<T>::verify2((const volatile Thing<T>*)&thing, &const_volatile_func2<T>);
Verifier<T>::verify2((const Thing<T>*)&thing, &const_bound_func2<T>);
Verifier<T>::verify2((volatile Thing<T>*)&thing, &volatile_bound_func2<T>);
Verifier<T>::verify2((const volatile Thing<T>*)&thing, &const_volatile_bound_func2<T>);
Verifier<T>::verify2(&thing, &void_func2<T>);
Verifier<T>::verify2((const Thing<T>*)&thing, &const_void_func2<T>);
Verifier<T>::verify2((volatile Thing<T>*)&thing, &volatile_void_func2<T>);
Verifier<T>::verify2((const volatile Thing<T>*)&thing, &const_volatile_void_func2<T>);
Verifier<T>::verify2(callback(static_func2<T>));
Callback<T(T, T)> cb(static_func2);
@ -268,9 +402,13 @@ void test_dispatch3() {
Verifier<T>::verify3((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func3);
Verifier<T>::verify3((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func3);
Verifier<T>::verify3(&thing, &bound_func3<T>);
Verifier<T>::verify3((const Thing<T>*)&thing, &const_func3<T>);
Verifier<T>::verify3((volatile Thing<T>*)&thing, &volatile_func3<T>);
Verifier<T>::verify3((const volatile Thing<T>*)&thing, &const_volatile_func3<T>);
Verifier<T>::verify3((const Thing<T>*)&thing, &const_bound_func3<T>);
Verifier<T>::verify3((volatile Thing<T>*)&thing, &volatile_bound_func3<T>);
Verifier<T>::verify3((const volatile Thing<T>*)&thing, &const_volatile_bound_func3<T>);
Verifier<T>::verify3(&thing, &void_func3<T>);
Verifier<T>::verify3((const Thing<T>*)&thing, &const_void_func3<T>);
Verifier<T>::verify3((volatile Thing<T>*)&thing, &volatile_void_func3<T>);
Verifier<T>::verify3((const volatile Thing<T>*)&thing, &const_volatile_void_func3<T>);
Verifier<T>::verify3(callback(static_func3<T>));
Callback<T(T, T, T)> cb(static_func3);
@ -291,9 +429,13 @@ void test_dispatch4() {
Verifier<T>::verify4((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func4);
Verifier<T>::verify4((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func4);
Verifier<T>::verify4(&thing, &bound_func4<T>);
Verifier<T>::verify4((const Thing<T>*)&thing, &const_func4<T>);
Verifier<T>::verify4((volatile Thing<T>*)&thing, &volatile_func4<T>);
Verifier<T>::verify4((const volatile Thing<T>*)&thing, &const_volatile_func4<T>);
Verifier<T>::verify4((const Thing<T>*)&thing, &const_bound_func4<T>);
Verifier<T>::verify4((volatile Thing<T>*)&thing, &volatile_bound_func4<T>);
Verifier<T>::verify4((const volatile Thing<T>*)&thing, &const_volatile_bound_func4<T>);
Verifier<T>::verify4(&thing, &void_func4<T>);
Verifier<T>::verify4((const Thing<T>*)&thing, &const_void_func4<T>);
Verifier<T>::verify4((volatile Thing<T>*)&thing, &volatile_void_func4<T>);
Verifier<T>::verify4((const volatile Thing<T>*)&thing, &const_volatile_void_func4<T>);
Verifier<T>::verify4(callback(static_func4<T>));
Callback<T(T, T, T, T)> cb(static_func4);
@ -314,9 +456,13 @@ void test_dispatch5() {
Verifier<T>::verify5((volatile Thing<T>*)&thing, &Thing<T>::volatile_member_func5);
Verifier<T>::verify5((const volatile Thing<T>*)&thing, &Thing<T>::const_volatile_member_func5);
Verifier<T>::verify5(&thing, &bound_func5<T>);
Verifier<T>::verify5((const Thing<T>*)&thing, &const_func5<T>);
Verifier<T>::verify5((volatile Thing<T>*)&thing, &volatile_func5<T>);
Verifier<T>::verify5((const volatile Thing<T>*)&thing, &const_volatile_func5<T>);
Verifier<T>::verify5((const Thing<T>*)&thing, &const_bound_func5<T>);
Verifier<T>::verify5((volatile Thing<T>*)&thing, &volatile_bound_func5<T>);
Verifier<T>::verify5((const volatile Thing<T>*)&thing, &const_volatile_bound_func5<T>);
Verifier<T>::verify5(&thing, &void_func5<T>);
Verifier<T>::verify5((const Thing<T>*)&thing, &const_void_func5<T>);
Verifier<T>::verify5((volatile Thing<T>*)&thing, &volatile_void_func5<T>);
Verifier<T>::verify5((const volatile Thing<T>*)&thing, &const_volatile_void_func5<T>);
Verifier<T>::verify5(callback(static_func5<T>));
Callback<T(T, T, T, T, T)> cb(static_func5);

View File

@ -8,17 +8,23 @@ using namespace utest::v1;
// static functions
template <typename T>
T static_func0() { return 0; }
T static_func0()
{ return 0; }
template <typename T>
T static_func1(T a0) { return 0 | a0; }
T static_func1(T a0)
{ return 0 | a0; }
template <typename T>
T static_func2(T a0, T a1) { return 0 | a0 | a1; }
T static_func2(T a0, T a1)
{ return 0 | a0 | a1; }
template <typename T>
T static_func3(T a0, T a1, T a2) { return 0 | a0 | a1 | a2; }
T static_func3(T a0, T a1, T a2)
{ return 0 | a0 | a1 | a2; }
template <typename T>
T static_func4(T a0, T a1, T a2, T a3) { return 0 | a0 | a1 | a2 | a3; }
T static_func4(T a0, T a1, T a2, T a3)
{ return 0 | a0 | a1 | a2 | a3; }
template <typename T>
T static_func5(T a0, T a1, T a2, T a3, T a4) { return 0 | a0 | a1 | a2 | a3 | a4; }
T static_func5(T a0, T a1, T a2, T a3, T a4)
{ return 0 | a0 | a1 | a2 | a3 | a4; }
// class functions
template <typename T>
@ -26,90 +32,206 @@ struct Thing {
T t;
Thing() : t(0x80) {}
T member_func0() { return t; }
T member_func1(T a0) { return t | a0; }
T member_func2(T a0, T a1) { return t | a0 | a1; }
T member_func3(T a0, T a1, T a2) { return t | a0 | a1 | a2; }
T member_func4(T a0, T a1, T a2, T a3) { return t | a0 | a1 | a2 | a3; }
T member_func5(T a0, T a1, T a2, T a3, T a4) { return t | a0 | a1 | a2 | a3 | a4; }
T member_func0()
{ return t; }
T member_func1(T a0)
{ return t | a0; }
T member_func2(T a0, T a1)
{ return t | a0 | a1; }
T member_func3(T a0, T a1, T a2)
{ return t | a0 | a1 | a2; }
T member_func4(T a0, T a1, T a2, T a3)
{ return t | a0 | a1 | a2 | a3; }
T member_func5(T a0, T a1, T a2, T a3, T a4)
{ return t | a0 | a1 | a2 | a3 | a4; }
T const_member_func0() const { return t; }
T const_member_func1(T a0) const { return t | a0; }
T const_member_func2(T a0, T a1) const { return t | a0 | a1; }
T const_member_func3(T a0, T a1, T a2) const { return t | a0 | a1 | a2; }
T const_member_func4(T a0, T a1, T a2, T a3) const { return t | a0 | a1 | a2 | a3; }
T const_member_func5(T a0, T a1, T a2, T a3, T a4) const { return t | a0 | a1 | a2 | a3 | a4; }
T const_member_func0() const
{ return t; }
T const_member_func1(T a0) const
{ return t | a0; }
T const_member_func2(T a0, T a1) const
{ return t | a0 | a1; }
T const_member_func3(T a0, T a1, T a2) const
{ return t | a0 | a1 | a2; }
T const_member_func4(T a0, T a1, T a2, T a3) const
{ return t | a0 | a1 | a2 | a3; }
T const_member_func5(T a0, T a1, T a2, T a3, T a4) const
{ return t | a0 | a1 | a2 | a3 | a4; }
T volatile_member_func0() volatile { return t; }
T volatile_member_func1(T a0) volatile { return t | a0; }
T volatile_member_func2(T a0, T a1) volatile { return t | a0 | a1; }
T volatile_member_func3(T a0, T a1, T a2) volatile { return t | a0 | a1 | a2; }
T volatile_member_func4(T a0, T a1, T a2, T a3) volatile { return t | a0 | a1 | a2 | a3; }
T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile { return t | a0 | a1 | a2 | a3 | a4; }
T volatile_member_func0() volatile
{ return t; }
T volatile_member_func1(T a0) volatile
{ return t | a0; }
T volatile_member_func2(T a0, T a1) volatile
{ return t | a0 | a1; }
T volatile_member_func3(T a0, T a1, T a2) volatile
{ return t | a0 | a1 | a2; }
T volatile_member_func4(T a0, T a1, T a2, T a3) volatile
{ return t | a0 | a1 | a2 | a3; }
T volatile_member_func5(T a0, T a1, T a2, T a3, T a4) volatile
{ return t | a0 | a1 | a2 | a3 | a4; }
T const_volatile_member_func0() const volatile { return t; }
T const_volatile_member_func1(T a0) const volatile { return t | a0; }
T const_volatile_member_func2(T a0, T a1) const volatile { return t | a0 | a1; }
T const_volatile_member_func3(T a0, T a1, T a2) const volatile { return t | a0 | a1 | a2; }
T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile { return t | a0 | a1 | a2 | a3; }
T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile { return t | a0 | a1 | a2 | a3 | a4; }
T const_volatile_member_func0() const volatile
{ return t; }
T const_volatile_member_func1(T a0) const volatile
{ return t | a0; }
T const_volatile_member_func2(T a0, T a1) const volatile
{ return t | a0 | a1; }
T const_volatile_member_func3(T a0, T a1, T a2) const volatile
{ return t | a0 | a1 | a2; }
T const_volatile_member_func4(T a0, T a1, T a2, T a3) const volatile
{ return t | a0 | a1 | a2 | a3; }
T const_volatile_member_func5(T a0, T a1, T a2, T a3, T a4) const volatile
{ return t | a0 | a1 | a2 | a3 | a4; }
};
// bound functions
template <typename T>
T bound_func0(Thing<T> *t) { return t->t; }
T bound_func0(Thing<T> *t)
{ return t->t; }
template <typename T>
T bound_func1(Thing<T> *t, T a0) { return t->t | a0; }
T bound_func1(Thing<T> *t, T a0)
{ return t->t | a0; }
template <typename T>
T bound_func2(Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
T bound_func2(Thing<T> *t, T a0, T a1)
{ return t->t | a0 | a1; }
template <typename T>
T bound_func3(Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
T bound_func3(Thing<T> *t, T a0, T a1, T a2)
{ return t->t | a0 | a1 | a2; }
template <typename T>
T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
T bound_func4(Thing<T> *t, T a0, T a1, T a2, T a3)
{ return t->t | a0 | a1 | a2 | a3; }
template <typename T>
T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
T bound_func5(Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
{ return t->t | a0 | a1 | a2 | a3 | a4; }
template <typename T>
T const_bound_func0(const Thing<T> *t)
{ return t->t; }
template <typename T>
T const_bound_func1(const Thing<T> *t, T a0)
{ return t->t | a0; }
template <typename T>
T const_bound_func2(const Thing<T> *t, T a0, T a1)
{ return t->t | a0 | a1; }
template <typename T>
T const_bound_func3(const Thing<T> *t, T a0, T a1, T a2)
{ return t->t | a0 | a1 | a2; }
template <typename T>
T const_bound_func4(const Thing<T> *t, T a0, T a1, T a2, T a3)
{ return t->t | a0 | a1 | a2 | a3; }
template <typename T>
T const_bound_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
{ return t->t | a0 | a1 | a2 | a3 | a4; }
template <typename T>
T volatile_bound_func0(volatile Thing<T> *t)
{ return t->t; }
template <typename T>
T volatile_bound_func1(volatile Thing<T> *t, T a0)
{ return t->t | a0; }
template <typename T>
T volatile_bound_func2(volatile Thing<T> *t, T a0, T a1)
{ return t->t | a0 | a1; }
template <typename T>
T volatile_bound_func3(volatile Thing<T> *t, T a0, T a1, T a2)
{ return t->t | a0 | a1 | a2; }
template <typename T>
T volatile_bound_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3)
{ return t->t | a0 | a1 | a2 | a3; }
template <typename T>
T volatile_bound_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
{ return t->t | a0 | a1 | a2 | a3 | a4; }
template <typename T>
T const_volatile_bound_func0(const volatile Thing<T> *t)
{ return t->t; }
template <typename T>
T const_volatile_bound_func1(const volatile Thing<T> *t, T a0)
{ return t->t | a0; }
template <typename T>
T const_volatile_bound_func2(const volatile Thing<T> *t, T a0, T a1)
{ return t->t | a0 | a1; }
template <typename T>
T const_volatile_bound_func3(const volatile Thing<T> *t, T a0, T a1, T a2)
{ return t->t | a0 | a1 | a2; }
template <typename T>
T const_volatile_bound_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3)
{ return t->t | a0 | a1 | a2 | a3; }
template <typename T>
T const_volatile_bound_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4)
{ return t->t | a0 | a1 | a2 | a3 | a4; }
// const bound functions
// void functions
template <typename T>
T const_func0(const Thing<T> *t) { return t->t; }
T void_func0(void *t)
{ return static_cast<Thing<T>*>(t)->t; }
template <typename T>
T const_func1(const Thing<T> *t, T a0) { return t->t | a0; }
T void_func1(void *t, T a0)
{ return static_cast<Thing<T>*>(t)->t | a0; }
template <typename T>
T const_func2(const Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
T void_func2(void *t, T a0, T a1)
{ return static_cast<Thing<T>*>(t)->t | a0 | a1; }
template <typename T>
T const_func3(const Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
T void_func3(void *t, T a0, T a1, T a2)
{ return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2; }
template <typename T>
T const_func4(const Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
T void_func4(void *t, T a0, T a1, T a2, T a3)
{ return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
template <typename T>
T const_func5(const Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
// volatile bound functions
T void_func5(void *t, T a0, T a1, T a2, T a3, T a4)
{ return static_cast<Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
template <typename T>
T volatile_func0(volatile Thing<T> *t) { return t->t; }
T const_void_func0(const void *t)
{ return static_cast<const Thing<T>*>(t)->t; }
template <typename T>
T volatile_func1(volatile Thing<T> *t, T a0) { return t->t | a0; }
T const_void_func1(const void *t, T a0)
{ return static_cast<const Thing<T>*>(t)->t | a0; }
template <typename T>
T volatile_func2(volatile Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
T const_void_func2(const void *t, T a0, T a1)
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1; }
template <typename T>
T volatile_func3(volatile Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
T const_void_func3(const void *t, T a0, T a1, T a2)
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2; }
template <typename T>
T volatile_func4(volatile Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
T const_void_func4(const void *t, T a0, T a1, T a2, T a3)
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
template <typename T>
T volatile_func5(volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
// const volatile bound functions
T const_void_func5(const void *t, T a0, T a1, T a2, T a3, T a4)
{ return static_cast<const Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
template <typename T>
T const_volatile_func0(const volatile Thing<T> *t) { return t->t; }
T volatile_void_func0(volatile void *t)
{ return static_cast<volatile Thing<T>*>(t)->t; }
template <typename T>
T const_volatile_func1(const volatile Thing<T> *t, T a0) { return t->t | a0; }
T volatile_void_func1(volatile void *t, T a0)
{ return static_cast<volatile Thing<T>*>(t)->t | a0; }
template <typename T>
T const_volatile_func2(const volatile Thing<T> *t, T a0, T a1) { return t->t | a0 | a1; }
T volatile_void_func2(volatile void *t, T a0, T a1)
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1; }
template <typename T>
T const_volatile_func3(const volatile Thing<T> *t, T a0, T a1, T a2) { return t->t | a0 | a1 | a2; }
T volatile_void_func3(volatile void *t, T a0, T a1, T a2)
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2; }
template <typename T>
T const_volatile_func4(const volatile Thing<T> *t, T a0, T a1, T a2, T a3) { return t->t | a0 | a1 | a2 | a3; }
T volatile_void_func4(volatile void *t, T a0, T a1, T a2, T a3)
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
template <typename T>
T const_volatile_func5(const volatile Thing<T> *t, T a0, T a1, T a2, T a3, T a4) { return t->t | a0 | a1 | a2 | a3 | a4; }
T volatile_void_func5(volatile void *t, T a0, T a1, T a2, T a3, T a4)
{ return static_cast<volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
template <typename T>
T const_volatile_void_func0(const volatile void *t)
{ return static_cast<const volatile Thing<T>*>(t)->t; }
template <typename T>
T const_volatile_void_func1(const volatile void *t, T a0)
{ return static_cast<const volatile Thing<T>*>(t)->t | a0; }
template <typename T>
T const_volatile_void_func2(const volatile void *t, T a0, T a1)
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1; }
template <typename T>
T const_volatile_void_func3(const volatile void *t, T a0, T a1, T a2)
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2; }
template <typename T>
T const_volatile_void_func4(const volatile void *t, T a0, T a1, T a2, T a3)
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3; }
template <typename T>
T const_volatile_void_func5(const volatile void *t, T a0, T a1, T a2, T a3, T a4)
{ return static_cast<const volatile Thing<T>*>(t)->t | a0 | a1 | a2 | a3 | a4; }
// function call and result verification

View File

@ -44,6 +44,38 @@ public:
attach(func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(void *obj, R (*func)(void*)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(const void *obj, R (*func)(const void*)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(volatile void *obj, R (*func)(volatile void*)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(const volatile void *obj, R (*func)(const volatile void*)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
@ -143,6 +175,78 @@ public:
_thunk = func._thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(void *obj, R (*func)(void*)) {
struct local {
static R _thunk(void *obj, const void *func) {
return (*static_cast<R (*const *)(void*)>(func))(
(void*)obj);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(const void *obj, R (*func)(const void*)) {
struct local {
static R _thunk(void *obj, const void *func) {
return (*static_cast<R (*const *)(const void*)>(func))(
(const void*)obj);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(volatile void *obj, R (*func)(volatile void*)) {
struct local {
static R _thunk(void *obj, const void *func) {
return (*static_cast<R (*const *)(volatile void*)>(func))(
(volatile void*)obj);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(const volatile void *obj, R (*func)(const volatile void*)) {
struct local {
static R _thunk(void *obj, const void *func) {
return (*static_cast<R (*const *)(const volatile void*)>(func))(
(const volatile void*)obj);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
@ -369,6 +473,38 @@ public:
attach(func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(void *obj, R (*func)(void*, A0)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(const void *obj, R (*func)(const void*, A0)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(volatile void *obj, R (*func)(volatile void*, A0)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(const volatile void *obj, R (*func)(const volatile void*, A0)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
@ -468,6 +604,78 @@ public:
_thunk = func._thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(void *obj, R (*func)(void*, A0)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0) {
return (*static_cast<R (*const *)(void*, A0)>(func))(
(void*)obj, a0);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(const void *obj, R (*func)(const void*, A0)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0) {
return (*static_cast<R (*const *)(const void*, A0)>(func))(
(const void*)obj, a0);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(volatile void *obj, R (*func)(volatile void*, A0)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0) {
return (*static_cast<R (*const *)(volatile void*, A0)>(func))(
(volatile void*)obj, a0);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(const volatile void *obj, R (*func)(const volatile void*, A0)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0) {
return (*static_cast<R (*const *)(const volatile void*, A0)>(func))(
(const volatile void*)obj, a0);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
@ -694,6 +902,38 @@ public:
attach(func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(void *obj, R (*func)(void*, A0, A1)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(const void *obj, R (*func)(const void*, A0, A1)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(volatile void *obj, R (*func)(volatile void*, A0, A1)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
@ -793,6 +1033,78 @@ public:
_thunk = func._thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(void *obj, R (*func)(void*, A0, A1)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1) {
return (*static_cast<R (*const *)(void*, A0, A1)>(func))(
(void*)obj, a0, a1);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(const void *obj, R (*func)(const void*, A0, A1)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1) {
return (*static_cast<R (*const *)(const void*, A0, A1)>(func))(
(const void*)obj, a0, a1);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(volatile void *obj, R (*func)(volatile void*, A0, A1)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1) {
return (*static_cast<R (*const *)(volatile void*, A0, A1)>(func))(
(volatile void*)obj, a0, a1);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1) {
return (*static_cast<R (*const *)(const volatile void*, A0, A1)>(func))(
(const volatile void*)obj, a0, a1);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
@ -1019,6 +1331,38 @@ public:
attach(func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(void *obj, R (*func)(void*, A0, A1, A2)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(const void *obj, R (*func)(const void*, A0, A1, A2)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
@ -1118,6 +1462,78 @@ public:
_thunk = func._thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(void *obj, R (*func)(void*, A0, A1, A2)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) {
return (*static_cast<R (*const *)(void*, A0, A1, A2)>(func))(
(void*)obj, a0, a1, a2);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(const void *obj, R (*func)(const void*, A0, A1, A2)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) {
return (*static_cast<R (*const *)(const void*, A0, A1, A2)>(func))(
(const void*)obj, a0, a1, a2);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) {
return (*static_cast<R (*const *)(volatile void*, A0, A1, A2)>(func))(
(volatile void*)obj, a0, a1, a2);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2) {
return (*static_cast<R (*const *)(const volatile void*, A0, A1, A2)>(func))(
(const volatile void*)obj, a0, a1, a2);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
@ -1344,6 +1760,38 @@ public:
attach(func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(void *obj, R (*func)(void*, A0, A1, A2, A3)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
@ -1443,6 +1891,78 @@ public:
_thunk = func._thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(void *obj, R (*func)(void*, A0, A1, A2, A3)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) {
return (*static_cast<R (*const *)(void*, A0, A1, A2, A3)>(func))(
(void*)obj, a0, a1, a2, a3);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) {
return (*static_cast<R (*const *)(const void*, A0, A1, A2, A3)>(func))(
(const void*)obj, a0, a1, a2, a3);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) {
return (*static_cast<R (*const *)(volatile void*, A0, A1, A2, A3)>(func))(
(volatile void*)obj, a0, a1, a2, a3);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3) {
return (*static_cast<R (*const *)(const volatile void*, A0, A1, A2, A3)>(func))(
(const volatile void*)obj, a0, a1, a2, a3);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
@ -1669,6 +2189,38 @@ public:
attach(func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
Callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) {
attach(obj, func);
}
/** Create a Callback with a static function and bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
@ -1768,6 +2320,78 @@ public:
_thunk = func._thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
return (*static_cast<R (*const *)(void*, A0, A1, A2, A3, A4)>(func))(
(void*)obj, a0, a1, a2, a3, a4);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
return (*static_cast<R (*const *)(const void*, A0, A1, A2, A3, A4)>(func))(
(const void*)obj, a0, a1, a2, a3, a4);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
return (*static_cast<R (*const *)(volatile void*, A0, A1, A2, A3, A4)>(func))(
(volatile void*)obj, a0, a1, a2, a3, a4);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
*/
void attach(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) {
struct local {
static R _thunk(void *obj, const void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
return (*static_cast<R (*const *)(const volatile void*, A0, A1, A2, A3, A4)>(func))(
(const volatile void*)obj, a0, a1, a2, a3, a4);
}
};
memset(&_func, 0, sizeof _func);
memcpy(&_func, &func, sizeof func);
_obj = (void*)obj;
_thunk = &local::_thunk;
}
/** Attach a static function with a bound pointer
* @param obj Pointer to object to bind to function
* @param func Static function to attach
@ -2004,6 +2628,50 @@ Callback<R()> callback(const Callback<R()> &func) {
return Callback<R()>(func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R>
Callback<R()> callback(void *obj, R (*func)(void*)) {
return Callback<R()>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R>
Callback<R()> callback(const void *obj, R (*func)(const void*)) {
return Callback<R()>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R>
Callback<R()> callback(volatile void *obj, R (*func)(volatile void*)) {
return Callback<R()>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R>
Callback<R()> callback(const volatile void *obj, R (*func)(const volatile void*)) {
return Callback<R()>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
@ -2113,6 +2781,50 @@ Callback<R(A0)> callback(const Callback<R(A0)> &func) {
return Callback<R(A0)>(func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0>
Callback<R(A0)> callback(void *obj, R (*func)(void*, A0)) {
return Callback<R(A0)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0>
Callback<R(A0)> callback(const void *obj, R (*func)(const void*, A0)) {
return Callback<R(A0)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0>
Callback<R(A0)> callback(volatile void *obj, R (*func)(volatile void*, A0)) {
return Callback<R(A0)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0>
Callback<R(A0)> callback(const volatile void *obj, R (*func)(const volatile void*, A0)) {
return Callback<R(A0)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
@ -2222,6 +2934,50 @@ Callback<R(A0, A1)> callback(const Callback<R(A0, A1)> &func) {
return Callback<R(A0, A1)>(func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1>
Callback<R(A0, A1)> callback(void *obj, R (*func)(void*, A0, A1)) {
return Callback<R(A0, A1)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1>
Callback<R(A0, A1)> callback(const void *obj, R (*func)(const void*, A0, A1)) {
return Callback<R(A0, A1)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1>
Callback<R(A0, A1)> callback(volatile void *obj, R (*func)(volatile void*, A0, A1)) {
return Callback<R(A0, A1)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1>
Callback<R(A0, A1)> callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1)) {
return Callback<R(A0, A1)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
@ -2331,6 +3087,50 @@ Callback<R(A0, A1, A2)> callback(const Callback<R(A0, A1, A2)> &func) {
return Callback<R(A0, A1, A2)>(func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1, typename A2>
Callback<R(A0, A1, A2)> callback(void *obj, R (*func)(void*, A0, A1, A2)) {
return Callback<R(A0, A1, A2)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1, typename A2>
Callback<R(A0, A1, A2)> callback(const void *obj, R (*func)(const void*, A0, A1, A2)) {
return Callback<R(A0, A1, A2)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1, typename A2>
Callback<R(A0, A1, A2)> callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2)) {
return Callback<R(A0, A1, A2)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1, typename A2>
Callback<R(A0, A1, A2)> callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2)) {
return Callback<R(A0, A1, A2)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
@ -2440,6 +3240,50 @@ Callback<R(A0, A1, A2, A3)> callback(const Callback<R(A0, A1, A2, A3)> &func) {
return Callback<R(A0, A1, A2, A3)>(func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1, typename A2, typename A3>
Callback<R(A0, A1, A2, A3)> callback(void *obj, R (*func)(void*, A0, A1, A2, A3)) {
return Callback<R(A0, A1, A2, A3)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1, typename A2, typename A3>
Callback<R(A0, A1, A2, A3)> callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3)) {
return Callback<R(A0, A1, A2, A3)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1, typename A2, typename A3>
Callback<R(A0, A1, A2, A3)> callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3)) {
return Callback<R(A0, A1, A2, A3)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1, typename A2, typename A3>
Callback<R(A0, A1, A2, A3)> callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3)) {
return Callback<R(A0, A1, A2, A3)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
@ -2549,6 +3393,50 @@ Callback<R(A0, A1, A2, A3, A4)> callback(const Callback<R(A0, A1, A2, A3, A4)> &
return Callback<R(A0, A1, A2, A3, A4)>(func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
Callback<R(A0, A1, A2, A3, A4)> callback(void *obj, R (*func)(void*, A0, A1, A2, A3, A4)) {
return Callback<R(A0, A1, A2, A3, A4)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
Callback<R(A0, A1, A2, A3, A4)> callback(const void *obj, R (*func)(const void*, A0, A1, A2, A3, A4)) {
return Callback<R(A0, A1, A2, A3, A4)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
Callback<R(A0, A1, A2, A3, A4)> callback(volatile void *obj, R (*func)(volatile void*, A0, A1, A2, A3, A4)) {
return Callback<R(A0, A1, A2, A3, A4)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function
* @param func Static function to attach
* @return Callback with infered type
*/
template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
Callback<R(A0, A1, A2, A3, A4)> callback(const volatile void *obj, R (*func)(const volatile void*, A0, A1, A2, A3, A4)) {
return Callback<R(A0, A1, A2, A3, A4)>(obj, func);
}
/** Create a callback class with type infered from the arguments
*
* @param obj Optional pointer to object to bind to function