From 909d8273ccc2ea4a8af2917aa5646d4f214e32f6 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Fri, 27 Jan 2023 17:11:04 +0800 Subject: [PATCH] feat: code check ffi --- src/klotski/ffi/codec.cc | 14 ++++++++++++++ src/klotski/ffi/klotski.h | 11 +++++++++++ src/main.c | 5 ++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/klotski/ffi/codec.cc b/src/klotski/ffi/codec.cc index b51a51d..df78654 100644 --- a/src/klotski/ffi/codec.cc +++ b/src/klotski/ffi/codec.cc @@ -1,7 +1,21 @@ #include "klotski.h" #include "short_code.h" +using klotski::RawCode; using klotski::ShortCode; +using klotski::CommonCode; + +bool raw_code_check(uint64_t code) { + return RawCode::check(code); +} + +bool short_code_check(uint32_t code) { + return ShortCode::check(code); +} + +bool common_code_check(uint64_t code) { + return CommonCode::check(code); +} void short_code_speed_up() { ShortCode::speed_up(ShortCode::NORMAL); diff --git a/src/klotski/ffi/klotski.h b/src/klotski/ffi/klotski.h index e516aa3..0c40edc 100644 --- a/src/klotski/ffi/klotski.h +++ b/src/klotski/ffi/klotski.h @@ -1,5 +1,12 @@ #pragma once +#ifdef __cplusplus +#include +#else +#include +#include +#endif + /// klotski test interface #ifdef __cplusplus extern "C" { @@ -14,6 +21,10 @@ extern "C" { #ifdef __cplusplus extern "C" { #endif + extern bool raw_code_check(uint64_t code); + extern bool short_code_check(uint32_t code); + extern bool common_code_check(uint64_t code); + extern void short_code_speed_up(); extern void short_code_speed_up_fast(); #ifdef __cplusplus diff --git a/src/main.c b/src/main.c index afb1497..96a29de 100644 --- a/src/main.c +++ b/src/main.c @@ -4,7 +4,10 @@ int main() { // printf("cli boot\n"); - tmain(); +// tmain(); + + bool ret = common_code_check(0x1A9BF0C00); + printf("result -> %d\n", ret); // printf("cli exit\n"); return 0;