Modernize engine2.* style.
This commit is contained in:
parent
0100ebadb9
commit
10d778e344
@ -1,4 +1,15 @@
|
|||||||
// vim: set ts=4 sw=4 tw=99 noet:
|
// vim: set sts=2 ts=8 sw=2 tw=99 noet:
|
||||||
|
//
|
||||||
|
// Copyright (C) 2006-2015 AlliedModders LLC
|
||||||
|
//
|
||||||
|
// This file is part of SourcePawn. SourcePawn is free software: you can
|
||||||
|
// redistribute it and/or modify it under the terms of the GNU General Public
|
||||||
|
// License as published by the Free Software Foundation, either version 3 of
|
||||||
|
// the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along with
|
||||||
|
// SourcePawn. If not, see http://www.gnu.org/licenses/.
|
||||||
|
//
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -18,7 +29,8 @@ SourcePawnEngine2::SourcePawnEngine2()
|
|||||||
jit_enabled_ = true;
|
jit_enabled_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file, int *err)
|
IPluginRuntime *
|
||||||
|
SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file, int *err)
|
||||||
{
|
{
|
||||||
sp_file_hdr_t hdr;
|
sp_file_hdr_t hdr;
|
||||||
uint8_t *base;
|
uint8_t *base;
|
||||||
@ -29,8 +41,7 @@ IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file
|
|||||||
|
|
||||||
FILE *fp = fopen(file, "rb");
|
FILE *fp = fopen(file, "rb");
|
||||||
|
|
||||||
if (!fp)
|
if (!fp) {
|
||||||
{
|
|
||||||
error = SP_ERROR_NOT_FOUND;
|
error = SP_ERROR_NOT_FOUND;
|
||||||
goto return_error;
|
goto return_error;
|
||||||
}
|
}
|
||||||
@ -38,8 +49,7 @@ IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file
|
|||||||
/* Rewind for safety */
|
/* Rewind for safety */
|
||||||
ignore = fread(&hdr, sizeof(sp_file_hdr_t), 1, fp);
|
ignore = fread(&hdr, sizeof(sp_file_hdr_t), 1, fp);
|
||||||
|
|
||||||
if (hdr.magic != SmxConsts::FILE_MAGIC)
|
if (hdr.magic != SmxConsts::FILE_MAGIC) {
|
||||||
{
|
|
||||||
error = SP_ERROR_FILE_FORMAT;
|
error = SP_ERROR_FILE_FORMAT;
|
||||||
goto return_error;
|
goto return_error;
|
||||||
}
|
}
|
||||||
@ -93,8 +103,7 @@ IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file
|
|||||||
}
|
}
|
||||||
|
|
||||||
pRuntime = new BaseRuntime();
|
pRuntime = new BaseRuntime();
|
||||||
if ((error = pRuntime->CreateFromMemory(&hdr, base)) != SP_ERROR_NONE)
|
if ((error = pRuntime->CreateFromMemory(&hdr, base)) != SP_ERROR_NONE) {
|
||||||
{
|
|
||||||
delete pRuntime;
|
delete pRuntime;
|
||||||
goto return_error;
|
goto return_error;
|
||||||
}
|
}
|
||||||
@ -118,9 +127,7 @@ IPluginRuntime *SourcePawnEngine2::LoadPlugin(ICompilation *co, const char *file
|
|||||||
(void)ignore;
|
(void)ignore;
|
||||||
|
|
||||||
if (!pRuntime->plugin()->name)
|
if (!pRuntime->plugin()->name)
|
||||||
{
|
|
||||||
pRuntime->SetName(file);
|
pRuntime->SetName(file);
|
||||||
}
|
|
||||||
|
|
||||||
pRuntime->ApplyCompilationOptions(co);
|
pRuntime->ApplyCompilationOptions(co);
|
||||||
|
|
||||||
@ -138,65 +145,74 @@ return_error:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SPVM_NATIVE_FUNC SourcePawnEngine2::CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData)
|
SPVM_NATIVE_FUNC
|
||||||
|
SourcePawnEngine2::CreateFakeNative(SPVM_FAKENATIVE_FUNC callback, void *pData)
|
||||||
{
|
{
|
||||||
return g_Jit.CreateFakeNative(callback, pData);
|
return g_Jit.CreateFakeNative(callback, pData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourcePawnEngine2::DestroyFakeNative(SPVM_NATIVE_FUNC func)
|
void
|
||||||
|
SourcePawnEngine2::DestroyFakeNative(SPVM_NATIVE_FUNC func)
|
||||||
{
|
{
|
||||||
g_Jit.DestroyFakeNative(func);
|
g_Jit.DestroyFakeNative(func);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SourcePawnEngine2::GetEngineName()
|
const char *
|
||||||
|
SourcePawnEngine2::GetEngineName()
|
||||||
{
|
{
|
||||||
return "SourcePawn 1.7, jit-x86";
|
return "SourcePawn 1.7, jit-x86";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SourcePawnEngine2::GetVersionString()
|
const char *
|
||||||
|
SourcePawnEngine2::GetVersionString()
|
||||||
{
|
{
|
||||||
return SOURCEMOD_VERSION;
|
return SOURCEMOD_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
IDebugListener *SourcePawnEngine2::SetDebugListener(IDebugListener *listener)
|
IDebugListener *
|
||||||
|
SourcePawnEngine2::SetDebugListener(IDebugListener *listener)
|
||||||
{
|
{
|
||||||
return g_engine1.SetDebugListener(listener);
|
return g_engine1.SetDebugListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int SourcePawnEngine2::GetAPIVersion()
|
unsigned int
|
||||||
|
SourcePawnEngine2::GetAPIVersion()
|
||||||
{
|
{
|
||||||
return SOURCEPAWN_ENGINE2_API_VERSION;
|
return SOURCEPAWN_ENGINE2_API_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
ICompilation *SourcePawnEngine2::StartCompilation()
|
ICompilation *
|
||||||
|
SourcePawnEngine2::StartCompilation()
|
||||||
{
|
{
|
||||||
return g_Jit.StartCompilation();
|
return g_Jit.StartCompilation();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SourcePawnEngine2::GetErrorString(int err)
|
const char *
|
||||||
|
SourcePawnEngine2::GetErrorString(int err)
|
||||||
{
|
{
|
||||||
return g_engine1.GetErrorString(err);
|
return g_engine1.GetErrorString(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SourcePawnEngine2::Initialize()
|
bool
|
||||||
|
SourcePawnEngine2::Initialize()
|
||||||
{
|
{
|
||||||
return g_Jit.InitializeJIT();
|
return g_Jit.InitializeJIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SourcePawnEngine2::Shutdown()
|
void
|
||||||
|
SourcePawnEngine2::Shutdown()
|
||||||
{
|
{
|
||||||
g_WatchdogTimer.Shutdown();
|
g_WatchdogTimer.Shutdown();
|
||||||
g_Jit.ShutdownJIT();
|
g_Jit.ShutdownJIT();
|
||||||
}
|
}
|
||||||
|
|
||||||
IPluginRuntime *SourcePawnEngine2::CreateEmptyRuntime(const char *name, uint32_t memory)
|
IPluginRuntime *
|
||||||
|
SourcePawnEngine2::CreateEmptyRuntime(const char *name, uint32_t memory)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
BaseRuntime *rt;
|
|
||||||
|
|
||||||
rt = new BaseRuntime();
|
BaseRuntime *rt = new BaseRuntime();
|
||||||
if ((err = rt->CreateBlank(memory)) != SP_ERROR_NONE)
|
if ((err = rt->CreateBlank(memory)) != SP_ERROR_NONE) {
|
||||||
{
|
|
||||||
delete rt;
|
delete rt;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -208,7 +224,8 @@ IPluginRuntime *SourcePawnEngine2::CreateEmptyRuntime(const char *name, uint32_t
|
|||||||
return rt;
|
return rt;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SourcePawnEngine2::InstallWatchdogTimer(size_t timeout_ms)
|
bool
|
||||||
|
SourcePawnEngine2::InstallWatchdogTimer(size_t timeout_ms)
|
||||||
{
|
{
|
||||||
return g_WatchdogTimer.Initialize(timeout_ms);
|
return g_WatchdogTimer.Initialize(timeout_ms);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,22 @@
|
|||||||
// vim: set ts=4 sw=4 tw=99 noet:
|
// vim: set sts=2 ts=8 sw=2 tw=99 noet:
|
||||||
|
//
|
||||||
|
// Copyright (C) 2006-2015 AlliedModders LLC
|
||||||
|
//
|
||||||
|
// This file is part of SourcePawn. SourcePawn is free software: you can
|
||||||
|
// redistribute it and/or modify it under the terms of the GNU General Public
|
||||||
|
// License as published by the Free Software Foundation, either version 3 of
|
||||||
|
// the License, or (at your option) any later version.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License along with
|
||||||
|
// SourcePawn. If not, see http://www.gnu.org/licenses/.
|
||||||
|
//
|
||||||
#ifndef _INCLUDE_SOURCEPAWN_ENGINE_2_H_
|
#ifndef _INCLUDE_SOURCEPAWN_ENGINE_2_H_
|
||||||
#define _INCLUDE_SOURCEPAWN_ENGINE_2_H_
|
#define _INCLUDE_SOURCEPAWN_ENGINE_2_H_
|
||||||
|
|
||||||
#include <sp_vm_api.h>
|
#include <sp_vm_api.h>
|
||||||
|
|
||||||
namespace SourcePawn
|
namespace SourcePawn {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* @brief Outlines the interface a Virtual Machine (JIT) must expose
|
* @brief Outlines the interface a Virtual Machine (JIT) must expose
|
||||||
*/
|
*/
|
||||||
@ -13,6 +24,7 @@ namespace SourcePawn
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SourcePawnEngine2();
|
SourcePawnEngine2();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
unsigned int GetAPIVersion();
|
unsigned int GetAPIVersion();
|
||||||
const char *GetEngineName();
|
const char *GetEngineName();
|
||||||
@ -58,12 +70,14 @@ namespace SourcePawn
|
|||||||
IProfilingTool *GetProfiler() {
|
IProfilingTool *GetProfiler() {
|
||||||
return profiler_;
|
return profiler_;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IProfilingTool *profiler_;
|
IProfilingTool *profiler_;
|
||||||
bool jit_enabled_;
|
bool jit_enabled_;
|
||||||
bool profiling_enabled_;
|
bool profiling_enabled_;
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
} // namespace SourcePawn
|
||||||
|
|
||||||
extern SourcePawn::SourcePawnEngine2 g_engine2;
|
extern SourcePawn::SourcePawnEngine2 g_engine2;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user