kcat / alure

Alure is a utility library for OpenAL, providing a C++ API and managing common tasks that include file loading, caching, and streaming
zlib License
70 stars 20 forks source link

DECL_THUNK0->N rename to DECL_IMPL_FORWARDED_FUNCTION[_ARGS[1->N]] #12

Closed Cazadorro closed 4 years ago

Cazadorro commented 6 years ago

DECL_THUNK is a very ambiguous name, and what the macro is doing is pretty straight forward.

from main.h

#define DECL_THUNK0(ret, C, Name, cv)                                         \
ret C::Name() cv { return pImpl->Name(); }
#define DECL_THUNK1(ret, C, Name, cv, T1)                                     \
ret C::Name(T1 a) cv { return pImpl->Name(std::forward<T1>(a)); }
#define DECL_THUNK2(ret, C, Name, cv, T1, T2)                                 \
ret C::Name(T1 a, T2 b) cv                                                    \
{ return pImpl->Name(std::forward<T1>(a), std::forward<T2>(b)); }
#define DECL_THUNK3(ret, C, Name, cv, T1, T2, T3)                             \
ret C::Name(T1 a, T2 b, T3 c) cv                                              \
{                                                                             \
    return pImpl->Name(std::forward<T1>(a), std::forward<T2>(b),              \
                       std::forward<T3>(c));                                  \
}

We should instead call this DECL_IMPL_FORWARDED_FUNCTION, or optionally ALURE_DECL_IMPL_FORWARDED_FUNCTION in order to avoid namespace conflicts.

the definitions would be changed like so to reflect this, and look like the following for clarity

#define DECL_IMPL_FORWARDED_FUNCTION(ret_type, caller_type, \
func_name, const_qualifier)   \
ret_type caller_type::func_name() const_qualifier { return pImpl->func_name(); }

#define DECL_IMPL_FORWARDED_FUNCTION_ARGS_1(ret_type, caller_type, \
func_name, const_qualifier)   \
arg1); \ 
...
#define DECL_IMPL_FORWARDED_FUNCTION_ARGS_3(ret_type, caller_type, \
func_name, const_qualifier)   \
arg1, arg2, arg3); \

I could submit a pull request for this change if I have the time.

Cazadorro commented 4 years ago

Not practically an issue at the time, closing