2017-08-30 18:31:27 -04:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "ScriptingContext.h"
|
2018-09-02 15:37:13 -04:00
|
|
|
#include "../Utilities/Timer.h"
|
2017-08-30 18:31:27 -04:00
|
|
|
|
|
|
|
struct lua_State;
|
2018-09-02 15:37:13 -04:00
|
|
|
struct lua_Debug;
|
2017-08-30 18:31:27 -04:00
|
|
|
class Debugger;
|
|
|
|
|
|
|
|
class LuaScriptingContext : public ScriptingContext
|
|
|
|
{
|
|
|
|
private:
|
2018-09-02 15:37:13 -04:00
|
|
|
static LuaScriptingContext* _context;
|
|
|
|
static uint32_t _timeout;
|
2017-08-30 18:31:27 -04:00
|
|
|
lua_State* _lua = nullptr;
|
2018-09-02 15:37:13 -04:00
|
|
|
Timer _timer;
|
|
|
|
|
|
|
|
static void ExecutionCountHook(lua_State* lua, lua_Debug* ar);
|
2017-08-30 18:31:27 -04:00
|
|
|
|
2017-10-05 19:44:37 -04:00
|
|
|
protected:
|
2017-11-20 19:15:17 -05:00
|
|
|
void InternalCallMemoryCallback(uint16_t addr, uint8_t &value, CallbackType type) override;
|
|
|
|
int InternalCallEventCallback(EventType type) override;
|
2017-10-05 19:44:37 -04:00
|
|
|
|
2017-08-30 18:31:27 -04:00
|
|
|
public:
|
2018-07-01 15:21:05 -04:00
|
|
|
LuaScriptingContext(Debugger* debugger);
|
2018-06-11 19:07:05 -04:00
|
|
|
virtual ~LuaScriptingContext();
|
2017-08-30 18:31:27 -04:00
|
|
|
|
2018-09-02 15:37:13 -04:00
|
|
|
static void SetScriptTimeout(uint32_t timeout);
|
|
|
|
|
2017-11-20 19:15:17 -05:00
|
|
|
bool LoadScript(string scriptName, string scriptContent, Debugger* debugger) override;
|
2017-10-07 19:48:45 -04:00
|
|
|
|
|
|
|
void UnregisterMemoryCallback(CallbackType type, int startAddr, int endAddr, int reference) override;
|
|
|
|
void UnregisterEventCallback(EventType type, int reference) override;
|
2017-08-30 18:31:27 -04:00
|
|
|
};
|