mirror of
https://github.com/momo5502/emulator.git
synced 2026-01-22 05:03:56 +00:00
Add nlohmann json
This commit is contained in:
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -18,3 +18,7 @@
|
||||
[submodule "deps/gtest-parallel"]
|
||||
path = deps/gtest-parallel
|
||||
url = https://github.com/google/gtest-parallel.git
|
||||
[submodule "deps/json"]
|
||||
path = deps/json
|
||||
url = https://github.com/nlohmann/json.git
|
||||
branch = master
|
||||
|
||||
4
deps/CMakeLists.txt
vendored
4
deps/CMakeLists.txt
vendored
@@ -3,6 +3,10 @@ add_subdirectory(unicorn)
|
||||
|
||||
##########################################
|
||||
|
||||
add_subdirectory(json)
|
||||
|
||||
##########################################
|
||||
|
||||
add_library(reflect INTERFACE)
|
||||
target_include_directories(reflect INTERFACE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/reflect"
|
||||
|
||||
1
deps/json
vendored
Submodule
1
deps/json
vendored
Submodule
Submodule deps/json added at 55f93686c0
@@ -16,6 +16,7 @@ endif()
|
||||
|
||||
target_link_libraries(debugger PRIVATE
|
||||
windows-emulator
|
||||
nlohmann_json
|
||||
)
|
||||
|
||||
set_property(GLOBAL PROPERTY VS_STARTUP_PROJECT debugger)
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <windows_emulator.hpp>
|
||||
#include <cstdio>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#ifdef OS_EMSCRIPTEN
|
||||
#include <emscripten.h>
|
||||
@@ -73,18 +74,35 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
void handle_messages()
|
||||
void send_object(const nlohmann::json& json)
|
||||
{
|
||||
const std::string res = json.dump();
|
||||
send_message(res);
|
||||
}
|
||||
|
||||
nlohmann::json receive_object()
|
||||
{
|
||||
auto message = receive_message();
|
||||
if (message.empty())
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
return nlohmann::json::parse(message);
|
||||
}
|
||||
|
||||
void handle_messages(windows_emulator& win_emu)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
suspend_execution(0ms);
|
||||
const auto message = receive_message();
|
||||
if (message.empty())
|
||||
const auto message = receive_object();
|
||||
if (message.is_null())
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
puts(message.c_str());
|
||||
puts(message.dump().c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,7 +162,7 @@ namespace
|
||||
windows_emulator win_emu{app_settings, settings};
|
||||
|
||||
win_emu.callbacks.on_thread_switch = [&] {
|
||||
handle_messages(); //
|
||||
handle_messages(win_emu); //
|
||||
};
|
||||
|
||||
return run_emulation(win_emu);
|
||||
|
||||
Reference in New Issue
Block a user