1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-08-05 07:31:48 +02:00

Expand the host plug-in API and not just the Squirrel API.

Extend the host plug-in API with a few more date/time functions.
Update some of the plugins to use the expanded functions of the host plug-in API.
This commit is contained in:
Sandu Liviu Catalin
2016-07-04 16:26:39 +03:00
parent 805251a6db
commit 87ab54d453
22 changed files with 396 additions and 78 deletions

View File

@@ -22,12 +22,12 @@ Object Attribute::AsLong(Object & def) const
// The resulted long integer value
Int64 longint = 0;
// Attempt to get the numeric value inside the specified object
if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
if (SQ_FAILED(SqMod_GetSLongValue(_SqVM, -1, &longint)))
{
STHROWF("Invalid long integer specified");
}
// Push a long integer instance with the requested value on the stack
_SqMod->PushSLongObject(_SqVM, m_Attr.as_llong(longint));
SqMod_PushSLongObject(_SqVM, m_Attr.as_llong(longint));
// Obtain the object from the stack and return it
return Var< Object >(_SqVM, -1).value;
}
@@ -42,12 +42,12 @@ Object Attribute::AsUlong(Object & def) const
// The resulted long integer value
Uint64 longint = 0;
// Attempt to get the numeric value inside the specified object
if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
if (SQ_FAILED(SqMod_GetULongValue(_SqVM, -1, &longint)))
{
STHROWF("Invalid long integer specified");
}
// Push a long integer instance with the requested value on the stack
_SqMod->PushULongObject(_SqVM, m_Attr.as_ullong(longint));
SqMod_PushULongObject(_SqVM, m_Attr.as_ullong(longint));
// Obtain the object from the stack and return it
return Var< Object >(_SqVM, -1).value;
}
@@ -62,7 +62,7 @@ bool Attribute::ApplyLong(Object & value)
// The resulted long integer value
Int64 longint = 0;
// Attempt to get the numeric value inside the specified object
if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
if (SQ_FAILED(SqMod_GetSLongValue(_SqVM, -1, &longint)))
{
STHROWF("Invalid long integer specified");
}
@@ -80,7 +80,7 @@ bool Attribute::ApplyUlong(Object & value)
// The resulted long integer value
Uint64 longint = 0;
// Attempt to get the numeric value inside the specified object
if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
if (SQ_FAILED(SqMod_GetULongValue(_SqVM, -1, &longint)))
{
STHROWF("Invalid long integer specified");
}
@@ -94,7 +94,7 @@ Object Attribute::GetLong() const
// Obtain the initial stack size
const StackGuard sg(_SqVM);
// Push a long integer instance with the requested value on the stack
_SqMod->PushSLongObject(_SqVM, m_Attr.as_llong());
SqMod_PushSLongObject(_SqVM, m_Attr.as_llong());
// Obtain the object from the stack and return it
return Var< Object >(_SqVM, -1).value;
}
@@ -109,7 +109,7 @@ void Attribute::SetLong(Object & value)
// The resulted long integer value
Int64 longint = 0;
// Attempt to get the numeric value inside the specified object
if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
if (SQ_FAILED(SqMod_GetSLongValue(_SqVM, -1, &longint)))
{
STHROWF("Invalid long integer specified");
}
@@ -123,7 +123,7 @@ Object Attribute::GetUlong() const
// Obtain the initial stack size
const StackGuard sg(_SqVM);
// Push a long integer instance with the requested value on the stack
_SqMod->PushULongObject(_SqVM, m_Attr.as_ullong());
SqMod_PushULongObject(_SqVM, m_Attr.as_ullong());
// Obtain the object from the stack and return it
return Var< Object >(_SqVM, -1).value;
}
@@ -138,7 +138,7 @@ void Attribute::SetUlong(Object & value)
// The resulted long integer value
Uint64 longint = 0;
// Attempt to get the numeric value inside the specified object
if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
if (SQ_FAILED(SqMod_GetULongValue(_SqVM, -1, &longint)))
{
STHROWF("Invalid long integer specified");
}

View File

