1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-19 16:47:14 +02:00

Export functions to at least create shared buffers from modules.

This commit is contained in:
Sandu Liviu Catalin
2016-06-15 10:01:07 +03:00
parent 861c830bb7
commit 166760fd46
2 changed files with 47 additions and 0 deletions

View File

@ -1,5 +1,6 @@
// ------------------------------------------------------------------------------------------------
#include "Core.hpp"
#include "Base/Buffer.hpp"
// ------------------------------------------------------------------------------------------------
#include "Library/Numeric/LongInt.hpp"
@ -475,6 +476,42 @@ SQRESULT SqEx_PushDatetime(HSQUIRRELVM vm, uint16_t year, uint8_t month, uint8_t
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
SQRESULT SqEx_PushBuffer(HSQUIRRELVM vm, SQInteger size, SQInteger cursor)
{
// Attempt to push the requested instance
try
{
Var< const Buffer & >::push(vm, Buffer(ConvTo< Buffer::SzType >::From(size),
ConvTo< Buffer::SzType >::From(cursor)));
}
catch (...)
{
// Specify that we failed
return SQ_ERROR;
}
// Specify that we succeeded
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
SQRESULT SqEx_PushBufferData(HSQUIRRELVM vm, const char * data, SQInteger size, SQInteger cursor)
{
// Attempt to push the requested instance
try
{
Var< const Buffer & >::push(vm, Buffer(data, ConvTo< Buffer::SzType >::From(size),
ConvTo< Buffer::SzType >::From(cursor)));
}
catch (...)
{
// Specify that we failed
return SQ_ERROR;
}
// Specify that we succeeded
return SQ_OK;
}
// ------------------------------------------------------------------------------------------------
void InitExports()
{
@ -529,6 +566,10 @@ void InitExports()
g_SqExports.PopStackSLong = PopStackSLong;
g_SqExports.PopStackULong = PopStackULong;
//buffer utilities
g_SqExports.PushBuffer = SqEx_PushBuffer;
g_SqExports.PushBufferData = SqEx_PushBufferData;
// Export them to the server
_Func->ExportFunctions(_Info->pluginId,
const_cast< const void ** >(reinterpret_cast< void ** >(&sqexports)),