-
-
Save ThePhD/a5f814afe71ccc507ea7 to your computer and use it in GitHub Desktop.
Arf.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename R, typename... Args> | |
int RegisterGlobalFunction(R(*fptr)(Args...), std::string name, CallConv callconv = callConv<R(*)(Args...)>(nullptr)) | |
{ | |
int r = engine->RegisterGlobalFunction(decompose(name, fptr).c_str(), AS_::asFunctionPtr(fptr), (AS_::asECallConvTypes)callconv); | |
ASThrow(r); | |
return r; | |
} | |
// Const | |
template <typename R, typename T, typename... Args> | |
int RegisterGlobalFunction(R(T::*mfptr)(Args...)const, std::string name, T* instance = nullptr, CallConv callconv = CallConv::Thiscall_global) | |
{ | |
if (instance == nullptr) | |
{ //static member function..I hope | |
callconv = CallConv::Cdecl; | |
} | |
int r = engine->RegisterGlobalFunction(decompose(name, mfptr).c_str(), AS_::asSMethodPtr<sizeof(void (T::*)())>::Convert(mfptr), (AS_::asECallConvTypes)callconv, instance); | |
ASThrow(r); | |
return r; | |
} | |
// Non Const | |
template <typename R, typename T, typename... Args> | |
int RegisterGlobalFunction(R(T::*mfptr)(Args...), std::string name, T* instance = nullptr, CallConv callconv = CallConv::Thiscall_global) | |
{ | |
if (instance == nullptr) | |
{ //static member function..I hope | |
callconv = CallConv::Cdecl; | |
} | |
int r = engine->RegisterGlobalFunction(decompose(name, mfptr).c_str(), AS_::asSMethodPtr<sizeof(void (T::*)())>::Convert(mfptr), (AS_::asECallConvTypes)callconv, instance); | |
ASThrow(r); | |
return r; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment