project64/Source/Project64/UserInterface/Debugger/ScriptInstance.h

63 lines
1.8 KiB
C
Raw Normal View History

#include "ScriptTypes.h"
#include "ScriptSystem.h"
#include "ScriptWorker.h"
2017-08-18 05:08:22 +00:00
#pragma once
2017-08-18 05:08:22 +00:00
class CScriptInstance
{
private:
JSInstanceName m_InstanceName;
CScriptSystem* m_System;
duk_context* m_Ctx;
size_t m_RefCount;
uint64_t m_ExecTimeout;
uint64_t m_ExecStartTime;
std::ifstream m_SourceFile;
char* m_SourceCode;
JSAppCallbackID m_CurExecCallbackId;
std::vector<CScriptWorker*> m_Workers;
bool m_bStopping;
2017-08-18 05:08:22 +00:00
public:
CScriptInstance(CScriptSystem* sys, const char* name);
2017-09-13 10:36:03 +00:00
~CScriptInstance();
2017-08-18 05:08:22 +00:00
JSInstanceName& Name();
CScriptSystem* System();
CDebuggerUI* Debugger();
JSAppCallbackID CallbackId();
bool Run(const char* path);
void SetExecTimeout(uint64_t timeout);
bool IsTimedOut();
2017-09-13 10:36:03 +00:00
size_t GetRefCount();
void IncRefCount();
void DecRefCount();
void SetStopping(bool bStopping);
bool IsStopping();
2017-09-13 10:36:03 +00:00
bool RegisterWorker(CScriptWorker* worker);
void UnregisterWorker(CScriptWorker* worker);
void StopRegisteredWorkers();
2017-09-13 10:36:03 +00:00
void RawInvokeAppCallback(JSAppCallback& cb, void *_hookEnv);
2017-09-13 10:36:03 +00:00
void RawConsoleInput(const char* code);
2017-09-13 10:36:03 +00:00
void RawCall(void* dukFuncHeapPtr, JSDukArgSetupFunc argSetupFunc, void* param = nullptr);
2017-09-13 10:36:03 +00:00
void RawCMethodCall(void* dukThisHeapPtr, duk_c_function func,
JSDukArgSetupFunc argSetupFunc = nullptr,
void* argSetupParam = nullptr);
2017-09-13 10:36:03 +00:00
void PostCMethodCall(void* dukThisHeapPtr, duk_c_function func,
JSDukArgSetupFunc argSetupFunc = nullptr,
void* argSetupParam = nullptr, size_t argSetupParamSize = 0);
2017-09-13 10:36:03 +00:00
private:
static uint64_t Timestamp();
void Cleanup();
};