Browse Source

feat: add next_cases support

master
Dnomd343 2 weeks ago
parent
commit
4f5e9c246e
  1. 2
      src/core_ffi/py_ffi/binder/common_code.cc
  2. 12
      src/core_ffi/py_ffi/include/py_ffi/common_code.h

2
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<bool (*)(uint64_t)>(&PyCommonCode::check))

12
src/core_ffi/py_ffi/include/py_ffi/common_code.h

@ -2,6 +2,7 @@
#pragma once
#include <mover/mover.h>
#include <common_code/common_code.h>
#include "py_ffi/short_code.h"
@ -56,6 +57,17 @@ public:
// ------------------------------------------------------------------------------------- //
[[nodiscard]] std::vector<PyCommonCode> next_cases() const noexcept {
std::vector<PyCommonCode> cases;
auto mover = mover::MaskMover([&cases](const codec::RawCode code, uint64_t) {
cases.emplace_back(std::bit_cast<PyCommonCode>(code.to_common_code()));
});
mover.next_cases(code_.to_raw_code(), 0);
return cases;
}
// ------------------------------------------------------------------------------------- //
private:
CommonCode code_;
};

Loading…
Cancel
Save