From 0dd562ab4aabcbe0bd19468bb322e090c2ea4d96 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sat, 28 Jan 2023 21:35:56 +0800 Subject: [PATCH] feat: all_cases export api --- src/klotski/CMakeLists.txt | 2 +- src/klotski/ffi/all_cases.cc | 23 +++++++++++++++++++++++ src/klotski/ffi/klotski.h | 20 +++++++++++++++++++- src/main.c | 2 +- 4 files changed, 44 insertions(+), 3 deletions(-) create mode 100644 src/klotski/ffi/all_cases.cc diff --git a/src/klotski/CMakeLists.txt b/src/klotski/CMakeLists.txt index 95bf892..32fe0b1 100644 --- a/src/klotski/CMakeLists.txt +++ b/src/klotski/CMakeLists.txt @@ -63,7 +63,7 @@ add_subdirectory(benchmark) ################################################################################ -set(FFI_SRC codec.cc tmain.cc version.cc) +set(FFI_SRC codec.cc all_cases.cc tmain.cc version.cc) list(TRANSFORM FFI_SRC PREPEND "ffi/") add_library(klotski-ffi OBJECT ${FFI_SRC}) diff --git a/src/klotski/ffi/all_cases.cc b/src/klotski/ffi/all_cases.cc new file mode 100644 index 0000000..6f7b728 --- /dev/null +++ b/src/klotski/ffi/all_cases.cc @@ -0,0 +1,23 @@ +#include "klotski.h" +#include "all_cases.h" + +using klotski::AllCases; +using klotski::BasicRanges; +using klotski::BASIC_RANGES_SIZE; +using klotski::ALL_CASES_SIZE_SUM; + +void all_cases_build() { + AllCases::build(); +} + +void basic_ranges_build() { + BasicRanges::build(); +} + +bool is_all_cases_available() { + return AllCases::status() == AllCases::AVAILABLE; +} + +bool is_basic_ranges_available() { + return BasicRanges::status() == BasicRanges::AVAILABLE; +} diff --git a/src/klotski/ffi/klotski.h b/src/klotski/ffi/klotski.h index 1733b5e..00a6058 100644 --- a/src/klotski/ffi/klotski.h +++ b/src/klotski/ffi/klotski.h @@ -38,6 +38,25 @@ extern "C" { } #endif +/// ------------------------------- klotski all cases export -------------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + extern void all_cases_build(); + extern void basic_ranges_build(); + extern bool is_all_cases_available(); + extern bool is_basic_ranges_available(); + + extern const uint32_t all_cases_size; + extern void export_all_cases(uint64_t *buffer); + + extern const uint32_t basic_ranges_size; + extern void export_basic_ranges(uint32_t *buffer); +#ifdef __cplusplus +} +#endif + /// -------------------------------- klotski codec interface -------------------------------- #ifdef __cplusplus @@ -70,7 +89,6 @@ extern "C" { extern bool common_code_to_string(uint64_t common_code, char common_code_str[]); extern bool common_code_to_string_shorten(uint64_t common_code, char common_code_str[]); extern bool common_code_from_string(const char common_code_str[], uint64_t *common_code); - #ifdef __cplusplus } #endif diff --git a/src/main.c b/src/main.c index 8b3f9be..19d4f6e 100644 --- a/src/main.c +++ b/src/main.c @@ -4,7 +4,7 @@ int main() { // printf("cli boot\n"); - tmain(); +// tmain(); return 0; // bool ret = common_code_check(0x1A9BF0C00);