Browse Source

feat: code check ffi

master
Dnomd343 2 years ago
parent
commit
909d8273cc
  1. 14
      src/klotski/ffi/codec.cc
  2. 11
      src/klotski/ffi/klotski.h
  3. 5
      src/main.c

14
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);

11
src/klotski/ffi/klotski.h

@ -1,5 +1,12 @@
#pragma once
#ifdef __cplusplus
#include <cstdint>
#else
#include <stdint.h>
#include <stdbool.h>
#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

5
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;

Loading…
Cancel
Save