1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-21 20:27:13 +01:00

Adjust Routine type methods to use the new method of receiving formatted strings.

This commit is contained in:
Sandu Liviu Catalin 2016-11-16 13:12:49 +02:00
parent fd10399d9b
commit 91bb7ef7ba
2 changed files with 53 additions and 15 deletions

View File

@ -604,9 +604,16 @@ const String & Routine::GetTag() const
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void Routine::SetTag(CSStr tag) void Routine::SetTag(const StackStrF & tag)
{ {
m_Tag.assign(tag ? tag : _SC("")); if (tag.mLen)
{
m_Tag.assign(tag.mPtr, tag.mLen);
}
else
{
m_Tag.clear();
}
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -628,9 +635,16 @@ void Routine::SetData(Object & data)
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
Routine & Routine::ApplyTag(CSStr tag) Routine & Routine::ApplyTag(StackStrF & tag)
{ {
m_Tag.assign(tag ? tag : _SC("")); if (tag.mLen)
{
m_Tag.assign(tag.mPtr, tag.mLen);
}
else
{
m_Tag.clear();
}
// Allow chaining // Allow chaining
return *this; return *this;
} }
@ -994,7 +1008,7 @@ void Register_Routine(HSQUIRRELVM vm)
.Prop(_SC("Terminated"), &Routine::GetTerminated) .Prop(_SC("Terminated"), &Routine::GetTerminated)
.Prop(_SC("Callback"), &Routine::GetCallback) .Prop(_SC("Callback"), &Routine::GetCallback)
// Functions // Functions
.Func(_SC("SetTag"), &Routine::ApplyTag) .FmtFunc(_SC("SetTag"), &Routine::ApplyTag)
.Func(_SC("SetData"), &Routine::ApplyData) .Func(_SC("SetData"), &Routine::ApplyData)
.Func(_SC("Terminate"), &Routine::Terminate) .Func(_SC("Terminate"), &Routine::Terminate)
.Func(_SC("Bind"), &Routine::SetCallback) .Func(_SC("Bind"), &Routine::SetCallback)

View File

@ -240,9 +240,18 @@ public:
*/ */
Int32 Cmp(SQInteger interval) const Int32 Cmp(SQInteger interval) const
{ {
if (m_Interval == interval) return 0; if (m_Interval == interval)
else if (m_Interval > interval) return 1; {
else return -1; return 0;
}
else if (m_Interval > interval)
{
return 1;
}
else
{
return -1;
}
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
@ -266,9 +275,18 @@ public:
*/ */
Int32 Cmp(bool suspended) const Int32 Cmp(bool suspended) const
{ {
if (m_Suspended == suspended) return 0; if (m_Suspended == suspended)
else if (m_Suspended > suspended) return 1; {
else return -1; return 0;
}
else if (m_Suspended > suspended)
{
return 1;
}
else
{
return -1;
}
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
@ -276,8 +294,14 @@ public:
*/ */
Int32 Cmp(std::nullptr_t) const Int32 Cmp(std::nullptr_t) const
{ {
if (m_Terminated == true) return 0; if (m_Terminated == true)
else return 1; {
return 0;
}
else
{
return 1;
}
} }
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
@ -293,7 +317,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Modify the associated user tag. * Modify the associated user tag.
*/ */
void SetTag(CSStr tag); void SetTag(const StackStrF & tag);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Retrieve the associated user data. * Retrieve the associated user data.
@ -308,7 +332,7 @@ public:
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Modify the associated user tag and allow chaining of operations. * Modify the associated user tag and allow chaining of operations.
*/ */
Routine & ApplyTag(CSStr tag); Routine & ApplyTag(StackStrF & tag);
/* -------------------------------------------------------------------------------------------- /* --------------------------------------------------------------------------------------------
* Modify the associated user data and allow chaining of operations. * Modify the associated user data and allow chaining of operations.