mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-02-21 20:27:13 +01:00
Allow toggling of error handling for each routine individually ( should close #31 ).
Allow a routine to ignore runtime errors (if requested) and not terminate itself.
This commit is contained in:
parent
d568ddf341
commit
0bf9afc553
@ -271,6 +271,8 @@ void Register_Routine(HSQUIRRELVM vm)
|
|||||||
.Prop(_SC("Interval"), &Routine::GetInterval, &Routine::SetInterval)
|
.Prop(_SC("Interval"), &Routine::GetInterval, &Routine::SetInterval)
|
||||||
.Prop(_SC("Iterations"), &Routine::GetIterations, &Routine::SetIterations)
|
.Prop(_SC("Iterations"), &Routine::GetIterations, &Routine::SetIterations)
|
||||||
.Prop(_SC("Suspended"), &Routine::GetSuspended, &Routine::SetSuspended)
|
.Prop(_SC("Suspended"), &Routine::GetSuspended, &Routine::SetSuspended)
|
||||||
|
.Prop(_SC("Quiet"), &Routine::GetQuiet, &Routine::SetQuiet)
|
||||||
|
.Prop(_SC("Endure"), &Routine::GetEndure, &Routine::SetEndure)
|
||||||
.Prop(_SC("Arguments"), &Routine::GetArguments)
|
.Prop(_SC("Arguments"), &Routine::GetArguments)
|
||||||
// Member Methods
|
// Member Methods
|
||||||
.FmtFunc(_SC("SetTag"), &Routine::SetTag)
|
.FmtFunc(_SC("SetTag"), &Routine::SetTag)
|
||||||
|
@ -38,6 +38,8 @@ private:
|
|||||||
Iterator mIterations; // Number of iterations before self destruct.
|
Iterator mIterations; // Number of iterations before self destruct.
|
||||||
Interval mInterval; // Interval between routine invocations.
|
Interval mInterval; // Interval between routine invocations.
|
||||||
bool mSuspended; // Whether this instance is allowed to receive calls.
|
bool mSuspended; // Whether this instance is allowed to receive calls.
|
||||||
|
bool mQuiet; // Whether this instance is allowed to handle errors.
|
||||||
|
bool mEndure; // Whether this instance is allowed to terminate itself on errors.
|
||||||
Uint8 mArgc; // The number of arguments that the routine must forward.
|
Uint8 mArgc; // The number of arguments that the routine must forward.
|
||||||
Argument mArgv[14]; // The arguments that the routine must forward.
|
Argument mArgv[14]; // The arguments that the routine must forward.
|
||||||
|
|
||||||
@ -53,6 +55,8 @@ private:
|
|||||||
, mIterations(0)
|
, mIterations(0)
|
||||||
, mInterval(0)
|
, mInterval(0)
|
||||||
, mSuspended(false)
|
, mSuspended(false)
|
||||||
|
, mQuiet(ErrorHandling::IsEnabled())
|
||||||
|
, mEndure(false)
|
||||||
, mArgc(0)
|
, mArgc(0)
|
||||||
, mArgv()
|
, mArgv()
|
||||||
{
|
{
|
||||||
@ -141,11 +145,15 @@ private:
|
|||||||
sq_pushobject(vm, mArgv[n].mObj);
|
sq_pushobject(vm, mArgv[n].mObj);
|
||||||
}
|
}
|
||||||
// Make the function call and store the result
|
// Make the function call and store the result
|
||||||
const SQRESULT res = sq_call(vm, mArgc + 1, false, ErrorHandling::IsEnabled());
|
const SQRESULT res = sq_call(vm, mArgc + 1, false, mQuiet);
|
||||||
// Validate the result
|
// Validate the result
|
||||||
if (SQ_FAILED(res))
|
if (SQ_FAILED(res))
|
||||||
{
|
{
|
||||||
Terminate(); // Destroy ourself on error
|
// Should we endure the errors?
|
||||||
|
if (!mEndure)
|
||||||
|
{
|
||||||
|
Terminate(); // Destroy ourself on error
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Decrease the number of iterations if necessary
|
// Decrease the number of iterations if necessary
|
||||||
@ -477,6 +485,38 @@ public:
|
|||||||
GetValid().mSuspended = toggle;
|
GetValid().mSuspended = toggle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* See whether the routine is quite.
|
||||||
|
*/
|
||||||
|
bool GetQuiet() const
|
||||||
|
{
|
||||||
|
return GetValid().mQuiet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Set whether the routine should be quiet.
|
||||||
|
*/
|
||||||
|
void SetQuiet(bool toggle)
|
||||||
|
{
|
||||||
|
GetValid().mQuiet = toggle;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* See whether the routine endures.
|
||||||
|
*/
|
||||||
|
bool GetEndure() const
|
||||||
|
{
|
||||||
|
return GetValid().mEndure;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------
|
||||||
|
* Set whether the routine should endure.
|
||||||
|
*/
|
||||||
|
void SetEndure(bool toggle)
|
||||||
|
{
|
||||||
|
GetValid().mEndure = toggle;
|
||||||
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------
|
/* --------------------------------------------------------------------------------------------
|
||||||
* Retrieve the number of arguments to be forwarded.
|
* Retrieve the number of arguments to be forwarded.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user