mirror of https://github.com/dnomd343/klotski.git
				
				
			
				 9 changed files with 148 additions and 30 deletions
			
			
		@ -0,0 +1,32 @@ | 
				
			|||
#include "rust_ffi/include/short_code.h" | 
				
			|||
 | 
				
			|||
#include <short_code/short_code.h> | 
				
			|||
 | 
				
			|||
using klotski::codec::ShortCode; | 
				
			|||
 | 
				
			|||
using klotski::ffi::RsShortCode; | 
				
			|||
using klotski::ffi::RsCommonCode; | 
				
			|||
 | 
				
			|||
bool klotski::ffi::short_code_check(const uint32_t val) { | 
				
			|||
    return ShortCode::check(val); | 
				
			|||
} | 
				
			|||
 | 
				
			|||
uint32_t klotski::ffi::short_code_from_str(const rust::Str s) { | 
				
			|||
    const std::string_view sv {s.data(), s.length()}; | 
				
			|||
    if (const auto ret = ShortCode::from_string(sv); ret.has_value()) { | 
				
			|||
        return ret.value().unwrap(); | 
				
			|||
    } | 
				
			|||
    return 0xFFFFFFFF; // return invalid value for now
 | 
				
			|||
} | 
				
			|||
 | 
				
			|||
rust::String RsShortCode::to_string() const noexcept { | 
				
			|||
    return ShortCode::unsafe_create(code).to_string(); | 
				
			|||
} | 
				
			|||
 | 
				
			|||
RsCommonCode RsShortCode::to_common_code() const noexcept { | 
				
			|||
    return {ShortCode::unsafe_create(code).to_common_code().unwrap()}; | 
				
			|||
} | 
				
			|||
 | 
				
			|||
void klotski::ffi::short_code_speed_up(const bool fast_mode) { | 
				
			|||
    ShortCode::speed_up(fast_mode); | 
				
			|||
} | 
				
			|||
@ -1,11 +1,3 @@ | 
				
			|||
#pragma once | 
				
			|||
 | 
				
			|||
#include "rust_ffi/src/common_code.rs.h" | 
				
			|||
 | 
				
			|||
namespace klotski::ffi { | 
				
			|||
 | 
				
			|||
bool common_code_check(uint64_t val); | 
				
			|||
 | 
				
			|||
uint64_t common_code_from_str(rust::Str s); | 
				
			|||
 | 
				
			|||
} // namespace klotski::ffi
 | 
				
			|||
#include "interface.h" | 
				
			|||
 | 
				
			|||
@ -0,0 +1,17 @@ | 
				
			|||
#pragma once | 
				
			|||
 | 
				
			|||
#include "rust_ffi/src/bridge.rs.h" | 
				
			|||
 | 
				
			|||
namespace klotski::ffi { | 
				
			|||
 | 
				
			|||
bool short_code_check(uint32_t val); | 
				
			|||
 | 
				
			|||
bool common_code_check(uint64_t val); | 
				
			|||
 | 
				
			|||
uint32_t short_code_from_str(rust::Str s); | 
				
			|||
 | 
				
			|||
uint64_t common_code_from_str(rust::Str s); | 
				
			|||
 | 
				
			|||
void short_code_speed_up(bool fast_mode); | 
				
			|||
 | 
				
			|||
} // namespace klotski::ffi
 | 
				
			|||
@ -0,0 +1,3 @@ | 
				
			|||
#pragma once | 
				
			|||
 | 
				
			|||
#include "interface.h" | 
				
			|||
					Loading…
					
					
				
		Reference in new issue