Modified project structure:
- renamed sqmodule_api.h/.cpp to module_api - moved defines for sq_* functions into squirrel_api.h - renamed SqModule::inti to SQModule::Init - moved all of the files to "api" subfolder
This commit is contained in:
@@ -5,8 +5,9 @@ project(SqModule)
|
|||||||
file(GLOB_RECURSE SRC
|
file(GLOB_RECURSE SRC
|
||||||
"dependencies/squirrel/include/*.h"
|
"dependencies/squirrel/include/*.h"
|
||||||
"dependencies/sqrat/include/*.h"
|
"dependencies/sqrat/include/*.h"
|
||||||
"src/sqmodule_api.h"
|
"src/api/squirrel_api.h"
|
||||||
"src/sqmodule_api.cpp"
|
"src/api/module_api.h"
|
||||||
|
"src/api/module_api.cpp"
|
||||||
"src/pch.h"
|
"src/pch.h"
|
||||||
"src/sqmain.cpp"
|
"src/sqmain.cpp"
|
||||||
)
|
)
|
||||||
|
|||||||
22
src/api/module_api.cpp
Normal file
22
src/api/module_api.cpp
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#include "pch.h"
|
||||||
|
|
||||||
|
namespace SqModule
|
||||||
|
{
|
||||||
|
HSQUIRRELVM vm;
|
||||||
|
HSQAPI api;
|
||||||
|
|
||||||
|
void Initialize(HSQUIRRELVM vm, HSQAPI api) {
|
||||||
|
SqModule::vm = vm;
|
||||||
|
SqModule::api = api;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Print(const SQChar* msg) {
|
||||||
|
const SQPRINTFUNCTION print = sq_getprintfunc(vm);
|
||||||
|
print(vm, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Error(const SQChar* msg) {
|
||||||
|
const SQPRINTFUNCTION error = sq_geterrorfunc(vm);
|
||||||
|
error(vm, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/api/module_api.h
Normal file
16
src/api/module_api.h
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
#ifndef _MODULE_API_H
|
||||||
|
#define _MODULE_API_H
|
||||||
|
|
||||||
|
#include <sqmodule.h>
|
||||||
|
|
||||||
|
namespace SqModule
|
||||||
|
{
|
||||||
|
extern HSQUIRRELVM vm;
|
||||||
|
extern HSQAPI api;
|
||||||
|
|
||||||
|
void Initalize(HSQUIRRELVM vm, HSQAPI api);
|
||||||
|
void Print(const SQChar* msg);
|
||||||
|
void Error(const SQChar* msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,18 +1,5 @@
|
|||||||
#ifndef _SQAPI_H
|
#ifndef _SQUIRREL_API_H
|
||||||
#define _SQAPI_H
|
#define _SQUIRREL_API_H
|
||||||
|
|
||||||
#include <sqmodule.h>
|
|
||||||
|
|
||||||
namespace SqModule
|
|
||||||
{
|
|
||||||
extern HSQUIRRELVM vm;
|
|
||||||
extern HSQAPI api;
|
|
||||||
|
|
||||||
extern SQPRINTFUNCTION print;
|
|
||||||
extern SQPRINTFUNCTION error;
|
|
||||||
|
|
||||||
void init(HSQUIRRELVM vm, HSQAPI api);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*vm*/
|
/*vm*/
|
||||||
#define sq_open SqModule::api->open
|
#define sq_open SqModule::api->open
|
||||||
@@ -3,5 +3,6 @@
|
|||||||
|
|
||||||
#define SCRAT_EXPORT // Used to get SQRAT_API macro for sqmodule_load func (export function)
|
#define SCRAT_EXPORT // Used to get SQRAT_API macro for sqmodule_load func (export function)
|
||||||
|
|
||||||
#include "sqmodule_api.h"
|
#include "api/squirrel_api.h"
|
||||||
|
#include "api/module_api.h"
|
||||||
#include "sqrat.h"
|
#include "sqrat.h"
|
||||||
|
|||||||
@@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
extern "C" SQRESULT SQRAT_API sqmodule_load(HSQUIRRELVM vm, HSQAPI api)
|
extern "C" SQRESULT SQRAT_API sqmodule_load(HSQUIRRELVM vm, HSQAPI api)
|
||||||
{
|
{
|
||||||
SqModule::init(vm, api);
|
SqModule::Initalize(vm, api);
|
||||||
|
Sqrat::DefaultVM::Set(vm);
|
||||||
|
|
||||||
return SQ_OK;
|
return SQ_OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
#include "pch.h"
|
|
||||||
|
|
||||||
namespace SqModule
|
|
||||||
{
|
|
||||||
HSQUIRRELVM vm;
|
|
||||||
HSQAPI api;
|
|
||||||
|
|
||||||
SQPRINTFUNCTION print;
|
|
||||||
SQPRINTFUNCTION error;
|
|
||||||
|
|
||||||
void init(HSQUIRRELVM vm, HSQAPI api)
|
|
||||||
{
|
|
||||||
SqModule::vm = vm;
|
|
||||||
SqModule::api = api;
|
|
||||||
|
|
||||||
SqModule::print = sq_getprintfunc(vm);
|
|
||||||
SqModule::error = sq_geterrorfunc(vm);
|
|
||||||
|
|
||||||
Sqrat::DefaultVM::Set(vm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user