From b2dc3a89270518a734ed21a194e780486c535292 Mon Sep 17 00:00:00 2001 From: Wagram Airiian Date: Wed, 4 Feb 2026 09:43:51 +0100 Subject: [PATCH 1/6] Update reference --- cmake/deps.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/deps.cmake b/cmake/deps.cmake index 323dc283..89300df1 100644 --- a/cmake/deps.cmake +++ b/cmake/deps.cmake @@ -15,7 +15,7 @@ CPMAddPackage( "EXPECTED_BUILD_TESTS OFF" "EXPECTED_BUILD_PACKAGE_DEB OFF") CPMAddPackage( - URI "gh:Klebert-Engineering/simfil@0.6.3#v0.6.3" + URI "gh:Klebert-Engineering/simfil#byte-array" OPTIONS "SIMFIL_WITH_MODEL_JSON ON" "SIMFIL_SHARED OFF") From 844ac78cbea69e688b53ace79e346d8fe9c1c358 Mon Sep 17 00:00:00 2001 From: Wagram Airiian Date: Wed, 4 Feb 2026 09:52:34 +0100 Subject: [PATCH 2/6] Add byte array --- libs/model/include/mapget/model/featureid.h | 2 ++ libs/model/src/featureid.cpp | 19 ++++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libs/model/include/mapget/model/featureid.h b/libs/model/include/mapget/model/featureid.h index e9c18b0e..8a6a35ff 100644 --- a/libs/model/include/mapget/model/featureid.h +++ b/libs/model/include/mapget/model/featureid.h @@ -67,6 +67,8 @@ class FeatureId : public simfil::MandatoryDerivedModelNodeBase Data* data_ = nullptr; model_ptr fields_; + + mutable std::vector byteArrayCache_; }; } diff --git a/libs/model/src/featureid.cpp b/libs/model/src/featureid.cpp index ebd3f877..92d19626 100644 --- a/libs/model/src/featureid.cpp +++ b/libs/model/src/featureid.cpp @@ -27,8 +27,11 @@ std::string FeatureId::toString() const auto addIdPart = [&result](auto&& v) { - if constexpr (!std::is_same_v, std::monostate>) + if constexpr (std::is_same_v, simfil::ByteArray>) { + result << "." << v.toDisplayString(); + } else if constexpr (!std::is_same_v, std::monostate>) { result << "." << v; + } }; // Add common id-part fields @@ -84,14 +87,24 @@ bool FeatureId::iterate(const simfil::ModelNode::IterCallback& cb) const KeyValueViewPairs FeatureId::keyValuePairs() const { KeyValueViewPairs result; + byteArrayCache_.clear(); auto objectFieldsToKeyValuePairs = [&result, this](simfil::ModelNode::FieldRange fields){ for (auto const& [key, value] : fields) { auto keyStr = model().strings()->resolve(key); std::visit( - [&result, &keyStr](auto&& v) + [&result, &keyStr, this](auto&& v) { - if constexpr (!std::is_same_v, std::monostate> && !std::is_same_v, double>) { + using T = std::decay_t; + if constexpr (std::is_same_v || std::is_same_v) { + return; + } else if constexpr (std::is_same_v) { + byteArrayCache_.emplace_back(v.toDisplayString()); + result.emplace_back(*keyStr, std::string_view(byteArrayCache_.back())); + } else if constexpr (std::is_same_v) { + byteArrayCache_.push_back(v); + result.emplace_back(*keyStr, std::string_view(byteArrayCache_.back())); + } else { result.emplace_back(*keyStr, v); } }, From bdf24c9e74426de474d86e489c4362ab7638edcf Mon Sep 17 00:00:00 2001 From: Wagram Airiian Date: Wed, 4 Feb 2026 14:41:16 +0100 Subject: [PATCH 3/6] Raise exception in FeatureId when value is ByteArray --- libs/model/include/mapget/model/featureid.h | 2 -- libs/model/src/featureid.cpp | 18 +++++++----------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/libs/model/include/mapget/model/featureid.h b/libs/model/include/mapget/model/featureid.h index 8a6a35ff..e9c18b0e 100644 --- a/libs/model/include/mapget/model/featureid.h +++ b/libs/model/include/mapget/model/featureid.h @@ -67,8 +67,6 @@ class FeatureId : public simfil::MandatoryDerivedModelNodeBase Data* data_ = nullptr; model_ptr fields_; - - mutable std::vector byteArrayCache_; }; } diff --git a/libs/model/src/featureid.cpp b/libs/model/src/featureid.cpp index 92d19626..2fbc8b43 100644 --- a/libs/model/src/featureid.cpp +++ b/libs/model/src/featureid.cpp @@ -3,6 +3,8 @@ #include +#include "mapget/log.h" + namespace mapget { @@ -87,24 +89,18 @@ bool FeatureId::iterate(const simfil::ModelNode::IterCallback& cb) const KeyValueViewPairs FeatureId::keyValuePairs() const { KeyValueViewPairs result; - byteArrayCache_.clear(); auto objectFieldsToKeyValuePairs = [&result, this](simfil::ModelNode::FieldRange fields){ for (auto const& [key, value] : fields) { auto keyStr = model().strings()->resolve(key); std::visit( - [&result, &keyStr, this](auto&& v) + [&result, &keyStr](auto&& v) { using T = std::decay_t; - if constexpr (std::is_same_v || std::is_same_v) { - return; - } else if constexpr (std::is_same_v) { - byteArrayCache_.emplace_back(v.toDisplayString()); - result.emplace_back(*keyStr, std::string_view(byteArrayCache_.back())); - } else if constexpr (std::is_same_v) { - byteArrayCache_.push_back(v); - result.emplace_back(*keyStr, std::string_view(byteArrayCache_.back())); - } else { + if constexpr (std::is_same_v) { + raiseFmt("FeatureId part '{}' cannot be a ByteArray.", keyStr ? *keyStr : ""); + } + else if constexpr (!std::is_same_v && !std::is_same_v) { result.emplace_back(*keyStr, v); } }, From 6919cff184c125260f4d65cdcc45b3ebaee462f2 Mon Sep 17 00:00:00 2001 From: Wagram Airiian Date: Wed, 4 Feb 2026 14:44:22 +0100 Subject: [PATCH 4/6] Raise exception in FeatureId when value is ByteArray --- libs/model/src/featureid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/model/src/featureid.cpp b/libs/model/src/featureid.cpp index 2fbc8b43..cb8293d5 100644 --- a/libs/model/src/featureid.cpp +++ b/libs/model/src/featureid.cpp @@ -30,7 +30,7 @@ std::string FeatureId::toString() const auto addIdPart = [&result](auto&& v) { if constexpr (std::is_same_v, simfil::ByteArray>) { - result << "." << v.toDisplayString(); + raiseFmt("FeatureId part value '{}' cannot be a ByteArray.", v.toDisplayString()); } else if constexpr (!std::is_same_v, std::monostate>) { result << "." << v; } From 2db9691c0b21b76ca17cc7362e34ec1f809f41d0 Mon Sep 17 00:00:00 2001 From: Wagram Airiian Date: Tue, 10 Feb 2026 08:05:04 +0100 Subject: [PATCH 5/6] Fix output regarding ByteArray. --- libs/model/include/mapget/model/featurelayer.h | 2 +- libs/model/src/featureid.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/model/include/mapget/model/featurelayer.h b/libs/model/include/mapget/model/featurelayer.h index 07888c60..9f4ffbc6 100644 --- a/libs/model/include/mapget/model/featurelayer.h +++ b/libs/model/include/mapget/model/featurelayer.h @@ -233,7 +233,7 @@ class TileFeatureLayer : public TileLayer, public simfil::ModelPool * @param query Simfil query * @param node Model root node to query * @param anyMode Auto-wrap expression in `any(...)` - * @param autoWildcard Auto expand constant expressions to `** = ` + * @param autoWildcard Auto expand constant expressions to `** == ` */ struct QueryResult { // The list of values resulting from the query evaluation. diff --git a/libs/model/src/featureid.cpp b/libs/model/src/featureid.cpp index cb8293d5..228c3854 100644 --- a/libs/model/src/featureid.cpp +++ b/libs/model/src/featureid.cpp @@ -30,7 +30,7 @@ std::string FeatureId::toString() const auto addIdPart = [&result](auto&& v) { if constexpr (std::is_same_v, simfil::ByteArray>) { - raiseFmt("FeatureId part value '{}' cannot be a ByteArray.", v.toDisplayString()); + raiseFmt("FeatureId part value 'b\"{}\"' cannot be a ByteArray.", v.toHex()); } else if constexpr (!std::is_same_v, std::monostate>) { result << "." << v; } From 99c55266cca4285599133366fe63caf915827473 Mon Sep 17 00:00:00 2001 From: Joseph Birkner Date: Tue, 10 Feb 2026 12:36:36 +0100 Subject: [PATCH 6/6] Fix py-layer.h --- libs/pymapget/binding/py-layer.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/libs/pymapget/binding/py-layer.h b/libs/pymapget/binding/py-layer.h index bc641193..8b149852 100644 --- a/libs/pymapget/binding/py-layer.h +++ b/libs/pymapget/binding/py-layer.h @@ -96,8 +96,17 @@ void bindTileLayer(py::module_& m) std::visit( [&](auto&& vv) { - if constexpr (!std::is_same_v, std::monostate>) + using V = std::decay_t; + if constexpr (std::is_same_v) { + return; + } + else if constexpr (std::is_same_v) { + // Store bytes in hex to keep JSON valid and readable. + self.setInfo(k, vv.toHex()); + } + else { self.setInfo(k, vv); + } }, v); }, @@ -106,7 +115,7 @@ void bindTileLayer(py::module_& m) R"pbdoc( Set a JSON field to store sizes, construction times, and other arbitrary meta-information. The value may be - bool, int, double or string. + bool, int, double or string. ByteArray values are stored as hex strings. )pbdoc") .def( "set_prefix",