From 2fe2286df8f790ef75702a517c1751972da364c5 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 23 Oct 2021 15:15:08 +0200 Subject: [PATCH] Fixes for Windows. --- CMakeLists.txt | 3 ++- TestRunner/Runner.cpp | 6 ++++-- src/ASVariableFormatter.cpp | 4 ++-- src/AngelscriptDebugger.cpp | 2 +- src/DebugAdapterProtocol/Events.hpp | 2 +- src/DebugAdapterProtocol/Types.hpp | 18 ++++++++++-------- 6 files changed, 20 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc5f567..c20cb01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,8 +57,9 @@ if (WINDOWS) add_compile_options(-m64) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-allow-multiple-definition") if (SHARED) - set_target_properties(pkmnLib PROPERTIES SUFFIX ".dll") + set_target_properties(AngelscriptDebugger PROPERTIES SUFFIX ".dll") endif(SHARED) + set(_LINKS ${_LINKS} -Wl,-Bstatic -lws2_32 -Wl,-Bdynamic) endif (WINDOWS) if (STATICC) diff --git a/TestRunner/Runner.cpp b/TestRunner/Runner.cpp index 0a44425..5736c1a 100644 --- a/TestRunner/Runner.cpp +++ b/TestRunner/Runner.cpp @@ -4,6 +4,8 @@ #include "angelscript_addons/scriptbuilder/scriptbuilder.h" #include "angelscript_addons/scripthelper/scripthelper.h" #include "angelscript_addons/scriptstdstring/scriptstdstring.h" +#include +#include static void print(const std::string& s) { std::cout << s << std::endl; } @@ -22,7 +24,7 @@ int main() { std::cout << "Waiting for debugger to attach." << std::endl; while (!debugger.HasDebuggerAttached()) { - usleep(1000); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } std::cout << "Debugger attached." << std::endl; @@ -84,7 +86,7 @@ class TestClass { ctx->Execute(); while (ctx->GetState() != asEXECUTION_FINISHED && ctx->GetState() != asEXECUTION_EXCEPTION && ctx->GetState() != asEXECUTION_ABORTED && ctx->GetState() != asEXECUTION_ERROR) { - usleep(1000); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); } ctx->Release(); diff --git a/src/ASVariableFormatter.cpp b/src/ASVariableFormatter.cpp index b50f289..07e9d54 100644 --- a/src/ASVariableFormatter.cpp +++ b/src/ASVariableFormatter.cpp @@ -233,11 +233,11 @@ void ASVariableFormatter::GetChildDAPVariables(std::vectorSetObject(address); ctx->Execute(); if (t == asTYPEID_UINT64) { - FormatArrayLike( + FormatArrayLike( vars, engine, ctx, address, debugger, indexFunc); } else if (t == asTYPEID_INT32){ - FormatArrayLike( + FormatArrayLike( vars, engine, ctx, address, debugger, indexFunc); } } diff --git a/src/AngelscriptDebugger.cpp b/src/AngelscriptDebugger.cpp index d634489..e073345 100644 --- a/src/AngelscriptDebugger.cpp +++ b/src/AngelscriptDebugger.cpp @@ -321,7 +321,7 @@ void AngelscriptDebugger::OnRequest(asio::ip::tcp::socket* client, DebugAdapterP auto response = new DebugAdapterProtocol::VariablesResponse(msg->seq); auto variables = std::vector(); auto reference = t->arguments.value()->variablesReference - 1; - if (reference >= _storedVariableReferences.size() || reference < 0) + if (reference >= _storedVariableReferences.size()) return; auto& variant = _storedVariableReferences[reference]; diff --git a/src/DebugAdapterProtocol/Events.hpp b/src/DebugAdapterProtocol/Events.hpp index e727988..ea0b0c7 100644 --- a/src/DebugAdapterProtocol/Events.hpp +++ b/src/DebugAdapterProtocol/Events.hpp @@ -189,7 +189,7 @@ namespace DebugAdapterProtocol { std::optional> hitBreakpointIds; explicit StoppedEventBody(std::string reason, size_t breakpoint) - : reason(std::move(reason)), hitBreakpointIds({breakpoint}) {} + : reason(std::move(reason)), hitBreakpointIds(std::vector({breakpoint})) {} explicit StoppedEventBody(std::string reason, std::string description, std::string text) : reason(std::move(reason)), description(std::move(description)), text(std::move(text)) {} diff --git a/src/DebugAdapterProtocol/Types.hpp b/src/DebugAdapterProtocol/Types.hpp index 2bbe245..3884d5b 100644 --- a/src/DebugAdapterProtocol/Types.hpp +++ b/src/DebugAdapterProtocol/Types.hpp @@ -248,20 +248,22 @@ namespace DebugAdapterProtocol { presentationHint(presentationHint) {} static Variable FromString(std::string name, std::string value) { - return Variable( - name, value, "string", - VariablePresentationHint{.kind = "data", .attributes = std::vector{"rawString"}}); + return Variable(name, value, "string", + VariablePresentationHint{ + .kind = "data", .attributes = std::vector{"rawString"}, .visibility = {}}); } static Variable FromNull(std::string name, std::string type) { - return Variable(name, "null", type, - VariablePresentationHint{.kind = "data", .attributes = std::vector{}}); + return Variable( + name, "null", type, + VariablePresentationHint{.kind = "data", .attributes = std::vector{}, .visibility = {}}); } static Variable FromPointer(std::string name, std::string type, std::string display, size_t variableReference) { - auto v = Variable( - std::move(name), std::move(display), type, - VariablePresentationHint{.kind = "class", .attributes = std::vector{"hasObjectId"}}); + auto v = + Variable(std::move(name), std::move(display), type, + VariablePresentationHint{ + .kind = "class", .attributes = std::vector{"hasObjectId"}, .visibility = {}}); v.variablesReference = variableReference; return v; }