From 4f5e9c246e33ec5024b101f5f828019690549861 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sun, 3 Nov 2024 14:51:48 +0800 Subject: [PATCH] feat: add next_cases support --- src/core_ffi/py_ffi/binder/common_code.cc | 2 ++ src/core_ffi/py_ffi/include/py_ffi/common_code.h | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/core_ffi/py_ffi/binder/common_code.cc b/src/core_ffi/py_ffi/binder/common_code.cc index d3e68ad..82ab88b 100644 --- a/src/core_ffi/py_ffi/binder/common_code.cc +++ b/src/core_ffi/py_ffi/binder/common_code.cc @@ -23,6 +23,8 @@ void bind_common_code(const py::module_ &m) { .def_property_readonly("value", &PyCommonCode::value) .def_property_readonly("short_code", &PyCommonCode::short_code) + .def("next_cases", &PyCommonCode::next_cases) + .def("to_string", &PyCommonCode::string, py::arg("shorten") = false) .def_static("check", static_cast(&PyCommonCode::check)) diff --git a/src/core_ffi/py_ffi/include/py_ffi/common_code.h b/src/core_ffi/py_ffi/include/py_ffi/common_code.h index f37efd3..6bb2d90 100644 --- a/src/core_ffi/py_ffi/include/py_ffi/common_code.h +++ b/src/core_ffi/py_ffi/include/py_ffi/common_code.h @@ -2,6 +2,7 @@ #pragma once +#include #include #include "py_ffi/short_code.h" @@ -56,6 +57,17 @@ public: // ------------------------------------------------------------------------------------- // + [[nodiscard]] std::vector next_cases() const noexcept { + std::vector cases; + auto mover = mover::MaskMover([&cases](const codec::RawCode code, uint64_t) { + cases.emplace_back(std::bit_cast(code.to_common_code())); + }); + mover.next_cases(code_.to_raw_code(), 0); + return cases; + } + + // ------------------------------------------------------------------------------------- // + private: CommonCode code_; };