mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-04-16 09:17:12 +02:00
Miscellaneous.
This commit is contained in:
parent
6fa8a17e9d
commit
66b2af9be2
@ -2456,7 +2456,11 @@ void Register_Core(HSQUIRRELVM vm)
|
|||||||
// Meta-methods
|
// Meta-methods
|
||||||
.SquirrelFunc(_SC("_typename"), &CoreStateTypename::Fn)
|
.SquirrelFunc(_SC("_typename"), &CoreStateTypename::Fn)
|
||||||
// Member Properties
|
// Member Properties
|
||||||
.Prop(_SC("Value"), &CoreState::GetValue)
|
.Prop(_SC("Value"), &CoreState::GetState, &CoreState::SetState)
|
||||||
|
.Prop(_SC("Init"), &CoreState::GetStart)
|
||||||
|
// Member Methods
|
||||||
|
.Func(_SC("Propose"), &CoreState::SetState)
|
||||||
|
.Func(_SC("Regress"), &CoreState::Regress)
|
||||||
);
|
);
|
||||||
|
|
||||||
corens
|
corens
|
||||||
|
@ -849,7 +849,7 @@ struct CoreState
|
|||||||
* Backup the current core state.
|
* Backup the current core state.
|
||||||
*/
|
*/
|
||||||
CoreState()
|
CoreState()
|
||||||
: m_State(Core::Get().GetState())
|
: m_State(Core::Get().GetState()), m_Start(m_Start)
|
||||||
{
|
{
|
||||||
//...
|
//...
|
||||||
}
|
}
|
||||||
@ -858,7 +858,7 @@ struct CoreState
|
|||||||
* Backup the current core state and set the given state.
|
* Backup the current core state and set the given state.
|
||||||
*/
|
*/
|
||||||
explicit CoreState(int s)
|
explicit CoreState(int s)
|
||||||
: m_State(Core::Get().GetState())
|
: CoreState()
|
||||||
{
|
{
|
||||||
Core::Get().SetState(s);
|
Core::Get().SetState(s);
|
||||||
}
|
}
|
||||||
@ -891,17 +891,44 @@ struct CoreState
|
|||||||
*/
|
*/
|
||||||
CoreState & operator = (CoreState && o) = delete;
|
CoreState & operator = (CoreState && o) = delete;
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Retrieve the initial state.
|
||||||
|
*/
|
||||||
|
SQMOD_NODISCARD int GetStart() const
|
||||||
|
{
|
||||||
|
return m_Start;
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the guarded state.
|
* Retrieve the guarded state.
|
||||||
*/
|
*/
|
||||||
SQMOD_NODISCARD int GetValue() const
|
SQMOD_NODISCARD int GetState() const
|
||||||
{
|
{
|
||||||
return m_State;
|
return m_State;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Modify the guarded state.
|
||||||
|
*/
|
||||||
|
CoreState & SetState(int s)
|
||||||
|
{
|
||||||
|
m_State = s;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Restore the guarded state. I.e the original state value at the time of construction.
|
||||||
|
*/
|
||||||
|
CoreState & Regress()
|
||||||
|
{
|
||||||
|
m_State = m_Start;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
int m_State; // The core state at the time when this instance was created.
|
int m_State; // The core state to be applied by destructor.
|
||||||
|
int m_Start; // The core state at the time when this instance was created.
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Namespace:: SqMod
|
} // Namespace:: SqMod
|
||||||
|
Loading…
x
Reference in New Issue
Block a user