2024-05-04 20:51:05 +08:00
|
|
|
|
#include <Windows.h>
|
|
|
|
|
|
#include "SquirrelClassEx.h"
|
2024-05-04 22:04:36 +08:00
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef SQUNICODE
|
|
|
|
|
|
#define scfprintf fwprintf
|
|
|
|
|
|
#define scvprintf vfwprintf
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
|
|
#define scvprintf vfprintf
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#include <kiwano/kiwano.h>
|
|
|
|
|
|
using namespace kiwano;
|
|
|
|
|
|
#include <kiwano-audio/kiwano-audio.h>
|
|
|
|
|
|
using namespace kiwano::audio;
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-05-04 20:51:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//ԭ<><D4AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-05-04 22:04:36 +08:00
|
|
|
|
void printfunc(HSQUIRRELVM v, const SQChar* s, ...)
|
2024-05-04 20:51:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
va_list vl;
|
|
|
|
|
|
va_start(vl, s);
|
2024-05-04 22:04:36 +08:00
|
|
|
|
scvprintf(stdout, s, vl);
|
2024-05-04 20:51:05 +08:00
|
|
|
|
va_end(vl);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-04 22:04:36 +08:00
|
|
|
|
void errorfunc(HSQUIRRELVM v, const SQChar* s, ...)
|
2024-05-04 20:51:05 +08:00
|
|
|
|
{
|
|
|
|
|
|
va_list vl;
|
|
|
|
|
|
va_start(vl, s);
|
2024-05-04 22:04:36 +08:00
|
|
|
|
scvprintf(stderr, s, vl);
|
2024-05-04 20:51:05 +08:00
|
|
|
|
va_end(vl);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SQInteger SquirrelClassEx::ReloadingScript()
|
|
|
|
|
|
{
|
|
|
|
|
|
return SQInteger();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SQInteger SquirrelClassEx::Exit(HSQUIRRELVM v)
|
|
|
|
|
|
{
|
|
|
|
|
|
Application::GetInstance().Quit();
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><>ʼ<EFBFBD><CABC>
|
|
|
|
|
|
void SquirrelClassEx::Init()
|
|
|
|
|
|
{
|
|
|
|
|
|
v = sq_open(4096); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC>СΪ1024
|
|
|
|
|
|
sq_setprintfunc(v, printfunc, errorfunc);
|
|
|
|
|
|
|
|
|
|
|
|
sq_pushroottable(v);
|
|
|
|
|
|
|
|
|
|
|
|
sqstd_register_bloblib(v);
|
|
|
|
|
|
sqstd_register_iolib(v);
|
|
|
|
|
|
sqstd_register_systemlib(v);
|
|
|
|
|
|
sqstd_register_mathlib(v);
|
|
|
|
|
|
sqstd_register_stringlib(v);
|
|
|
|
|
|
sqstd_seterrorhandlers(v);
|
|
|
|
|
|
|
|
|
|
|
|
R_Register_Nut(v);
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE>Ϣ
|
|
|
|
|
|
scfprintf(stdout, _SC("%s %s (%d bits)\n"), SQUIRREL_VERSION, SQUIRREL_COPYRIGHT, (int)sizeof(SQInteger) * 8);
|
|
|
|
|
|
|
|
|
|
|
|
//<2F><>һ<EFBFBD>μ<EFBFBD><CEBC>ؽű<D8BD>
|
|
|
|
|
|
ReloadingScript();
|
2024-05-04 22:04:36 +08:00
|
|
|
|
|
|
|
|
|
|
sqstd_dofile(v, _SC("Script/Main.nut"), false, true);
|
2024-05-04 20:51:05 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SquirrelClassEx::RegisterNutApi(const SQChar* funcName, void* funcAddr, HSQUIRRELVM v)
|
|
|
|
|
|
{
|
|
|
|
|
|
sq_pushroottable(v);
|
|
|
|
|
|
sq_pushstring(v, funcName, -1);
|
|
|
|
|
|
sq_newclosure(v, (SQFUNCTION)funcAddr, 0);
|
|
|
|
|
|
sq_newslot(v, -3, false);
|
|
|
|
|
|
sq_poptop(v);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SquirrelClassEx::R_Register_Nut(HSQUIRRELVM v)
|
|
|
|
|
|
{
|
2024-05-04 22:04:36 +08:00
|
|
|
|
RegisterNutApi(_SC("sq_ReloadingScript"), ReloadingScript, v);
|
|
|
|
|
|
RegisterNutApi(_SC("sq_Exit"), Exit, v);
|
2024-05-04 20:51:05 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SquirrelClassEx::Run()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SquirrelClassEx::Close()
|
|
|
|
|
|
{
|
|
|
|
|
|
sq_close(v);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|