@@ -42,8 +42,10 @@ void OnSquirrelInitialize()
}
else
{
// Expand the Squirrel plug-in API into global functions
sqmod_api_expand(_SqMod);
// Obtain the Squirrel API
_SqAPI = _SqMod->GetSquirrelAPI();
_SqAPI = SqMod_GetSquirrelAPI();
// Expand the Squirrel API into global functions
sq_api_expand(_SqAPI);
}
@@ -60,7 +62,7 @@ void OnSquirrelLoad()
return; // Unable to proceed!
}
// Obtain the Squirrel API and VM
_SqVM = _SqMod->GetSquirrelVM();
_SqVM = SqMod_GetSquirrelVM();
// Make sure that a valid virtual machine exists
if (!_SqVM)
{

View File

@@ -43,12 +43,12 @@ Object Text::AsLong(Object & def) const
// The resulted long integer value
Int64 longint = 0;
// Attempt to get the numeric value inside the specified object
if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
if (SQ_FAILED(SqMod_GetSLongValue(_SqVM, -1, &longint)))
{
STHROWF("Invalid long integer specified");
}
// Push a long integer instance with the requested value on the stack
_SqMod->PushSLongObject(_SqVM, m_Text.as_llong(longint));
SqMod_PushSLongObject(_SqVM, m_Text.as_llong(longint));
// Obtain the object from the stack and return it
return Var< Object >(_SqVM, -1).value;
}
@@ -63,12 +63,12 @@ Object Text::AsUlong(Object & def) const
// The resulted long integer value
Uint64 longint = 0;
// Attempt to get the numeric value inside the specified object
if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
if (SQ_FAILED(SqMod_GetULongValue(_SqVM, -1, &longint)))
{
STHROWF("Invalid long integer specified");
}
// Push a long integer instance with the requested value on the stack
_SqMod->PushULongObject(_SqVM, m_Text.as_ullong(longint));
SqMod_PushULongObject(_SqVM, m_Text.as_ullong(longint));
// Obtain the object from the stack and return it
return Var< Object >(_SqVM, -1).value;
}
@@ -83,7 +83,7 @@ bool Text::ApplyLong(Object & value)
// The resulted long integer value
Int64 longint = 0;
// Attempt to get the numeric value inside the specified object
if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
if (SQ_FAILED(SqMod_GetSLongValue(_SqVM, -1, &longint)))
{
STHROWF("Invalid long integer specified");
}
@@ -101,7 +101,7 @@ bool Text::ApplyUlong(Object & value)
// The resulted long integer value
Uint64 longint = 0;
// Attempt to get the numeric value inside the specified object
if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
if (SQ_FAILED(SqMod_GetULongValue(_SqVM, -1, &longint)))
{
STHROWF("Invalid long integer specified");
}
@@ -115,7 +115,7 @@ Object Text::GetLong() const
// Obtain the initial stack size
const StackGuard sg(_SqVM);
// Push a long integer instance with the requested value on the stack
_SqMod->PushSLongObject(_SqVM, m_Text.as_llong());
SqMod_PushSLongObject(_SqVM, m_Text.as_llong());
// Obtain the object from the stack and return it
return Var< Object >(_SqVM, -1).value;
}
@@ -130,7 +130,7 @@ void Text::SetLong(Object & value)
// The resulted long integer value
Int64 longint = 0;
// Attempt to get the numeric value inside the specified object
if (SQ_FAILED(_SqMod->GetSLongValue(_SqVM, -1, &longint)))
if (SQ_FAILED(SqMod_GetSLongValue(_SqVM, -1, &longint)))
{
STHROWF("Invalid long integer specified");
}
@@ -144,7 +144,7 @@ Object Text::GetUlong() const
// Obtain the initial stack size
const StackGuard sg(_SqVM);
// Push a long integer instance with the requested value on the stack
_SqMod->PushULongObject(_SqVM, m_Text.as_ullong());
SqMod_PushULongObject(_SqVM, m_Text.as_ullong());
// Obtain the object from the stack and return it
return Var< Object >(_SqVM, -1).value;
}
@@ -159,7 +159,7 @@ void Text::SetUlong(Object & value)
// The resulted long integer value
Uint64 longint = 0;
// Attempt to get the numeric value inside the specified object
if (SQ_FAILED(_SqMod->GetULongValue(_SqVM, -1, &longint)))
if (SQ_FAILED(SqMod_GetULongValue(_SqVM, -1, &longint)))
{
STHROWF("Invalid long integer specified");
}