2016-02-27 10:57:10 +01:00
|
|
|
//
|
|
|
|
// SqModule: API used to communicate with and register squirrel modules
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
2016-06-03 20:26:19 +02:00
|
|
|
// Copyright (c) 2016 Sandu Liviu Catalin (aka. S.L.C)
|
2016-02-27 10:57:10 +01:00
|
|
|
//
|
|
|
|
// This software is provided 'as-is', without any express or implied
|
|
|
|
// warranty. In no event will the authors be held liable for any damages
|
|
|
|
// arising from the use of this software.
|
|
|
|
//
|
|
|
|
// Permission is granted to anyone to use this software for any purpose,
|
|
|
|
// including commercial applications, and to alter it and redistribute it
|
|
|
|
// freely, subject to the following restrictions:
|
|
|
|
//
|
|
|
|
// 1. The origin of this software must not be misrepresented; you must not
|
|
|
|
// claim that you wrote the original software. If you use this software
|
|
|
|
// in a product, an acknowledgment in the product documentation would be
|
|
|
|
// appreciated but is not required.
|
|
|
|
//
|
|
|
|
// 2. Altered source versions must be plainly marked as such, and must not be
|
|
|
|
// misrepresented as being the original software.
|
|
|
|
//
|
|
|
|
// 3. This notice may not be removed or altered from any source
|
|
|
|
// distribution.
|
|
|
|
//
|
|
|
|
|
|
|
|
#if !defined(_SQ_MOD_H_)
|
|
|
|
#define _SQ_MOD_H_
|
|
|
|
|
2016-03-27 19:49:57 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2016-02-27 10:57:10 +01:00
|
|
|
#include "SqAPI.h"
|
|
|
|
#include "vcmp.h"
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**< 64 bits integer types */
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
typedef __int64 SqInt64;
|
|
|
|
typedef unsigned __int64 SqUint64;
|
|
|
|
#else
|
|
|
|
typedef long long SqInt64;
|
|
|
|
typedef unsigned long long SqUint64;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#define SQMOD_API_EXPORT extern "C" __declspec(dllexport)
|
|
|
|
#elif defined(__GNUC__)
|
|
|
|
#define SQMOD_API_EXPORT extern "C"
|
|
|
|
#else
|
|
|
|
#define SQMOD_API_EXPORT extern "C"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define SQMOD_HOST_NAME "SqModHost"
|
|
|
|
#define SQMOD_INITIALIZE_CMD 0xDABBAD00
|
|
|
|
#define SQMOD_LOAD_CMD 0xDEADBABE
|
|
|
|
#define SQMOD_TERMINATE_CMD 0xDEADC0DE
|
|
|
|
#define SQMOD_API_VER 1
|
|
|
|
|
2016-03-10 04:57:13 +01:00
|
|
|
//primitive functions
|
2016-02-27 10:57:10 +01:00
|
|
|
typedef HSQAPI (*SqEx_GetSquirrelAPI) (void);
|
|
|
|
typedef HSQUIRRELVM (*SqEx_GetSquirrelVM) (void);
|
2016-03-10 04:57:13 +01:00
|
|
|
//logging utilities
|
2016-02-27 10:57:10 +01:00
|
|
|
typedef void (*SqEx_LogMessage) (const SQChar * fmt, ...);
|
2016-03-10 04:57:13 +01:00
|
|
|
//script loading
|
|
|
|
typedef SQRESULT (*SqEx_LoadScript) (const SQChar * filepath);
|
2016-06-05 03:16:42 +02:00
|
|
|
//numeric utilities
|
2016-02-27 10:57:10 +01:00
|
|
|
typedef SQRESULT (*SqEx_GetSLongValue) (HSQUIRRELVM vm, SQInteger idx, SqInt64 * num);
|
2016-06-04 21:33:34 +02:00
|
|
|
typedef SQRESULT (*SqEx_PushSLongObject) (HSQUIRRELVM vm, SqInt64 num);
|
2016-02-27 10:57:10 +01:00
|
|
|
typedef SQRESULT (*SqEx_GetULongValue) (HSQUIRRELVM vm, SQInteger idx, SqUint64 * num);
|
2016-06-04 21:33:34 +02:00
|
|
|
typedef SQRESULT (*SqEx_PushULongObject) (HSQUIRRELVM vm, SqUint64 num);
|
2016-03-10 04:57:13 +01:00
|
|
|
//time utilities
|
2016-02-27 10:57:10 +01:00
|
|
|
typedef SqInt64 (*SqEx_GetCurrentSysTime) (void);
|
|
|
|
typedef SqInt64 (*SqEx_GetEpochTimeMicro) (void);
|
|
|
|
typedef SqInt64 (*SqEx_GetEpochTimeMilli) (void);
|
|
|
|
typedef SQRESULT (*SqEx_GetTimestamp) (HSQUIRRELVM vm, SQInteger idx, SqInt64 * num);
|
2016-06-04 21:33:34 +02:00
|
|
|
typedef SQRESULT (*SqEx_PushTimestamp) (HSQUIRRELVM vm, SqInt64 num);
|
2016-06-04 22:10:35 +02:00
|
|
|
typedef SQRESULT (*SqEx_GetDate) (HSQUIRRELVM vm, SQInteger idx, uint16_t * year, uint8_t * month, uint8_t * day);
|
|
|
|
typedef SQRESULT (*SqEx_PushDate) (HSQUIRRELVM vm, uint16_t year, uint8_t month, uint8_t day);
|
|
|
|
typedef SQRESULT (*SqEx_GetTime) (HSQUIRRELVM vm, SQInteger idx, uint8_t * hour, uint8_t * minute, uint8_t * second, uint16_t * millisecond);
|
|
|
|
typedef SQRESULT (*SqEx_PushTime) (HSQUIRRELVM vm, uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond);
|
|
|
|
typedef SQRESULT (*SqEx_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 (*SqEx_PushDatetime) (HSQUIRRELVM vm, uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t minute, uint8_t second, uint16_t millisecond);
|
2016-06-03 20:26:19 +02:00
|
|
|
//stack utilities
|
|
|
|
typedef SQInteger (*SqEx_PopStackInteger) (HSQUIRRELVM vm, SQInteger idx);
|
|
|
|
typedef SQFloat (*SqEx_PopStackFloat) (HSQUIRRELVM vm, SQInteger idx);
|
|
|
|
typedef SqInt64 (*SqEx_PopStackSLong) (HSQUIRRELVM vm, SQInteger idx);
|
|
|
|
typedef SqUint64 (*SqEx_PopStackULong) (HSQUIRRELVM vm, SQInteger idx);
|
2016-02-27 10:57:10 +01:00
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-06-03 20:26:19 +02:00
|
|
|
* Allows modules to interface with the plug-in API without linking of any sorts
|
2016-02-27 10:57:10 +01:00
|
|
|
*/
|
|
|
|
typedef struct
|
|
|
|
{
|
2016-03-10 04:57:13 +01:00
|
|
|
unsigned int StructSize;
|
|
|
|
//primitive functions
|
2016-02-27 10:57:10 +01:00
|
|
|
SqEx_GetSquirrelAPI GetSquirrelAPI;
|
|
|
|
SqEx_GetSquirrelVM GetSquirrelVM;
|
2016-03-10 04:57:13 +01:00
|
|
|
//logging utilities
|
2016-02-27 10:57:10 +01:00
|
|
|
SqEx_LogMessage LogDbg;
|
|
|
|
SqEx_LogMessage LogUsr;
|
|
|
|
SqEx_LogMessage LogScs;
|
|
|
|
SqEx_LogMessage LogInf;
|
|
|
|
SqEx_LogMessage LogWrn;
|
|
|
|
SqEx_LogMessage LogErr;
|
|
|
|
SqEx_LogMessage LogFtl;
|
|
|
|
SqEx_LogMessage LogSDbg;
|
|
|
|
SqEx_LogMessage LogSUsr;
|
|
|
|
SqEx_LogMessage LogSScs;
|
|
|
|
SqEx_LogMessage LogSInf;
|
|
|
|
SqEx_LogMessage LogSWrn;
|
|
|
|
SqEx_LogMessage LogSErr;
|
|
|
|
SqEx_LogMessage LogSFtl;
|
2016-03-10 04:57:13 +01:00
|
|
|
//script loading
|
|
|
|
SqEx_LoadScript LoadScript;
|
2016-06-05 03:16:42 +02:00
|
|
|
//numeric utilities
|
2016-02-27 10:57:10 +01:00
|
|
|
SqEx_GetSLongValue GetSLongValue;
|
|
|
|
SqEx_PushSLongObject PushSLongObject;
|
|
|
|
SqEx_GetULongValue GetULongValue;
|
|
|
|
SqEx_PushULongObject PushULongObject;
|
2016-06-03 20:26:19 +02:00
|
|
|
//time utilities
|
2016-02-27 10:57:10 +01:00
|
|
|
SqEx_GetCurrentSysTime GetCurrentSysTime;
|
|
|
|
SqEx_GetEpochTimeMicro GetEpochTimeMicro;
|
|
|
|
SqEx_GetEpochTimeMilli GetEpochTimeMilli;
|
|
|
|
SqEx_GetTimestamp GetTimestamp;
|
|
|
|
SqEx_PushTimestamp PushTimestamp;
|
2016-06-04 21:33:34 +02:00
|
|
|
SqEx_GetDate GetDate;
|
|
|
|
SqEx_PushDate PushDate;
|
|
|
|
SqEx_GetTime GetTime;
|
|
|
|
SqEx_PushTime PushTime;
|
|
|
|
SqEx_GetDatetime GetDatetime;
|
|
|
|
SqEx_PushDatetime PushDatetime;
|
2016-06-03 20:26:19 +02:00
|
|
|
//stack utilities
|
|
|
|
SqEx_PopStackInteger PopStackInteger;
|
|
|
|
SqEx_PopStackFloat PopStackFloat;
|
|
|
|
SqEx_PopStackSLong PopStackSLong;
|
|
|
|
SqEx_PopStackULong PopStackULong;
|
2016-02-27 10:57:10 +01:00
|
|
|
} sq_exports, SQEXPORTS, *HSQEXPORTS;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
2016-06-03 20:26:19 +02:00
|
|
|
* Import the functions from the main squirrel plug-in.
|
2016-02-27 10:57:10 +01:00
|
|
|
*/
|
|
|
|
SQUIRREL_API HSQEXPORTS sq_api_import(PluginFuncs * vcapi);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Assign the functions from the specified API structure into the global functions.
|
|
|
|
*/
|
|
|
|
SQUIRREL_API SQRESULT sq_api_expand(HSQAPI sqapi);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------------------------------
|
|
|
|
* Undo changes done by sq_api_expand.
|
|
|
|
*/
|
|
|
|
SQUIRREL_API void sq_api_collapse();
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
} /*extern "C"*/
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /*_SQ_API_H_*/
|