1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 00:37:15 +01:00

Move shared code into main source.

Remove extra module API.
This commit is contained in:
Sandu Liviu Catalin 2020-03-21 22:16:48 +02:00
parent 22c8d84b1e
commit 9978dbe88c
10 changed files with 2 additions and 1314 deletions

View File

@ -1 +0,0 @@
#include "Utility.inl"

View File

@ -1 +0,0 @@
#include "Utility.inl"

View File

@ -68,42 +68,6 @@ extern "C" {
typedef void (*SqModAPI_LogMessage) (const SQChar * fmt, ...);
//script loading
typedef SQRESULT (*SqModAPI_LoadScript) (const SQChar * filepath, SQBool delay);
//numeric utilities
typedef SQRESULT (*SqModAPI_GetSLongValue) (HSQUIRRELVM vm, SQInteger idx, SqInt64 * num);
typedef SQRESULT (*SqModAPI_PushSLongObject) (HSQUIRRELVM vm, SqInt64 num);
typedef SQRESULT (*SqModAPI_GetULongValue) (HSQUIRRELVM vm, SQInteger idx, SqUint64 * num);
typedef SQRESULT (*SqModAPI_PushULongObject) (HSQUIRRELVM vm, SqUint64 num);
//time utilities
typedef SqInt64 (*SqModAPI_GetCurrentSysTime) (void);
typedef SqInt64 (*SqModAPI_GetEpochTimeMicro) (void);
typedef SqInt64 (*SqModAPI_GetEpochTimeMilli) (void);
typedef SQBool (*SqModAPI_ValidDate) (uint16_t year, uint8_t month, uint8_t day);
typedef SQBool (*SqModAPI_IsLeapYear) (uint16_t year);
typedef uint16_t (*SqModAPI_DaysInYear) (uint16_t year);
typedef uint8_t (*SqModAPI_DaysInMonth) (uint16_t year, uint8_t month);
typedef uint16_t (*SqModAPI_DayOfYear) (uint16_t year, uint8_t month, uint8_t day);
typedef SqInt64 (*SqModAPI_DateRangeToSeconds) (uint16_t lyear, uint8_t lmonth, uint8_t lday, uint16_t ryear, uint8_t rmonth, uint8_t rday);
typedef SQRESULT (*SqModAPI_GetTimestamp) (HSQUIRRELVM vm, SQInteger idx, SqInt64 * num);
typedef SQRESULT (*SqModAPI_PushTimestamp) (HSQUIRRELVM vm, SqInt64 num);
typedef SQRESULT (*SqModAPI_GetDate) (HSQUIRRELVM vm, SQInteger idx, uint16_t * year, uint8_t * month, uint8_t * day);
typedef SQRESULT (*SqModAPI_PushDate) (HSQUIRRELVM vm, uint16_t year, uint8_t month, uint8_t day);
typedef SQRESULT (*SqModAPI_GetTime) (HSQUIRRELVM vm, SQInteger idx, uint8_t * hour, uint8_t * minute, uint8_t * second, uint16_t * millisecond);
typedef SQRESULT (*SqModAPI_PushTime) (HSQUIRRELVM vm, uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond);
typedef SQRESULT (*SqModAPI_GetDatetime) (HSQUIRRELVM vm, SQInteger idx, uint16_t * year, uint8_t * month, uint8_t * day, uint8_t * hour, uint8_t * minute, uint8_t * second, uint16_t * millisecond);
typedef SQRESULT (*SqModAPI_PushDatetime) (HSQUIRRELVM vm, uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond);
//stack utilities
typedef SQInteger (*SqModAPI_PopStackInteger) (HSQUIRRELVM vm, SQInteger idx);
typedef SQFloat (*SqModAPI_PopStackFloat) (HSQUIRRELVM vm, SQInteger idx);
typedef SqInt64 (*SqModAPI_PopStackSLong) (HSQUIRRELVM vm, SQInteger idx);
typedef SqUint64 (*SqModAPI_PopStackULong) (HSQUIRRELVM vm, SQInteger idx);
//buffer utilities
typedef SQRESULT (*SqModAPI_PushBuffer) (HSQUIRRELVM vm, SQInteger size, SQInteger cursor);
typedef SQRESULT (*SqModAPI_PushBufferData) (HSQUIRRELVM vm, const char * data, SQInteger size, SQInteger cursor);
typedef SQRESULT (*SqModAPI_GetBufferInfo) (HSQUIRRELVM vm, SQInteger idx, const char ** ptr, SQInteger * size, SQInteger * cursor);
typedef const char * (*SqModAPI_GetBufferData) (HSQUIRRELVM vm, SQInteger idx);
typedef SQInteger (*SqModAPI_GetBufferSize) (HSQUIRRELVM vm, SQInteger idx);
typedef SQInteger (*SqModAPI_GetBufferCursor) (HSQUIRRELVM vm, SQInteger idx);
/* --------------------------------------------------------------------------------------------
* Allows modules to interface with the plug-in API without linking of any sorts
*/
@ -128,41 +92,6 @@ extern "C" {
SqModAPI_LogMessage LogSFtl;
//script loading
SqModAPI_LoadScript LoadScript;
//numeric utilities
SqModAPI_GetSLongValue GetSLongValue;
SqModAPI_PushSLongObject PushSLongObject;
SqModAPI_GetULongValue GetULongValue;
SqModAPI_PushULongObject PushULongObject;
//time utilities
SqModAPI_GetCurrentSysTime GetCurrentSysTime;
SqModAPI_GetEpochTimeMicro GetEpochTimeMicro;
SqModAPI_GetEpochTimeMilli GetEpochTimeMilli;
SqModAPI_ValidDate ValidDate;
SqModAPI_IsLeapYear IsLeapYear;
SqModAPI_DaysInYear DaysInYear;
SqModAPI_DaysInMonth DaysInMonth;
SqModAPI_DayOfYear DayOfYear;
SqModAPI_DateRangeToSeconds DateRangeToSeconds;
SqModAPI_GetTimestamp GetTimestamp;
SqModAPI_PushTimestamp PushTimestamp;
SqModAPI_GetDate GetDate;
SqModAPI_PushDate PushDate;
SqModAPI_GetTime GetTime;
SqModAPI_PushTime PushTime;
SqModAPI_GetDatetime GetDatetime;
SqModAPI_PushDatetime PushDatetime;
//stack utilities
SqModAPI_PopStackInteger PopStackInteger;
SqModAPI_PopStackFloat PopStackFloat;
SqModAPI_PopStackSLong PopStackSLong;
SqModAPI_PopStackULong PopStackULong;
//buffer utilities
SqModAPI_PushBuffer PushBuffer;
SqModAPI_PushBufferData PushBufferData;
SqModAPI_GetBufferInfo GetBufferInfo;
SqModAPI_GetBufferData GetBufferData;
SqModAPI_GetBufferSize GetBufferSize;
SqModAPI_GetBufferCursor GetBufferCursor;
} sq_modapi, SQMODAPI, *HSQMODAPI;
#ifdef SQMOD_PLUGIN_API
@ -189,45 +118,6 @@ extern "C" {
//script loading
extern SqModAPI_LoadScript SqMod_LoadScript;
//numeric utilities
extern SqModAPI_GetSLongValue SqMod_GetSLongValue;
extern SqModAPI_PushSLongObject SqMod_PushSLongObject;
extern SqModAPI_GetULongValue SqMod_GetULongValue;
extern SqModAPI_PushULongObject SqMod_PushULongObject;
//time utilities
extern SqModAPI_GetCurrentSysTime SqMod_GetCurrentSysTime;
extern SqModAPI_GetEpochTimeMicro SqMod_GetEpochTimeMicro;
extern SqModAPI_GetEpochTimeMilli SqMod_GetEpochTimeMilli;
extern SqModAPI_ValidDate SqMod_ValidDate;
extern SqModAPI_IsLeapYear SqMod_IsLeapYear;
extern SqModAPI_DaysInYear SqMod_DaysInYear;
extern SqModAPI_DaysInMonth SqMod_DaysInMonth;
extern SqModAPI_DayOfYear SqMod_DayOfYear;
extern SqModAPI_DateRangeToSeconds SqMod_DateRangeToSeconds;
extern SqModAPI_GetTimestamp SqMod_GetTimestamp;
extern SqModAPI_PushTimestamp SqMod_PushTimestamp;
extern SqModAPI_GetDate SqMod_GetDate;
extern SqModAPI_PushDate SqMod_PushDate;
extern SqModAPI_GetTime SqMod_GetTime;
extern SqModAPI_PushTime SqMod_PushTime;
extern SqModAPI_GetDatetime SqMod_GetDatetime;
extern SqModAPI_PushDatetime SqMod_PushDatetime;
//stack utilities
extern SqModAPI_PopStackInteger SqMod_PopStackInteger;
extern SqModAPI_PopStackFloat SqMod_PopStackFloat;
extern SqModAPI_PopStackSLong SqMod_PopStackSLong;
extern SqModAPI_PopStackULong SqMod_PopStackULong;
//buffer utilities
extern SqModAPI_PushBuffer SqMod_PushBuffer;
extern SqModAPI_PushBufferData SqMod_PushBufferData;
extern SqModAPI_GetBufferInfo SqMod_GetBufferInfo;
extern SqModAPI_GetBufferData SqMod_GetBufferData;
extern SqModAPI_GetBufferSize SqMod_GetBufferSize;
extern SqModAPI_GetBufferCursor SqMod_GetBufferCursor;
#endif // SQMOD_PLUGIN_API
/* --------------------------------------------------------------------------------------------

View File

@ -23,45 +23,6 @@ SqModAPI_LogMessage SqMod_LogSFtl
//script loading
SqModAPI_LoadScript SqMod_LoadScript = NULL;
//numeric utilities
SqModAPI_GetSLongValue SqMod_GetSLongValue = NULL;
SqModAPI_PushSLongObject SqMod_PushSLongObject = NULL;
SqModAPI_GetULongValue SqMod_GetULongValue = NULL;
SqModAPI_PushULongObject SqMod_PushULongObject = NULL;
//time utilities
SqModAPI_GetCurrentSysTime SqMod_GetCurrentSysTime = NULL;
SqModAPI_GetEpochTimeMicro SqMod_GetEpochTimeMicro = NULL;
SqModAPI_GetEpochTimeMilli SqMod_GetEpochTimeMilli = NULL;
SqModAPI_ValidDate SqMod_ValidDate = NULL;
SqModAPI_IsLeapYear SqMod_IsLeapYear = NULL;
SqModAPI_DaysInYear SqMod_DaysInYear = NULL;
SqModAPI_DaysInMonth SqMod_DaysInMonth = NULL;
SqModAPI_DayOfYear SqMod_DayOfYear = NULL;
SqModAPI_DateRangeToSeconds SqMod_DateRangeToSeconds = NULL;
SqModAPI_GetTimestamp SqMod_GetTimestamp = NULL;
SqModAPI_PushTimestamp SqMod_PushTimestamp = NULL;
SqModAPI_GetDate SqMod_GetDate = NULL;
SqModAPI_PushDate SqMod_PushDate = NULL;
SqModAPI_GetTime SqMod_GetTime = NULL;
SqModAPI_PushTime SqMod_PushTime = NULL;
SqModAPI_GetDatetime SqMod_GetDatetime = NULL;
SqModAPI_PushDatetime SqMod_PushDatetime = NULL;
//stack utilities
SqModAPI_PopStackInteger SqMod_PopStackInteger = NULL;
SqModAPI_PopStackFloat SqMod_PopStackFloat = NULL;
SqModAPI_PopStackSLong SqMod_PopStackSLong = NULL;
SqModAPI_PopStackULong SqMod_PopStackULong = NULL;
//buffer utilities
SqModAPI_PushBuffer SqMod_PushBuffer = NULL;
SqModAPI_PushBufferData SqMod_PushBufferData = NULL;
SqModAPI_GetBufferInfo SqMod_GetBufferInfo = NULL;
SqModAPI_GetBufferData SqMod_GetBufferData = NULL;
SqModAPI_GetBufferSize SqMod_GetBufferSize = NULL;
SqModAPI_GetBufferCursor SqMod_GetBufferCursor = NULL;
#endif // SQMOD_PLUGIN_API
// ------------------------------------------------------------------------------------------------
@ -96,45 +57,6 @@ uint8_t sqmod_api_expand(HSQMODAPI sqmodapi)
//script loading
SqMod_LoadScript = sqmodapi->LoadScript;
//numeric utilities
SqMod_GetSLongValue = sqmodapi->GetSLongValue;
SqMod_PushSLongObject = sqmodapi->PushSLongObject;
SqMod_GetULongValue = sqmodapi->GetULongValue;
SqMod_PushULongObject = sqmodapi->PushULongObject;
//time utilities
SqMod_GetCurrentSysTime = sqmodapi->GetCurrentSysTime;
SqMod_GetEpochTimeMicro = sqmodapi->GetEpochTimeMicro;
SqMod_GetEpochTimeMilli = sqmodapi->GetEpochTimeMilli;
SqMod_ValidDate = sqmodapi->ValidDate;
SqMod_IsLeapYear = sqmodapi->IsLeapYear;
SqMod_DaysInYear = sqmodapi->DaysInYear;
SqMod_DaysInMonth = sqmodapi->DaysInMonth;
SqMod_DayOfYear = sqmodapi->DayOfYear;
SqMod_DateRangeToSeconds = sqmodapi->DateRangeToSeconds;
SqMod_GetTimestamp = sqmodapi->GetTimestamp;
SqMod_PushTimestamp = sqmodapi->PushTimestamp;
SqMod_GetDate = sqmodapi->GetDate;
SqMod_PushDate = sqmodapi->PushDate;
SqMod_GetTime = sqmodapi->GetTime;
SqMod_PushTime = sqmodapi->PushTime;
SqMod_GetDatetime = sqmodapi->GetDatetime;
SqMod_PushDatetime = sqmodapi->PushDatetime;
//stack utilities
SqMod_PopStackInteger = sqmodapi->PopStackInteger;
SqMod_PopStackFloat = sqmodapi->PopStackFloat;
SqMod_PopStackSLong = sqmodapi->PopStackSLong;
SqMod_PopStackULong = sqmodapi->PopStackULong;
//buffer utilities
SqMod_PushBuffer = sqmodapi->PushBuffer;
SqMod_PushBufferData = sqmodapi->PushBufferData;
SqMod_GetBufferInfo = sqmodapi->GetBufferInfo;
SqMod_GetBufferData = sqmodapi->GetBufferData;
SqMod_GetBufferSize = sqmodapi->GetBufferSize;
SqMod_GetBufferCursor = sqmodapi->GetBufferCursor;
#endif // SQMOD_PLUGIN_API
return 1;
@ -167,45 +89,6 @@ void sqmod_api_collapse()
//script loading
SqMod_LoadScript = NULL;
//numeric utilities
SqMod_GetSLongValue = NULL;
SqMod_PushSLongObject = NULL;
SqMod_GetULongValue = NULL;
SqMod_PushULongObject = NULL;
//time utilities
SqMod_GetCurrentSysTime = NULL;
SqMod_GetEpochTimeMicro = NULL;
SqMod_GetEpochTimeMilli = NULL;
SqMod_ValidDate = NULL;
SqMod_IsLeapYear = NULL;
SqMod_DaysInYear = NULL;
SqMod_DaysInMonth = NULL;
SqMod_DayOfYear = NULL;
SqMod_DateRangeToSeconds = NULL;
SqMod_GetTimestamp = NULL;
SqMod_PushTimestamp = NULL;
SqMod_GetDate = NULL;
SqMod_PushDate = NULL;
SqMod_GetTime = NULL;
SqMod_PushTime = NULL;
SqMod_GetDatetime = NULL;
SqMod_PushDatetime = NULL;
//stack utilities
SqMod_PopStackInteger = NULL;
SqMod_PopStackFloat = NULL;
SqMod_PopStackSLong = NULL;
SqMod_PopStackULong = NULL;
//buffer utilities
SqMod_PushBuffer = NULL;
SqMod_PushBufferData = NULL;
SqMod_GetBufferInfo = NULL;
SqMod_GetBufferData = NULL;
SqMod_GetBufferSize = NULL;
SqMod_GetBufferCursor = NULL;
#endif // SQMOD_PLUGIN_API
}

View File

@ -16,10 +16,8 @@
#endif // SQMOD_OS_WINDOWS
// ------------------------------------------------------------------------------------------------
#ifndef SQMOD_PLUGIN_API
#include "Library/Numeric/LongInt.hpp"
#include <sqstdstring.h>
#endif // SQMOD_PLUGIN_API
#include "Library/Numeric/LongInt.hpp"
#include <sqstdstring.h>
// ------------------------------------------------------------------------------------------------
namespace SqMod {
@ -672,361 +670,9 @@ Object BufferToStrObj(const Buffer & b, Uint32 size)
return Var< Object >(DefaultVM::Get(), -1).value;
}
// ------------------------------------------------------------------------------------------------
Object MakeSLongObj(Int64 value)
{
// Obtain the default virtual machine
HSQUIRRELVM vm = DefaultVM::Get();
// Obtain the initial stack size
const StackGuard sg(vm);
#ifdef SQMOD_PLUGIN_API
// Push a long integer instance with the requested value on the stack
SqMod_PushSLongObject(vm, value);
#else
// Transform the specified value into a script object
PushVar< SLongInt >(vm, SLongInt(value));
#endif // SQMOD_PLUGIN_API
// Obtain the object from the stack and return it
return Var< Object >(vm, -1).value;
}
// ------------------------------------------------------------------------------------------------
Object MakeULongObj(Uint64 value)
{
// Obtain the default virtual machine
HSQUIRRELVM vm = DefaultVM::Get();
// Obtain the initial stack size
const StackGuard sg(vm);
#ifdef SQMOD_PLUGIN_API
// Push a long integer instance with the requested value on the stack
SqMod_PushULongObject(vm, value);
#else
// Transform the specified value into a script object
PushVar< ULongInt >(vm, ULongInt(value));
#endif // SQMOD_PLUGIN_API
// Obtain the object from the stack and return it
return Var< Object >(vm, -1).value;
}
// ------------------------------------------------------------------------------------------------
Object MakeSLongObj(HSQUIRRELVM vm, Int64 value)
{
// Obtain the initial stack size
const StackGuard sg(vm);
#ifdef SQMOD_PLUGIN_API
// Push a long integer instance with the requested value on the stack
SqMod_PushSLongObject(vm, value);
#else
// Transform the specified value into a script object
PushVar< SLongInt >(vm, SLongInt(value));
#endif // SQMOD_PLUGIN_API
// Obtain the object from the stack and return it
return Var< Object >(vm, -1).value;
}
// ------------------------------------------------------------------------------------------------
Object MakeULongObj(HSQUIRRELVM vm, Uint64 value)
{
// Obtain the initial stack size
const StackGuard sg(vm);
#ifdef SQMOD_PLUGIN_API
// Push a long integer instance with the requested value on the stack
SqMod_PushULongObject(vm, value);
#else
// Transform the specified value into a script object
PushVar< ULongInt >(vm, ULongInt(value));
#endif // SQMOD_PLUGIN_API
// Obtain the object from the stack and return it
return Var< Object >(vm, -1).value;
}
// ------------------------------------------------------------------------------------------------
Int64 FetchSLongObjVal(const Object & value)
{
// Grab the associated object virtual machine
HSQUIRRELVM vm = value.GetVM();
// Obtain the initial stack size
const StackGuard sg(vm);
// Push the specified object onto the stack
Var< const Object & >::push(vm, value);
// Retrieve and return the object value from the stack
return PopStackSLong(vm, -1);
}
// ------------------------------------------------------------------------------------------------
Uint64 FetchULongObjVal(const Object & value)
{
// Grab the associated object virtual machine
HSQUIRRELVM vm = value.GetVM();
// Obtain the initial stack size
const StackGuard sg(vm);
// Push the specified object onto the stack
Var< const Object & >::push(vm, value);
// Retrieve and return the object value from the stack
return PopStackSLong(vm, -1);
}
// ------------------------------------------------------------------------------------------------
SQRESULT FetchDateObjVal(const Object & value, Uint16 & year, Uint8 & month, Uint8 & day)
{
#ifdef SQMOD_PLUGIN_API
// Grab the associated object virtual machine
HSQUIRRELVM vm = value.GetVM();
// Remember the current stack size
const StackGuard sg(vm);
// Push the specified object onto the stack
Var< const Object & >::push(vm, value);
// Grab the date components from the date instance
return SqMod_GetDate(vm, -1, &year, &month, &day);
#else
STHROWF("This method is only available in modules");
// Should not reach this point
return SQ_ERROR;
// Avoid unused parameter warnings
SQMOD_UNUSED_VAR(value);
SQMOD_UNUSED_VAR(year);
SQMOD_UNUSED_VAR(month);
SQMOD_UNUSED_VAR(day);
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------
CSStr FetchDateObjStr(const Object & value)
{
#ifdef SQMOD_PLUGIN_API
static SQChar buffer[32];
// Grab the associated object virtual machine
HSQUIRRELVM vm = value.GetVM();
// Remember the current stack size
const StackGuard sg(vm);
// Push the specified object onto the stack
Var< const Object & >::push(vm, value);
// Grab the date instance as a string
StackStrF val(vm, -1);
// Validate the result
if (SQ_FAILED(val.Proc(false)))
{
return _SC("1000-01-01");
}
// Copy the string into the common buffer
std::strncpy(buffer, val.mPtr, sizeof(buffer));
// Return the obtained string
return buffer;
#else
STHROWF("This method is only available in modules");
// Should not reach this point
return nullptr;
// Avoid unused parameter warnings
SQMOD_UNUSED_VAR(value);
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------
SQRESULT FetchTimeObjVal(const Object & value, Uint8 & hour, Uint8 & minute, Uint8 & second)
{
#ifdef SQMOD_PLUGIN_API
// Grab the associated object virtual machine
HSQUIRRELVM vm = value.GetVM();
// Remember the current stack size
const StackGuard sg(vm);
// Push the specified object onto the stack
Var< const Object & >::push(vm, value);
// Grab the date components from the date instance
return SqMod_GetTime(vm, -1, &hour, &minute, &second, nullptr);
#else
STHROWF("This method is only available in modules");
// Should not reach this point
return SQ_ERROR;
// Avoid unused parameter warnings
SQMOD_UNUSED_VAR(value);
SQMOD_UNUSED_VAR(hour);
SQMOD_UNUSED_VAR(minute);
SQMOD_UNUSED_VAR(second);
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------
SQRESULT FetchTimeObjVal(const Object & value, Uint8 & hour, Uint8 & minute, Uint8 & second, Uint16 & millisecond)
{
#ifdef SQMOD_PLUGIN_API
// Grab the associated object virtual machine
HSQUIRRELVM vm = value.GetVM();
// Remember the current stack size
const StackGuard sg(vm);
// Push the specified object onto the stack
Var< const Object & >::push(vm, value);
// Grab the date components from the date instance
return SqMod_GetTime(vm, -1, &hour, &minute, &second, &millisecond);
#else
STHROWF("This method is only available in modules");
// Should not reach this point
return SQ_ERROR;
// Avoid unused parameter warnings
SQMOD_UNUSED_VAR(value);
SQMOD_UNUSED_VAR(hour);
SQMOD_UNUSED_VAR(minute);
SQMOD_UNUSED_VAR(second);
SQMOD_UNUSED_VAR(millisecond);
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------
CSStr FetchTimeObjStr(const Object & value)
{
#ifdef SQMOD_PLUGIN_API
static SQChar buffer[32];
// Grab the associated object virtual machine
HSQUIRRELVM vm = value.GetVM();
// Remember the current stack size
const StackGuard sg(vm);
// Push the specified object onto the stack
Var< const Object & >::push(vm, value);
// Grab the time instance as a string
StackStrF val(vm, -1);
// Validate the result
if (SQ_FAILED(val.Proc(false)))
{
return _SC("00:00:00");
}
// Copy the string into the common buffer
std::strncpy(buffer, val.mPtr, sizeof(buffer));
// Remove the millisecond part from the string, if any
buffer[8] = '\0';
// Return the obtained string
return buffer;
#else
STHROWF("This method is only available in modules");
// Should not reach this point
return nullptr;
// Avoid unused parameter warnings
SQMOD_UNUSED_VAR(value);
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------
Int32 FetchTimeObjSeconds(const Object & value)
{
#ifdef SQMOD_PLUGIN_API
// Grab the associated object virtual machine
HSQUIRRELVM vm = value.GetVM();
// Remember the current stack size
const StackGuard sg(vm);
// Push the specified object onto the stack
Var< const Object & >::push(vm, value);
// The time components
uint8_t h = 0, m = 0, s = 0;
// Grab the time components from the time instance
if (SQ_FAILED(SqMod_GetTime(vm, -1, &h, &m, &s, nullptr)))
{
STHROWF("Unable to obtain the time info");
}
// Return the number of seconds in the specified time
return ((h * (60 * 60)) + (m * 60) + s);
#else
STHROWF("This method is only available in modules");
// Should not reach this point
return 0;
// Avoid unused parameter warnings
SQMOD_UNUSED_VAR(value);
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------
SQRESULT FetchDatetimeObjVal(const Object & value, Uint16 & year, Uint8 & month, Uint8 & day, Uint8 & hour,
Uint8 & minute, Uint8 & second)
{
#ifdef SQMOD_PLUGIN_API
// Grab the associated object virtual machine
HSQUIRRELVM vm = value.GetVM();
// Remember the current stack size
const StackGuard sg(vm);
// Push the specified object onto the stack
Var< const Object & >::push(vm, value);
// Grab the date components from the date instance
return SqMod_GetDatetime(vm, -1, &year, &month, &day, &hour, &minute, &second, nullptr);
#else
STHROWF("This method is only available in modules");
// Should not reach this point
return SQ_ERROR;
// Avoid unused parameter warnings
SQMOD_UNUSED_VAR(value);
SQMOD_UNUSED_VAR(year);
SQMOD_UNUSED_VAR(month);
SQMOD_UNUSED_VAR(day);
SQMOD_UNUSED_VAR(hour);
SQMOD_UNUSED_VAR(minute);
SQMOD_UNUSED_VAR(second);
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------
SQRESULT FetchDatetimeObjVal(const Object & value, Uint16 & year, Uint8 & month, Uint8 & day, Uint8 & hour,
Uint8 & minute, Uint8 & second, Uint16 & millisecond)
{
#ifdef SQMOD_PLUGIN_API
// Grab the associated object virtual machine
HSQUIRRELVM vm = value.GetVM();
// Remember the current stack size
const StackGuard sg(vm);
// Push the specified object onto the stack
Var< const Object & >::push(vm, value);
// Grab the date components from the date instance
return SqMod_GetDatetime(vm, -1, &year, &month, &day, &hour, &minute, &second, &millisecond);
#else
STHROWF("This method is only available in modules");
// Should not reach this point
return SQ_ERROR;
// Avoid unused parameter warnings
SQMOD_UNUSED_VAR(value);
SQMOD_UNUSED_VAR(year);
SQMOD_UNUSED_VAR(month);
SQMOD_UNUSED_VAR(day);
SQMOD_UNUSED_VAR(hour);
SQMOD_UNUSED_VAR(minute);
SQMOD_UNUSED_VAR(second);
SQMOD_UNUSED_VAR(millisecond);
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------
CSStr FetchDatetimeObjStr(const Object & value)
{
#ifdef SQMOD_PLUGIN_API
static SQChar buffer[32];
// Grab the associated object virtual machine
HSQUIRRELVM vm = value.GetVM();
// Remember the current stack size
const StackGuard sg(vm);
// Push the specified object onto the stack
Var< const Object & >::push(vm, value);
// Grab the date-time instance as a string
StackStrF val(vm, -1);
// Validate the result
if (SQ_FAILED(val.Proc(false)))
{
return _SC("1000-01-01 00:00:00");
}
// Copy the string into the common buffer
std::strncpy(buffer, val.mPtr, sizeof(buffer));
// Remove the millisecond part from the string, if any
buffer[19] = '\0';
// Return the obtained string
return buffer;
#else
STHROWF("This method is only available in modules");
// Should not reach this point
return nullptr;
// Avoid unused parameter warnings
SQMOD_UNUSED_VAR(value);
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------
SQInteger PopStackInteger(HSQUIRRELVM vm, SQInteger idx)
{
#ifdef SQMOD_PLUGIN_API
return SqMod_PopStackInteger(vm, idx);
#else
// Identify which type must be extracted
switch (sq_gettype(vm, idx))
{
@ -1091,15 +737,11 @@ SQInteger PopStackInteger(HSQUIRRELVM vm, SQInteger idx)
}
// Default to 0
return 0;
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------
SQFloat PopStackFloat(HSQUIRRELVM vm, SQInteger idx)
{
#ifdef SQMOD_PLUGIN_API
return SqMod_PopStackFloat(vm, idx);
#else
// Identify which type must be extracted
switch (sq_gettype(vm, idx))
{
@ -1168,15 +810,11 @@ SQFloat PopStackFloat(HSQUIRRELVM vm, SQInteger idx)
}
// Default to 0
return 0.0;
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------
Int64 PopStackSLong(HSQUIRRELVM vm, SQInteger idx)
{
#ifdef SQMOD_PLUGIN_API
return SqMod_PopStackSLong(vm, idx);
#else
// Identify which type must be extracted
switch (sq_gettype(vm, idx))
{
@ -1241,15 +879,11 @@ Int64 PopStackSLong(HSQUIRRELVM vm, SQInteger idx)
}
// Default to 0
return 0;
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------
Uint64 PopStackULong(HSQUIRRELVM vm, SQInteger idx)
{
#ifdef SQMOD_PLUGIN_API
return SqMod_PopStackULong(vm, idx);
#else
// Identify which type must be extracted
switch (sq_gettype(vm, idx))
{
@ -1314,7 +948,6 @@ Uint64 PopStackULong(HSQUIRRELVM vm, SQInteger idx)
}
// Default to 0
return 0;
#endif // SQMOD_PLUGIN_API
}
// ------------------------------------------------------------------------------------------------

View File

@ -1477,83 +1477,6 @@ Object BufferToStrObj(const Buffer & b);
*/
Object BufferToStrObj(const Buffer & b, Uint32 size);
/* ------------------------------------------------------------------------------------------------
* Create a signed long integer instance from an integer.
*/
Object MakeSLongObj(Int64 value);
/* ------------------------------------------------------------------------------------------------
* Create a unsigned long integer instance from an integer.
*/
Object MakeULongObj(Uint64 value);
/* ------------------------------------------------------------------------------------------------
* Create a signed long integer instance from an integer.
*/
Object MakeSLongObj(HSQUIRRELVM vm, Int64 value);
/* ------------------------------------------------------------------------------------------------
* Create a unsigned long integer instance from an integer.
*/
Object MakeULongObj(HSQUIRRELVM vm, Uint64 value);
/* ------------------------------------------------------------------------------------------------
* Retrieve a signed 64 bit integer from an signed long integer instance.
*/
Int64 FetchSLongObjVal(const Object & value);
/* ------------------------------------------------------------------------------------------------
* Retrieve a unsigned 64 bit integer from an unsigned long integer instance.
*/
Uint64 FetchULongObjVal(const Object & value);
/* ------------------------------------------------------------------------------------------------
* Retrieve the date components from a date instance.
*/
SQRESULT FetchDateObjVal(const Object & value, Uint16 & year, Uint8 & month, Uint8 & day);
/* ------------------------------------------------------------------------------------------------
* Retrieve the date components from a date instance as a string.
*/
CSStr FetchDateObjStr(const Object & value);
/* ------------------------------------------------------------------------------------------------
* Retrieve the time components from a date instance.
*/
SQRESULT FetchTimeObjVal(const Object & value, Uint8 & hour, Uint8 & minute, Uint8 & second);
/* ------------------------------------------------------------------------------------------------
* Retrieve the time components from a date instance.
*/
SQRESULT FetchTimeObjVal(const Object & value, Uint8 & hour, Uint8 & minute, Uint8 & second, Uint16 & millisecond);
/* ------------------------------------------------------------------------------------------------
* Retrieve the time components from a date instance as a string.
*/
CSStr FetchTimeObjStr(const Object & value);
/* ------------------------------------------------------------------------------------------------
* Retrieve the time components from a date instance as the number of seconds.
*/
Int32 FetchTimeObjSeconds(const Object & value);
/* ------------------------------------------------------------------------------------------------
* Retrieve the date-time components from a date-time instance.
*/
SQRESULT FetchDatetimeObjVal(const Object & value, Uint16 & year, Uint8 & month, Uint8 & day, Uint8 & hour,
Uint8 & minute, Uint8 & second);
/* ------------------------------------------------------------------------------------------------
* Retrieve the date-time components from a date-time instance.
*/
SQRESULT FetchDatetimeObjVal(const Object & value, Uint16 & year, Uint8 & month, Uint8 & day, Uint8 & hour,
Uint8 & minute, Uint8 & second, Uint16 & millisecond);
/* ------------------------------------------------------------------------------------------------
* Retrieve the date-time components from a date-time instance as a string.
*/
CSStr FetchDatetimeObjStr(const Object & value);
/* ------------------------------------------------------------------------------------------------
* Attempt to pop the value at the specified index on the stack as a native integer.
*/

View File

@ -1,14 +1,5 @@
// ------------------------------------------------------------------------------------------------
#include "Core.hpp"
#include "Base/Buffer.hpp"
// ------------------------------------------------------------------------------------------------
#include "Library/Numeric/LongInt.hpp"
#include "Library/Chrono/Date.hpp"
#include "Library/Chrono/Time.hpp"
#include "Library/Chrono/Datetime.hpp"
#include "Library/Chrono/Timestamp.hpp"
#include "Library/Utils/Buffer.hpp"
// ------------------------------------------------------------------------------------------------
#include <cmath>
@ -42,597 +33,6 @@ static SQRESULT SqModImpl_LoadScript(const SQChar * filepath, SQBool delay)
return SQ_ERROR;
}
// ------------------------------------------------------------------------------------------------
static SQRESULT SqModImpl_GetSLongValue(HSQUIRRELVM vm, SQInteger idx, Int64 * num)
{
// Validate the specified number pointer and value type
if (!num)
{
return SQ_ERROR; // Nowhere to save!
}
// Is this an instance that we can treat as a SLongInt type?
else if (sq_gettype(vm, idx) == OT_INSTANCE)
{
// Attempt to obtain the long instance and it's value from the stack
try
{
*num = static_cast< Int64 >(Var< const SLongInt & >(vm, idx).value.GetNum());
}
catch (...)
{
return SQ_ERROR; // Unable to obtain the value!
}
}
// Is this a pure integer value?
else if(sq_gettype(vm, idx) == OT_INTEGER)
{
SQInteger val = 0;
// Attempt to get the value from the stack
sq_getinteger(vm, idx, &val);
// Save it into the specified memory location
*num = static_cast< Int64 >(val);
}
// Is this a pure floating point value?
else if(sq_gettype(vm, idx) == OT_FLOAT)
{
SQFloat val = 0.0;
// Attempt to get the value from the stack
sq_getfloat(vm, idx, &val);
// Save it into the specified memory location
*num = static_cast< Int64 >(std::llround(val));
}
// Is this a pure boolean value?
else if(sq_gettype(vm, idx) == OT_BOOL)
{
SQBool val = SQFalse;
// Attempt to get the value from the stack
sq_getbool(vm, idx, &val);
// Save it into the specified memory location
*num = static_cast< Int64 >(val);
}
// Unrecognized value
else
{
return SQ_ERROR;
}
// Value retrieved
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
static SQRESULT SqModImpl_PushSLongObject(HSQUIRRELVM vm, Int64 num)
{
// Attempt to push the requested instance
try
{
Var< const SLongInt & >::push(vm, SLongInt(num));
}
catch (...)
{
// Specify that we failed
return SQ_ERROR;
}
// Specify that we succeeded
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
static SQRESULT SqModImpl_GetULongValue(HSQUIRRELVM vm, SQInteger idx, Uint64 * num)
{
// Validate the specified number pointer and value type
if (!num)
{
return SQ_ERROR; // Nowhere to save
}
// Is this an instance that we can treat as a ULongInt type?
else if (sq_gettype(vm, idx) == OT_INSTANCE)
{
// Attempt to obtain the long instance and it's value from the stack
try
{
*num = static_cast< Uint64 >(Var< const ULongInt & >(vm, idx).value.GetNum());
}
catch (...)
{
return SQ_ERROR; // Unable to obtain the value!
}
}
// Is this a pure integer value?
else if(sq_gettype(vm, idx) == OT_INTEGER)
{
SQInteger val = 0;
// Attempt to get the value from the stack
sq_getinteger(vm, idx, &val);
// Save it into the specified memory location
*num = val ? static_cast< Uint64 >(val) : 0L;
}
// Is this a pure floating point value?
else if(sq_gettype(vm, idx) == OT_FLOAT)
{
SQFloat val = 0.0;
// Attempt to get the value from the stack
sq_getfloat(vm, idx, &val);
// Save it into the specified memory location
*num = EpsLt(val, SQFloat(0.0)) ? 0L : static_cast< Uint64 >(std::llround(val));
}
// Is this a pure boolean value?
else if(sq_gettype(vm, idx) == OT_BOOL)
{
SQBool val = SQFalse;
// Attempt to get the value from the stack
sq_getbool(vm, idx, &val);
// Save it into the specified memory location
*num = static_cast< Uint64 >(val);
}
// Unrecognized value
else
{
return SQ_ERROR;
}
// Value retrieved
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
static SQRESULT SqModImpl_PushULongObject(HSQUIRRELVM vm, Uint64 num)
{
// Attempt to push the requested instance
try
{
Var< const ULongInt & >::push(vm, ULongInt(num));
}
catch (...)
{
// Specify that we failed
return SQ_ERROR;
}
// Specify that we succeeded
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
SQBool SqModImpl_ValidDate(uint16_t year, uint8_t month, uint8_t day)
{
return Chrono::ValidDate(year, month, day);
}
// ------------------------------------------------------------------------------------------------
SQBool SqModImpl_IsLeapYear(uint16_t year)
{
return Chrono::IsLeapYear(year);
}
// ------------------------------------------------------------------------------------------------
static SQRESULT SqModImpl_GetTimestamp(HSQUIRRELVM vm, SQInteger idx, Int64 * num)
{
// Validate the specified number pointer and value type
if (!num)
{
return SQ_ERROR; // Nowhere to save
}
// Is this an instance that we can treat as a Time-stamp type?
else if (sq_gettype(vm, idx) == OT_INSTANCE)
{
// Attempt to obtain the time-stamp and it's value from the stack
try
{
*num = static_cast< Int64 >(Var< const Timestamp & >(vm, idx).value.GetNum());
}
catch (...)
{
return SQ_ERROR; // Unable to obtain the value!
}
}
// Is this a pure integer value?
else if(sq_gettype(vm, idx) == OT_INTEGER)
{
SQInteger val = 0;
// Attempt to get the value from the stack
sq_getinteger(vm, idx, &val);
// Save it into the specified memory location
*num = static_cast< Int64 >(val);
}
// Is this a pure floating point value?
else if(sq_gettype(vm, idx) == OT_FLOAT)
{
SQFloat val = 0.0;
// Attempt to get the value from the stack
sq_getfloat(vm, idx, &val);
// Save it into the specified memory location
*num = static_cast< Int64 >(std::llround(val));
}
// Is this a pure boolean value?
else if(sq_gettype(vm, idx) == OT_BOOL)
{
SQBool val = SQFalse;
// Attempt to get the value from the stack
sq_getbool(vm, idx, &val);
// Save it into the specified memory location
*num = static_cast< Int64 >(val);
}
// Unrecognized value
else
{
return SQ_ERROR;
}
// Value retrieved
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
static SQRESULT SqModImpl_PushTimestamp(HSQUIRRELVM vm, Int64 num)
{
// Attempt to push the requested instance
try
{
Var< const Timestamp & >::push(vm, Timestamp(num));
}
catch (...)
{
// Specify that we failed
return SQ_ERROR;
}
// Specify that we succeeded
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
SQRESULT SqModImpl_GetDate(HSQUIRRELVM vm, SQInteger idx, uint16_t * year, uint8_t * month, uint8_t * day)
{
// Is this an instance that we can treat as a Date type?
if (sq_gettype(vm, idx) == OT_INSTANCE)
{
// Attempt to obtain the time-stamp and it's value from the stack
try
{
// Attempt to retrieve the instance
Var< Date * > var(vm, idx);
// Assign the year
if (year != nullptr)
{
*year = var.value->GetYear();
}
// Assign the month
if (month != nullptr)
{
*month = var.value->GetMonth();
}
// Assign the day
if (day != nullptr)
{
*day = var.value->GetDay();
}
}
catch (...)
{
return SQ_ERROR; // Unable to obtain the value!
}
}
// Unrecognized value
else
{
return SQ_ERROR;
}
// Value retrieved
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
SQRESULT SqModImpl_PushDate(HSQUIRRELVM vm, uint16_t year, uint8_t month, uint8_t day)
{
// Attempt to push the requested instance
try
{
Var< const Date & >::push(vm, Date(year, month, day));
}
catch (...)
{
// Specify that we failed
return SQ_ERROR;
}
// Specify that we succeeded
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
SQRESULT SqModImpl_GetTime(HSQUIRRELVM vm, SQInteger idx, uint8_t * hour, uint8_t * minute,
uint8_t * second, uint16_t * millisecond)
{
// Is this an instance that we can treat as a Time type?
if (sq_gettype(vm, idx) == OT_INSTANCE)
{
// Attempt to obtain the time-stamp and it's value from the stack
try
{
// Attempt to retrieve the instance
Var< Time * > var(vm, idx);
// Assign the hour
if (hour != nullptr)
{
*hour = var.value->GetHour();
}
// Assign the minute
if (minute != nullptr)
{
*minute = var.value->GetMinute();
}
// Assign the second
if (second != nullptr)
{
*second = var.value->GetSecond();
}
// Assign the millisecond
if (millisecond != nullptr)
{
*millisecond = var.value->GetMillisecond();
}
}
catch (...)
{
return SQ_ERROR; // Unable to obtain the value!
}
}
// Unrecognized value
else
{
return SQ_ERROR;
}
// Value retrieved
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
SQRESULT SqModImpl_PushTime(HSQUIRRELVM vm, uint8_t hour, uint8_t minute, uint8_t second,
uint16_t millisecond)
{
// Attempt to push the requested instance
try
{
Var< const Time & >::push(vm, Time(hour, minute, second, millisecond));
}
catch (...)
{
// Specify that we failed
return SQ_ERROR;
}
// Specify that we succeeded
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
SQRESULT SqModImpl_GetDatetime(HSQUIRRELVM vm, SQInteger idx, uint16_t * year, uint8_t * month, uint8_t * day,
uint8_t * hour, uint8_t * minute, uint8_t * second, uint16_t * millisecond)
{
// Is this an instance that we can treat as a Date-time type?
if (sq_gettype(vm, idx) == OT_INSTANCE)
{
// Attempt to obtain the time-stamp and it's value from the stack
try
{
// Attempt to retrieve the instance
Var< Datetime * > var(vm, idx);
// Assign the year
if (year != nullptr)
{
*year = var.value->GetYear();
}
// Assign the month
if (month != nullptr)
{
*month = var.value->GetMonth();
}
// Assign the day
if (day != nullptr)
{
*day = var.value->GetDay();
}
// Assign the hour
if (hour != nullptr)
{
*hour = var.value->GetHour();
}
// Assign the minute
if (minute != nullptr)
{
*minute = var.value->GetMinute();
}
// Assign the second
if (second != nullptr)
{
*second = var.value->GetSecond();
}
// Assign the millisecond
if (millisecond != nullptr)
{
*millisecond = var.value->GetMillisecond();
}
}
catch (...)
{
return SQ_ERROR; // Unable to obtain the value!
}
}
// Unrecognized value
else
{
return SQ_ERROR;
}
// Value retrieved
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
SQRESULT SqModImpl_PushDatetime(HSQUIRRELVM vm, uint16_t year, uint8_t month, uint8_t day,
uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond)
{
// Attempt to push the requested instance
try
{
Var< const Datetime & >::push(vm, Datetime(year, month, day, hour, minute, second, millisecond));
}
catch (...)
{
// Specify that we failed
return SQ_ERROR;
}
// Specify that we succeeded
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
SQRESULT SqModImpl_PushBuffer(HSQUIRRELVM vm, SQInteger size, SQInteger cursor)
{
// Attempt to push the requested instance
try
{
Var< const SqBuffer & >::push(vm, SqBuffer(size, cursor));
}
catch (...)
{
// Specify that we failed
return SQ_ERROR;
}
// Specify that we succeeded
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
SQRESULT SqModImpl_PushBufferData(HSQUIRRELVM vm, const char * data, SQInteger size, SQInteger cursor)
{
// Attempt to push the requested instance
try
{
Var< const SqBuffer & >::push(vm, SqBuffer(data, size, cursor));
}
catch (...)
{
// Specify that we failed
return SQ_ERROR;
}
// Specify that we succeeded
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
SQRESULT SqModImpl_GetBufferInfo(HSQUIRRELVM vm, SQInteger idx, const char ** ptr, SQInteger * size, SQInteger * cursor)
{
// Attempt to obtain the requested information
try
{
// Attempt to retrieve the instance
Var< SqBuffer * > var(vm, idx);
// Validate the obtained buffer
if (!(var.value) || !(var.value->GetRef()) || !(*var.value->GetRef()))
{
// Should we obtain the buffer contents?
if (ptr)
{
*ptr = nullptr; // Default to null data
}
// Should we obtain the buffer length?
if (size)
{
*size = 0; // Default to 0 length
}
// Should we obtain the cursor position?
if (cursor)
{
*cursor = 0; // Default to position 0
}
}
// Grab the internal buffer
const Buffer & b = *var.value->GetRef();
// Should we obtain the buffer contents?
if (ptr)
{
*ptr = b.Data();
}
// Should we obtain the buffer length?
if (size)
{
*size = ConvTo< SQInteger >::From(b.Capacity());
}
// Should we obtain the cursor position?
if (cursor)
{
*cursor = ConvTo< SQInteger >::From(b.Position());
}
}
catch (...)
{
// Specify that we failed
return SQ_ERROR;
}
// Specify that we succeeded
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
const char * SqModImpl_GetBufferData(HSQUIRRELVM vm, SQInteger idx)
{
// Attempt to obtain the requested information
try
{
// Attempt to retrieve the instance
Var< SqBuffer * > var(vm, idx);
// Validate the obtained buffer and return the requested information
if ((var.value) && (var.value->GetRef()) && (*var.value->GetRef()))
{
return var.value->GetRef()->Data();
}
}
catch (...)
{
// Just ignore it...
}
// Specify that we failed
return nullptr;
}
// ------------------------------------------------------------------------------------------------
SQInteger SqModImpl_GetBufferSize(HSQUIRRELVM vm, SQInteger idx)
{
// Attempt to obtain the requested information
try
{
// Attempt to retrieve the instance
Var< SqBuffer * > var(vm, idx);
// Validate the obtained buffer and return the requested information
if ((var.value) && (var.value->GetRef()) && (*var.value->GetRef()))
{
return ConvTo< SQInteger >::From(var.value->GetRef()->Capacity());
}
}
catch (...)
{
// Just ignore it...
}
// Specify that we failed
return -1;
}
// ------------------------------------------------------------------------------------------------
SQInteger SqModImpl_GetBufferCursor(HSQUIRRELVM vm, SQInteger idx)
{
// Attempt to obtain the requested information
try
{
// Attempt to retrieve the instance
Var< SqBuffer * > var(vm, idx);
// Validate the obtained buffer and return the requested information
if ((var.value) && (var.value->GetRef()) && (*var.value->GetRef()))
{
return ConvTo< SQInteger >::From(var.value->GetRef()->Position());
}
}
catch (...)
{
// Just ignore it...
}
// Specify that we failed
return -1;
}
// ------------------------------------------------------------------------------------------------
static int32_t SqExport_PopulateModuleAPI(HSQMODAPI api, size_t size)
{
@ -667,45 +67,6 @@ static int32_t SqExport_PopulateModuleAPI(HSQMODAPI api, size_t size)
//script loading
api->LoadScript = SqModImpl_LoadScript;
//numeric utilities
api->GetSLongValue = SqModImpl_GetSLongValue;
api->PushSLongObject = SqModImpl_PushSLongObject;
api->GetULongValue = SqModImpl_GetULongValue;
api->PushULongObject = SqModImpl_PushULongObject;
//time utilities
api->GetCurrentSysTime = Chrono::GetCurrentSysTime;
api->GetEpochTimeMicro = Chrono::GetEpochTimeMicro;
api->GetEpochTimeMilli = Chrono::GetEpochTimeMilli;
api->ValidDate = SqModImpl_ValidDate;
api->IsLeapYear = SqModImpl_IsLeapYear;
api->DaysInYear = Chrono::DaysInYear;
api->DaysInMonth = Chrono::DaysInMonth;
api->DayOfYear = Chrono::DayOfYear;
api->DateRangeToSeconds = Chrono::DateRangeToSeconds;
api->GetTimestamp = SqModImpl_GetTimestamp;
api->PushTimestamp = SqModImpl_PushTimestamp;
api->GetDate = SqModImpl_GetDate;
api->PushDate = SqModImpl_PushDate;
api->GetTime = SqModImpl_GetTime;
api->PushTime = SqModImpl_PushTime;
api->GetDatetime = SqModImpl_GetDatetime;
api->PushDatetime = SqModImpl_PushDatetime;
//stack utilities
api->PopStackInteger = PopStackInteger;
api->PopStackFloat = PopStackFloat;
api->PopStackSLong = PopStackSLong;
api->PopStackULong = PopStackULong;
//buffer utilities
api->PushBuffer = SqModImpl_PushBuffer;
api->PushBufferData = SqModImpl_PushBufferData;
api->GetBufferInfo = SqModImpl_GetBufferInfo;
api->GetBufferData = SqModImpl_GetBufferData;
api->GetBufferSize = SqModImpl_GetBufferSize;
api->GetBufferCursor = SqModImpl_GetBufferCursor;
return 1; // Successfully populated!
}