Tidy JSON parsing in HarteTests

This commit is contained in:
Adrian Conlon 2024-01-10 14:41:37 +00:00
parent 0a9a1e5d4c
commit 81f5efb49a
14 changed files with 16 additions and 66 deletions

View File

@ -160,11 +160,7 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="array_t.cpp" />
<ClCompile Include="byte_t.cpp" />
<ClCompile Include="checker_t.cpp" /> <ClCompile Include="checker_t.cpp" />
<ClCompile Include="cycle_t.cpp" />
<ClCompile Include="element_t.cpp" />
<ClCompile Include="opcode_test_suite_t.cpp" /> <ClCompile Include="opcode_test_suite_t.cpp" />
<ClCompile Include="parser_t.cpp" /> <ClCompile Include="parser_t.cpp" />
<ClCompile Include="processor_test_suite_t.cpp" /> <ClCompile Include="processor_test_suite_t.cpp" />
@ -174,7 +170,6 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
</ClCompile> </ClCompile>
<ClCompile Include="state_t.cpp" />
<ClCompile Include="stdafx.cpp"> <ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader> <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
@ -183,7 +178,6 @@
</ClCompile> </ClCompile>
<ClCompile Include="TestRunner.cpp" /> <ClCompile Include="TestRunner.cpp" />
<ClCompile Include="tests.cpp" /> <ClCompile Include="tests.cpp" />
<ClCompile Include="test_t.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="array_t.h" /> <ClInclude Include="array_t.h" />

View File

@ -20,12 +20,6 @@
<ClCompile Include="stdafx.cpp"> <ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="state_t.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="test_t.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="opcode_test_suite_t.cpp"> <ClCompile Include="opcode_test_suite_t.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -35,18 +29,6 @@
<ClCompile Include="simdjson\simdjson.cpp"> <ClCompile Include="simdjson\simdjson.cpp">
<Filter>Header Files\simdjson</Filter> <Filter>Header Files\simdjson</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="cycle_t.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="byte_t.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="array_t.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="element_t.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="parser_t.cpp"> <ClCompile Include="parser_t.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>

View File

@ -1,5 +0,0 @@
#include "stdafx.h"
#include "array_t.h"
array_t::array_t(const simdjson::dom::array input) noexcept
: m_raw(input) {}

View File

@ -10,7 +10,8 @@ protected:
[[nodiscard]] auto raw() const noexcept { return m_raw; } [[nodiscard]] auto raw() const noexcept { return m_raw; }
public: public:
array_t(simdjson::dom::array input) noexcept; array_t(const simdjson::dom::array input) noexcept
: m_raw(input) {}
[[nodiscard]] auto begin() const noexcept { return raw().begin(); } [[nodiscard]] auto begin() const noexcept { return raw().begin(); }
[[nodiscard]] auto end() const noexcept { return raw().end(); } [[nodiscard]] auto end() const noexcept { return raw().end(); }

View File

@ -1,5 +0,0 @@
#include "stdafx.h"
#include "byte_t.h"
byte_t::byte_t(const simdjson::dom::array input) noexcept
: array_t(input) {}

View File

@ -8,7 +8,8 @@
class byte_t : public array_t { class byte_t : public array_t {
public: public:
byte_t(simdjson::dom::array input) noexcept; byte_t(const simdjson::dom::array input) noexcept
: array_t(input) {}
[[nodiscard]] auto address_at(size_t idx) const noexcept { return uint16_t(integer_at(idx)); } [[nodiscard]] auto address_at(size_t idx) const noexcept { return uint16_t(integer_at(idx)); }
[[nodiscard]] auto byte_at(size_t idx) const noexcept { return uint8_t(integer_at(idx)); } [[nodiscard]] auto byte_at(size_t idx) const noexcept { return uint8_t(integer_at(idx)); }

View File

@ -1,5 +0,0 @@
#include "stdafx.h"
#include "cycle_t.h"
cycle_t::cycle_t(const simdjson::dom::array input) noexcept
: byte_t(input) {}

View File

@ -8,7 +8,8 @@
class cycle_t final : public byte_t { class cycle_t final : public byte_t {
public: public:
cycle_t(simdjson::dom::array input) noexcept; cycle_t(const simdjson::dom::array input) noexcept
: byte_t(input) {}
[[nodiscard]] auto action() const noexcept { return std::string(std::string_view(at(2))); } [[nodiscard]] auto action() const noexcept { return std::string(std::string_view(at(2))); }
}; };

View File

@ -1,7 +0,0 @@
#include "stdafx.h"
#include "element_t.h"
element_t::element_t() noexcept {}
element_t::element_t(const simdjson::dom::element input) noexcept
: m_raw(input) {}

View File

@ -12,8 +12,10 @@ protected:
[[nodiscard]] auto raw() const noexcept { return m_raw; } [[nodiscard]] auto raw() const noexcept { return m_raw; }
public: public:
element_t() noexcept; element_t() noexcept {}
element_t(simdjson::dom::element input) noexcept;
element_t(const simdjson::dom::element input) noexcept
: m_raw(input) {}
[[nodiscard]] auto at(std::string_view key) const noexcept { return raw()[key]; } [[nodiscard]] auto at(std::string_view key) const noexcept { return raw()[key]; }
[[nodiscard]] auto operator[](std::string_view key) const noexcept { return at(key); } [[nodiscard]] auto operator[](std::string_view key) const noexcept { return at(key); }

View File

@ -1,5 +0,0 @@
#include "stdafx.h"
#include "state_t.h"
state_t::state_t(const simdjson::dom::element input) noexcept
: element_t(input) {}

View File

@ -10,7 +10,8 @@
class state_t final : public element_t { class state_t final : public element_t {
public: public:
state_t(simdjson::dom::element input) noexcept; state_t(const simdjson::dom::element input) noexcept
: element_t(input) {}
[[nodiscard]] auto address_at(std::string_view key) const noexcept { return uint16_t(integer_at(key)); } [[nodiscard]] auto address_at(std::string_view key) const noexcept { return uint16_t(integer_at(key)); }
[[nodiscard]] auto byte_at(std::string_view key) const noexcept { return uint8_t(integer_at(key)); } [[nodiscard]] auto byte_at(std::string_view key) const noexcept { return uint8_t(integer_at(key)); }

View File

@ -1,7 +0,0 @@
#include "stdafx.h"
#include "test_t.h"
test_t::test_t() noexcept {}
test_t::test_t(const simdjson::dom::element input) noexcept
: element_t(input) {}

View File

@ -8,8 +8,10 @@
class test_t final : public element_t { class test_t final : public element_t {
public: public:
test_t() noexcept; test_t() noexcept {}
test_t(simdjson::dom::element input) noexcept;
test_t(const simdjson::dom::element input) noexcept
: element_t(input) {}
[[nodiscard]] auto name() const noexcept { return at("name"); } [[nodiscard]] auto name() const noexcept { return at("name"); }
[[nodiscard]] auto initial() const noexcept { return state_t(at("initial")); } [[nodiscard]] auto initial() const noexcept { return state_t(at("initial")); }