1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-07-01 06:27:11 +02:00

Simplify the script function wrapper.

This commit is contained in:
Sandu Liviu Catalin
2018-07-31 17:41:46 +03:00
parent e48cb3b43c
commit 4c111d4139
2 changed files with 112 additions and 279 deletions

View File

@ -202,37 +202,25 @@ class WeakPtr;
/// @endcond
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Helper class that defines a VM that can be used as a fallback VM in case no other one is given to a piece of code
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Helper class that defines a VM that can be used as a fallback VM in case no other one is given to a piece of code
class DefaultVM {
private:
static HSQUIRRELVM& staticVm() {
static HSQUIRRELVM& StaticVM() noexcept {
static HSQUIRRELVM vm;
return vm;
}
public:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Gets the default VM
///
/// \return Default VM
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static HSQUIRRELVM Get() {
return staticVm();
// Gets the default VM (copy)
static HSQUIRRELVM Get() noexcept {
return StaticVM();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Sets the default VM to a given VM
///
/// \param vm New default VM
///
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Gets the default VM (reference)
static HSQUIRRELVM & Get_() noexcept {
return StaticVM();
}
// Sets the default VM to a given VM
static void Set(HSQUIRRELVM vm) {
staticVm() = vm;
StaticVM() = vm;
}
};