From fa16e054a549deea65bf66b5a2e4c04e7c91e899 Mon Sep 17 00:00:00 2001 From: Melchior Date: Tue, 18 Dec 2012 10:38:00 +0100 Subject: [PATCH 1/2] Add a default Win32 implmentation for OsSleep --- source/tilde/HostConfig.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/tilde/HostConfig.cpp b/source/tilde/HostConfig.cpp index 2bbfc2c..a9d164f 100644 --- a/source/tilde/HostConfig.cpp +++ b/source/tilde/HostConfig.cpp @@ -98,4 +98,11 @@ namespace tilde printf(s_printBuffer); #endif // defined(WIN32) } + + void OsSleep(unsigned int millisecs) + { +#ifdef WIN32 + Sleep(millisecs); +#endif + } } From 59d3bc8e55f3f85e01d2aef638bba5ac98a8113e Mon Sep 17 00:00:00 2001 From: Melchior Date: Tue, 18 Dec 2012 10:43:37 +0100 Subject: [PATCH 2/2] Fix the Win32 example * Use OutputDebugString instead of OutputDebugStr * Use the new tilde::LuaDebuggerComms and tilde::LuaDebuggerHost interfaces --- examples/WindowsDemo/LuaHostWindows.cpp | 16 ++++++++-------- examples/WindowsDemo/LuaHostWindows.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/WindowsDemo/LuaHostWindows.cpp b/examples/WindowsDemo/LuaHostWindows.cpp index 50a2564..ac2fae3 100644 --- a/examples/WindowsDemo/LuaHostWindows.cpp +++ b/examples/WindowsDemo/LuaHostWindows.cpp @@ -57,7 +57,7 @@ void print(const char * format, ...) vsnprintf(s_printBuffer, 1024, format, ap); va_end(ap); - OutputDebugStr(s_printBuffer); + OutputDebugString(s_printBuffer); printf(s_printBuffer); } @@ -71,7 +71,7 @@ void warn(const char * format, ...) vsnprintf(s_printBuffer, 1024, format, ap); va_end(ap); - OutputDebugStr(s_printBuffer); + OutputDebugString(s_printBuffer); printf(s_printBuffer); print("\n"); @@ -87,7 +87,7 @@ void error(const char * format, ...) vsnprintf(s_printBuffer, 1024, format, ap); va_end(ap); - OutputDebugStr(s_printBuffer); + OutputDebugString(s_printBuffer); printf(s_printBuffer); print("\n"); @@ -104,7 +104,7 @@ LuaHostWindows::LuaHostWindows(int port) m_debuggerSocket(SOCKET_ERROR) { m_machine = new LuaMachine(); - m_debuggerComms = new tilde::LuaDebuggerComms(m_machine->GetLVM(), this); + m_debuggerComms = new tilde::LuaDebuggerComms(this); m_netBufferSize = 4096; m_netBuffer = new tilde::u8[m_netBufferSize]; @@ -246,15 +246,15 @@ void LuaHostWindows::CloseDebuggerConnection() Close(); } -bool LuaHostWindows::AttachLuaHook( lua_Hook hook, int mask, int count ) +bool LuaHostWindows::AttachLuaHook(lua_State *L, lua_Hook hook, int mask, int count ) { - lua_sethook(m_debuggerComms->GetMainLVM(), hook, mask, count); + lua_sethook(L, hook, mask, count); return true; } -void LuaHostWindows::DetachLuaHook( lua_Hook hook ) +void LuaHostWindows::DetachLuaHook(lua_State *L, lua_Hook hook ) { - lua_sethook(m_debuggerComms->GetMainLVM(), NULL, 0, 0); + lua_sethook(L, NULL, 0, 0); } void LuaHostWindows::AttachPrintfHook( void (* hook)(const char *) ) diff --git a/examples/WindowsDemo/LuaHostWindows.h b/examples/WindowsDemo/LuaHostWindows.h index 371695c..56a5e5a 100644 --- a/examples/WindowsDemo/LuaHostWindows.h +++ b/examples/WindowsDemo/LuaHostWindows.h @@ -58,8 +58,8 @@ class LuaHostWindows : public tilde::LuaDebuggerHost virtual void SendDebuggerData(const void * data, int size); virtual void CloseDebuggerConnection(); - virtual bool AttachLuaHook(lua_Hook hook, int mask, int count); - virtual void DetachLuaHook(lua_Hook hook); + virtual bool AttachLuaHook(lua_State *L, lua_Hook hook, int mask, int count); + virtual void DetachLuaHook(lua_State *L, lua_Hook hook); virtual void AttachPrintfHook( void (* hook)(const char *) ); virtual void DetachPrintfHook( void (* hook)(const char *) ); virtual void ReceiveExCommand(const char * command, int datalen, tilde::ReceiveMessageBuffer * data);