mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2024-11-08 00:37:15 +01:00
Replace the Argument class from the tasks with the new lightweight objects.
Include a forward declaration of the lightweight object in the base header.
This commit is contained in:
parent
faf07319f9
commit
b4b00caba9
@ -141,6 +141,7 @@ namespace Sqrat {
|
||||
class Table;
|
||||
class Function;
|
||||
class StackStrF;
|
||||
class LightObject;
|
||||
} // Namespace:: Sqrat
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
|
@ -20,107 +20,10 @@ public:
|
||||
typedef Int64 Time;
|
||||
typedef SQInteger Interval;
|
||||
typedef Uint32 Iterator;
|
||||
typedef LightObject Argument;
|
||||
|
||||
private:
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Helper structure to keep track of a script object with minimal impact on memory.
|
||||
*/
|
||||
struct Argument
|
||||
{
|
||||
// ----------------------------------------------------------------------------------------
|
||||
HSQOBJECT mObj; // Reference to the managed script object.
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Default constructor. (null)
|
||||
*/
|
||||
Argument()
|
||||
: mObj()
|
||||
{
|
||||
sq_resetobject(&mObj); // Initialize the object
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Forwarding constructor.
|
||||
*/
|
||||
Argument(Object & obj)
|
||||
: Argument(obj.GetObject())
|
||||
{
|
||||
/* ... */
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Base constructor.
|
||||
*/
|
||||
Argument(HSQOBJECT & obj)
|
||||
: mObj(obj)
|
||||
{
|
||||
// Is there a valid object?
|
||||
if (!sq_isnull(mObj))
|
||||
{
|
||||
sq_addref(DefaultVM::Get(), &mObj); // Keep a reference it
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Copy constructor. (disabled)
|
||||
*/
|
||||
Argument(const Argument & o) = delete;
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Move constructor.
|
||||
*/
|
||||
Argument(Argument && o)
|
||||
: mObj(o.mObj)
|
||||
{
|
||||
sq_resetobject(&o.mObj); // Take ownership
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Destructor.
|
||||
*/
|
||||
~Argument()
|
||||
{
|
||||
Release();
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Copy assignment operator. (disabled)
|
||||
*/
|
||||
Argument & operator = (const Argument & o) = delete;
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Move assignment operator.
|
||||
*/
|
||||
Argument & operator = (Argument && o)
|
||||
{
|
||||
if (this != &o)
|
||||
{
|
||||
// Release current resources, if any
|
||||
Release();
|
||||
// Replicate data
|
||||
mObj = o.mObj;
|
||||
// Take ownership
|
||||
sq_resetobject(&o.mObj);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------------------
|
||||
* Release managed script resources.
|
||||
*/
|
||||
void Release()
|
||||
{
|
||||
// Should we release any object?
|
||||
if (!sq_isnull(mObj))
|
||||
{
|
||||
sq_release(DefaultVM::Get(), &mObj);
|
||||
sq_resetobject(&mObj);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* --------------------------------------------------------------------------------------------
|
||||
* Structure that represents a task and keeps track of the task information.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user