Browse Source

feat: mirror interfaces of Layout

master
Dnomd343 4 days ago
parent
commit
1100fbc51e
  1. 7
      src/core_ffi/python_ffi/binder/klsk_code.cc
  2. 16
      src/core_ffi/python_ffi/include/py_ffi/layout.h

7
src/core_ffi/python_ffi/binder/klsk_code.cc

@ -65,7 +65,7 @@ static void bind_layout(const py::module_ &mod) {
.def_property_readonly("n_1x1", &PyLayout::n_1x1)
.def_property_readonly("n_1x2", &PyLayout::n_1x2)
.def_property_readonly("n_2x1", &PyLayout::n_2x1)
.def_property_readonly("n_2x2", &PyLayout::n_2x2) // TODO: return `1` directly
.def_property_readonly("n_2x2", [](const PyLayout&) { return 1; })
.def_property_readonly("type_id", &PyLayout::type_id)
.def_property_readonly("pattern_id", &PyLayout::pattern_id)
@ -74,6 +74,11 @@ static void bind_layout(const py::module_ &mod) {
.def_property_readonly("group", &PyLayout::group_info)
.def_property_readonly("case_info", &PyLayout::case_info)
.def("to_vertical_mirror", &PyLayout::to_vertical_mirror)
.def("to_horizontal_mirror", &PyLayout::to_horizontal_mirror)
.def_property_readonly("is_vertical_mirror", &PyLayout::is_vertical_mirror)
.def_property_readonly("is_horizontal_mirror", &PyLayout::is_horizontal_mirror)
.def_static("check", py::overload_cast<uint64_t>(&PyLayout::check))
.def_static("check", py::overload_cast<std::string_view>(&PyLayout::check));
}

16
src/core_ffi/python_ffi/include/py_ffi/layout.h

@ -119,8 +119,20 @@ public:
return std::get<1>(group::BLOCK_NUM[type_id()]);
}
[[nodiscard]] uint8_t n_2x2() const noexcept {
return 1;
[[nodiscard]] bool is_vertical_mirror() const noexcept {
return code_.is_vertical_mirror();
}
[[nodiscard]] bool is_horizontal_mirror() const noexcept {
return code_.is_horizontal_mirror();
}
[[nodiscard]] PyLayout to_vertical_mirror() const noexcept {
return std::bit_cast<PyLayout>(code_.to_vertical_mirror());
}
[[nodiscard]] PyLayout to_horizontal_mirror() const noexcept {
return std::bit_cast<PyLayout>(code_.to_horizontal_mirror());
}
// ------------------------------------------------------------------------------------- //

Loading…
Cancel
Save