Files
source/Utils/popup_callback.h
T
fc1c1dfe77 remove stray 'typename' before non-qualified names
'typename' disambiguates a qualified dependent name, telling the
compiler that something like T::iterator names a type rather than a
value. Before a plain identifier there is nothing to disambiguate: P1
is already a type, and so is PopupIndex.

The grammar wants a qualified name after the keyword, so clang reports
"expected a qualified name after 'typename'", drops the keyword and
carries on -- 15175 times, since the offending declarations sit in
widely included headers. MSVC accepts them without a word.

Semantics do not change. Both compilers already ignored the keyword,
so the partial specialisations matched before this and match after it.

The diagnostic belongs to no -W group and therefore cannot be switched
off with -Wno-, which makes deleting the tokens the only way to quiet
it.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 13:05:23 -03:00

341 lines
9.0 KiB
C++

#ifndef POPUP_CALLBACK_CLASS
#define POPUP_CALLBACK_CLASS
#include "sgp.h"
class popupCallback;
template <typename R, typename P1> class popupCallbackFunction;
template <typename R, typename P1, typename P2> class popupCallbackFunction2;
class popupCallback{
public:
popupCallback(void){}
~popupCallback(void){}
virtual void bind(void* newFun) = 0;
virtual bool call(void) = 0;
};
// returns something, takes three parameters
template<typename R,typename P1,typename P2,typename P3>
class popupCallbackFunction3: public popupCallback{
protected:
R (*fun)(P1,P2,P3);
P1 param_1;
P2 param_2;
P3 param_3;
public:
popupCallbackFunction3(void);
popupCallbackFunction3(void * newFun, P1 param, P2 param2, P3 param3);
virtual void bind(void * newFun);
virtual bool call(void);
};
template<typename R,typename P1,typename P2,typename P3>
popupCallbackFunction3<R,P1,P2,P3>::popupCallbackFunction3(void){
this->fun = 0;
this->param_1 = P1();
this->param_2 = P2();
this->param_3 = P3();
};
template<typename R,typename P1,typename P2,typename P3>
popupCallbackFunction3<R,P1,P2,P3>::popupCallbackFunction3(void * newFun, P1 param, P2 param2, P3 param3){
this->fun = static_cast< R(*)(P1,P2,P3)>(newFun);
this->param_1 = param;
this->param_2 = param2;
this->param_3 = param3;
};
template<typename R,typename P1,typename P2,typename P3>
void popupCallbackFunction3<R,P1,P2,P3>::bind(void * newFun){
this->fun = static_cast< R(*)(P1,P2,P3)>(newFun);
};
template<typename R,typename P1,typename P2,typename P3>
bool popupCallbackFunction3<R,P1,P2,P3>::call(void){
return (bool)(this->fun)(this->param_1,this->param_2,this->param_3);
};
// three params, no return val
template<typename P1,typename P2,typename P3>
class popupCallbackFunction3<void,P1,P2,P3>: public popupCallback{
protected:
void (*fun)(P1,P2,P3);
P1 param_1;
P2 param_2;
P3 param_3;
public:
popupCallbackFunction3(void);
popupCallbackFunction3(void * newFun, P1 param, P2 param2, P3 param3);
virtual void bind(void * newFun);
virtual bool call(void);
};
template<typename P1,typename P2,typename P3>
popupCallbackFunction3<void,P1,P2,P3>::popupCallbackFunction3(void){
this->fun = 0;
this->param_1 = P1();
this->param_2 = P2();
this->param_3 = P3();
};
template<typename P1,typename P2,typename P3>
popupCallbackFunction3<void,P1,P2,P3>::popupCallbackFunction3(void * newFun, P1 param, P2 param2, P3 param3){
this->fun = static_cast< void(*)(P1,P2,P3)>(newFun);
this->param_1 = param;
this->param_2 = param2;
this->param_3 = param3;
};
template<typename P1,typename P2,typename P3>
void popupCallbackFunction3<void,P1,P2,P3>::bind(void * newFun){
this->fun = static_cast< void(*)(P1,P2,P3)>(newFun);
};
template<typename P1,typename P2,typename P3>
bool popupCallbackFunction3<void,P1,P2,P3>::call(void){
(this->fun)(this->param_1,this->param_2,this->param_3);
return 1;
};
// returns something, takes two parameters
template<typename R,typename P1,typename P2>
class popupCallbackFunction2: public popupCallback{
protected:
R (*fun)(P1,P2);
P1 param_1;
P2 param_2;
public:
popupCallbackFunction2(void);
popupCallbackFunction2(void * newFun, P1 param, P2 param2);
virtual void bind(void * newFun);
virtual bool call(void);
};
template<typename R,typename P1,typename P2>
popupCallbackFunction2<R,P1,P2>::popupCallbackFunction2(void){
this->fun = 0;
this->param_1 = P1();
this->param_2 = P2();
};
template<typename R,typename P1,typename P2>
popupCallbackFunction2<R,P1,P2>::popupCallbackFunction2(void * newFun, P1 param, P2 param2){
this->fun = static_cast< R(*)(P1,P2)>(newFun);
this->param_1 = param;
this->param_2 = param2;
};
template<typename R,typename P1,typename P2>
void popupCallbackFunction2<R,P1,P2>::bind(void * newFun){
this->fun = static_cast< R(*)(P1,P2)>(newFun);
};
template<typename R,typename P1,typename P2>
bool popupCallbackFunction2<R,P1,P2>::call(void){
return (bool)(this->fun)(this->param_1,this->param_2);
};
// two params, no return val
template<typename P1,typename P2>
class popupCallbackFunction2<void, P1,P2>: public popupCallback{
protected:
void (*fun)(P1,P2);
P1 param_1;
P2 param_2;
public:
popupCallbackFunction2(void);
popupCallbackFunction2(void * newFun, P1 param, P2 param2);
virtual void bind(void * newFun);
virtual bool call(void);
};
template<typename P1,typename P2>
popupCallbackFunction2<void,P1,P2>::popupCallbackFunction2(void){
this->fun = 0;
this->param_1 = P1();
this->param_2 = P2();
};
template<typename P1,typename P2>
popupCallbackFunction2<void,P1,P2>::popupCallbackFunction2(void * newFun, P1 param, P2 param2){
this->fun = static_cast< void(*)(P1,P2)>(newFun);
this->param_1 = param;
this->param_2 = param2;
};
template<typename P1,typename P2>
void popupCallbackFunction2<void,P1,P2>::bind(void * newFun){
this->fun = static_cast< void(*)(P1,P2)>(newFun);
};
template<typename P1,typename P2>
bool popupCallbackFunction2<void,P1,P2>::call(void){
(this->fun)(this->param_1,this->param_2);
return 1;
};
// returns something, takes one parameter
template <typename R, typename P1>
class popupCallbackFunction : public popupCallback{
protected:
R (*fun)(P1);
P1 param_1;
public:
popupCallbackFunction(void);
popupCallbackFunction(void * newFun, P1 param);
virtual void bind(void * newFun);
virtual bool call(void);
};
template<typename R,typename P1>
popupCallbackFunction<R,P1>::popupCallbackFunction(void){
this->fun = 0;
this->param_1 = P1();
};
template<typename R,typename P1>
popupCallbackFunction<R,P1>::popupCallbackFunction(void * newFun, P1 param){
this->fun = static_cast< R(*)(P1)>(newFun);
this->param_1 = param;
};
template<typename R,typename P1>
void popupCallbackFunction<R,P1>::bind(void * newFun){
this->fun = static_cast< R(*)(P1)>(newFun);
};
template<typename R,typename P1>
bool popupCallbackFunction<R,P1>::call(void){
return (bool)(this->fun)(this->param_1);
}
// no return type, one parameter
template <typename P1>
class popupCallbackFunction<void, P1> : public popupCallback{
protected:
void (*fun)(P1);
P1 param_1;
public:
popupCallbackFunction(void);
popupCallbackFunction(void * newFun, P1 param);
virtual void bind(void * newFun);
virtual bool call(void);
};
template<typename P1>
popupCallbackFunction<void,P1>::popupCallbackFunction(void){
this->fun = 0;
this->param_1 = P1();
};
template<typename P1>
popupCallbackFunction<void,P1>::popupCallbackFunction(void * newFun, P1 param){
this->fun = static_cast< void(*)(P1)>(newFun);
this->param_1 = param;
};
template<typename P1>
void popupCallbackFunction<void,P1>::bind(void * newFun){
this->fun = static_cast< void(*)(P1)>(newFun);
};
template<typename P1>
bool popupCallbackFunction<void,P1>::call(void){
try {
(this->fun)(this->param_1);
} catch (...) {
return false;
}
return true;
}
// returns something, no parameter
template <typename R>
class popupCallbackFunction<R, void> : public popupCallback{
protected:
R (*fun)(void);
public:
popupCallbackFunction(void);
popupCallbackFunction(void * newFun);
virtual void bind(void * newFun);
virtual bool call(void);
};
template<typename R>
popupCallbackFunction<R,void>::popupCallbackFunction(void){
this->fun = 0;
};
template<typename R>
popupCallbackFunction<R,void>::popupCallbackFunction(void * newFun){
this->fun = static_cast< R(*)(void)>(newFun);
};
template<typename R>
void popupCallbackFunction<R,void>::bind(void * newFun){
this->fun = static_cast< R(*)(void)>(newFun);
};
template<typename R>
bool popupCallbackFunction<R,void>::call(void){
return (bool)(this->fun)();
}
//template<>
//bool popupCallbackFunction<bool,void>::call(void){
// return (this->fun)();
//}
// no parameters/return types
template <>
class popupCallbackFunction<void, void> : public popupCallback{
protected:
void (*fun)(void);
public:
popupCallbackFunction(void){
this->fun = 0;
};
popupCallbackFunction(void * newFun){
this->fun = static_cast< void(*)(void)>(newFun);
};
virtual void bind(void * newFun){
this->fun = static_cast< void(*)(void)>(newFun);
};
virtual bool call(void){
try {
(this->fun)();
} catch (...) {
return false;
}
return true;
};
};
class popupCallbackLua : public popupCallback{
protected:
CHAR16 * functionName;
public:
popupCallbackLua(void);
popupCallbackLua(CHAR16 * newFunctionName){
this->functionName = newFunctionName;
};
virtual void bind(void * newFun){
this->functionName = static_cast< CHAR16* >(newFun);
};
virtual bool call(void){
return true;
};
};
#endif