// // Created by koncord on 12.01.19. // #pragma once #include "Utils.hpp" #include "Types.hpp" template using Callback = void (*)(Types...); template using FunctionEllipsis = R(*)(...); template static constexpr unsigned int CallbackIndex(const char(&str)[N]) { return Utils::hash(str); } struct CallbackIdentity { const char* types; const unsigned int numargs; constexpr bool matches(const char* types, const unsigned int N = 0) const { return N < numargs ? this->types[N] == types[N] && matches(types, N + 1) : this->types[N] == types[N]; } template constexpr CallbackIdentity(Callback) : types(TypeString::value), numargs(sizeof(TypeString::value) - 1) {} }; struct ScriptCallbackData { const char* name; const unsigned long long index; const CallbackIdentity callback; template constexpr ScriptCallbackData(const char(&name)[N], CallbackIdentity _callback) : name(name), index(CallbackIndex(name)), callback(_callback) {} };