mirror of https://github.com/dnomd343/klotski.git
Dnomd343
2 weeks ago
17 changed files with 181 additions and 151 deletions
@ -1,32 +0,0 @@ |
|||||
#include "binder.h" |
|
||||
|
|
||||
void bind_common_code(const py::module_ &m) { |
|
||||
py::class_<PyCommonCode>(m, "CommonCode") |
|
||||
.def(py::init<uint64_t>()) |
|
||||
.def(py::init<PyShortCode>()) |
|
||||
.def(py::init<std::string_view>()) |
|
||||
|
|
||||
.def(py::hash(py::self)) |
|
||||
.def("__str__", &PyCommonCode::str) |
|
||||
.def("__int__", &PyCommonCode::value) |
|
||||
.def("__repr__", &PyCommonCode::repr) |
|
||||
|
|
||||
.def(py::self == py::self) |
|
||||
.def(py::self < py::self).def(py::self <= py::self) |
|
||||
.def(py::self > py::self).def(py::self >= py::self) |
|
||||
|
|
||||
.def(py::self == uint64_t()) |
|
||||
.def(py::self < uint64_t()).def(py::self <= uint64_t()) |
|
||||
.def(py::self > uint64_t()).def(py::self >= uint64_t()) |
|
||||
|
|
||||
// .def_property_readonly("str", &PyCommonCode::string)
|
|
||||
.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)) |
|
||||
.def_static("check", static_cast<bool (*)(std::string_view)>(&PyCommonCode::check)); |
|
||||
} |
|
@ -0,0 +1,72 @@ |
|||||
|
#include <pybind11/operators.h> |
||||
|
|
||||
|
#include "binder.h" |
||||
|
#include "py_ffi/short_code.h" |
||||
|
#include "py_ffi/common_code.h" |
||||
|
|
||||
|
using klotski::ffi::PyShortCode; |
||||
|
using klotski::ffi::PyCommonCode; |
||||
|
|
||||
|
static void bind_common_code(const py::module_ &mod) { |
||||
|
py::class_<PyCommonCode>(mod, "Code") |
||||
|
.def(py::init<uint64_t>()) |
||||
|
.def(py::init<PyShortCode>()) |
||||
|
.def(py::init<std::string_view>()) |
||||
|
|
||||
|
.def(py::self == py::self) |
||||
|
.def(py::self < py::self).def(py::self <= py::self) |
||||
|
.def(py::self > py::self).def(py::self >= py::self) |
||||
|
.def(py::self == uint64_t()) |
||||
|
.def(py::self < uint64_t()).def(py::self <= uint64_t()) |
||||
|
.def(py::self > uint64_t()).def(py::self >= uint64_t()) |
||||
|
|
||||
|
.def(py::hash(py::self)) |
||||
|
.def("__str__", &PyCommonCode::str) |
||||
|
.def("__int__", &PyCommonCode::value) |
||||
|
.def("__repr__", &PyCommonCode::repr) |
||||
|
|
||||
|
.def("next_cases", &PyCommonCode::next_cases) |
||||
|
// TODO: add fast_cal / fast_cal_multi / ...
|
||||
|
|
||||
|
.def("to_short_code", &PyCommonCode::short_code) |
||||
|
.def("to_string", &PyCommonCode::string, py::arg("shorten") = false) |
||||
|
|
||||
|
.def_property_readonly("value", &PyCommonCode::value) |
||||
|
// TODO: add n_1x1 / n_1x2 / n_2x1 / ...
|
||||
|
|
||||
|
.def_static("check", py::overload_cast<uint64_t>(&PyCommonCode::check)) |
||||
|
.def_static("check", py::overload_cast<std::string_view>(&PyCommonCode::check)); |
||||
|
} |
||||
|
|
||||
|
static void bind_short_code(const py::module_ &mod) { |
||||
|
py::class_<PyShortCode>(mod, "ShortCode") |
||||
|
.def(py::init<uint32_t>()) |
||||
|
.def(py::init<PyCommonCode>()) |
||||
|
.def(py::init<std::string_view>()) |
||||
|
|
||||
|
.def(py::self == py::self) |
||||
|
.def(py::self < py::self).def(py::self <= py::self) |
||||
|
.def(py::self > py::self).def(py::self >= py::self) |
||||
|
.def(py::self == uint32_t()) |
||||
|
.def(py::self < uint32_t()).def(py::self <= uint32_t()) |
||||
|
.def(py::self > uint32_t()).def(py::self >= uint32_t()) |
||||
|
|
||||
|
.def(py::hash(py::self)) |
||||
|
.def("__str__", &PyShortCode::str) |
||||
|
.def("__int__", &PyShortCode::value) |
||||
|
.def("__repr__", &PyShortCode::repr) |
||||
|
|
||||
|
.def_property_readonly("value", &PyShortCode::value) |
||||
|
|
||||
|
.def("to_common_code", &PyShortCode::common_code) |
||||
|
|
||||
|
.def_static("check", py::overload_cast<uint32_t>(&PyShortCode::check)) |
||||
|
.def_static("check", py::overload_cast<std::string_view>(&PyShortCode::check)) |
||||
|
|
||||
|
.def_static("speed_up", &PyShortCode::speed_up, py::arg("fast_mode") = false); |
||||
|
} |
||||
|
|
||||
|
void bind_klsk_code(const py::module_ &mod) { |
||||
|
bind_short_code(mod); |
||||
|
bind_common_code(mod); |
||||
|
} |
@ -1,28 +0,0 @@ |
|||||
#include "binder.h" |
|
||||
|
|
||||
void bind_short_code(const py::module_ &m) { |
|
||||
py::class_<PyShortCode>(m, "ShortCode") |
|
||||
.def(py::init<uint32_t>()) |
|
||||
.def(py::init<PyCommonCode>()) |
|
||||
.def(py::init<std::string_view>()) |
|
||||
|
|
||||
.def(py::hash(py::self)) |
|
||||
.def("__str__", &PyShortCode::str) |
|
||||
.def("__int__", &PyShortCode::value) |
|
||||
.def("__repr__", &PyShortCode::repr) |
|
||||
|
|
||||
.def(py::self == py::self) |
|
||||
.def(py::self < py::self).def(py::self <= py::self) |
|
||||
.def(py::self > py::self).def(py::self >= py::self) |
|
||||
|
|
||||
.def(py::self == uint32_t()) |
|
||||
.def(py::self < uint32_t()).def(py::self <= uint32_t()) |
|
||||
.def(py::self > uint32_t()).def(py::self >= uint32_t()) |
|
||||
|
|
||||
.def_property_readonly("value", &PyShortCode::value) |
|
||||
.def_property_readonly("common_code", &PyShortCode::common_code) |
|
||||
|
|
||||
.def_static("check", static_cast<bool (*)(uint32_t)>(&PyShortCode::check)) |
|
||||
.def_static("check", static_cast<bool (*)(std::string_view)>(&PyShortCode::check)) |
|
||||
.def_static("speed_up", &PyShortCode::speed_up, py::arg("fast_mode") = false); |
|
||||
} |
|
@ -1,30 +1,15 @@ |
|||||
#pragma once |
#pragma once |
||||
|
|
||||
#include <pybind11/pybind11.h> |
#include <pybind11/pybind11.h> |
||||
#include <pybind11/operators.h> |
|
||||
#include <pybind11/stl.h> |
|
||||
|
|
||||
namespace py = pybind11; |
namespace py = pybind11; |
||||
|
|
||||
#include "py_ffi/cases.h" |
void bind_klsk_code(const py::module_ &mod); |
||||
#include "py_ffi/group.h" |
|
||||
#include "py_ffi/short_code.h" |
|
||||
#include "py_ffi/common_code.h" |
|
||||
#include "py_ffi/fast_cal.h" |
|
||||
|
|
||||
using klotski::ffi::PyCases; |
void bind_klsk_cases(const py::module_ &mod); |
||||
using klotski::ffi::PyCasesIter; |
|
||||
using klotski::ffi::PyShortCode; |
|
||||
using klotski::ffi::PyCommonCode; |
|
||||
using klotski::ffi::PyGroupUnion; |
|
||||
using klotski::ffi::PyGroup; |
|
||||
using klotski::ffi::PyFastCal; |
|
||||
|
|
||||
void bind_cases(const py::module_ &mod); |
// TODO: add `bind_klsk_group` and `bind_klsk_fast_cal`
|
||||
void bind_short_code(const py::module_ &m); |
|
||||
void bind_common_code(const py::module_ &m); |
|
||||
|
|
||||
void bind_group_union(const py::module_ &m); |
void bind_group_union(const py::module_ &m); |
||||
void bind_group(const py::module_ &m); |
void bind_group(const py::module_ &m); |
||||
|
|
||||
void bind_fast_cal(const py::module_ &m); |
void bind_fast_cal(const py::module_ &m); |
||||
|
Loading…
Reference in new issue