reafactoring part1

This commit is contained in:
neuecc 2023-03-05 01:03:33 +09:00
parent 4710958684
commit b986cbefff
7 changed files with 408 additions and 323 deletions

View File

@ -1,4 +1,7 @@
use std::ffi::{c_char, CString}; use std::{
collections::HashSet,
ffi::{c_char, c_void, CString},
};
#[allow(dead_code)] #[allow(dead_code)]
#[allow(non_snake_case)] #[allow(non_snake_case)]
@ -11,8 +14,6 @@ mod lz4;
#[allow(non_camel_case_types)] #[allow(non_camel_case_types)]
mod lz4_ffi; mod lz4_ffi;
#[no_mangle] #[no_mangle]
#[allow(improper_ctypes_definitions)] #[allow(improper_ctypes_definitions)]
pub extern "C" fn ignore_nop() -> (i32, i32) { pub extern "C" fn ignore_nop() -> (i32, i32) {
@ -20,18 +21,50 @@ pub extern "C" fn ignore_nop() -> (i32, i32) {
(1, 2) (1, 2)
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn nop() -> () { pub extern "C" fn nop() -> () {
println!("hello nop!"); println!("hello nop!");
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn my_add(x: i32, y: i32) -> i32 { pub extern "C" fn my_add(x: i32, y: i32) -> i32 {
x + y x + y
} }
#[no_mangle]
pub extern "C" fn callback_test(cb: extern fn(a: i32) -> i32) -> i32 {
// Fn
cb(100)
}
#[no_mangle]
pub extern "C" fn create_counter_context() -> *mut c_void {
let ctx = Box::new(CounterContext {
set: HashSet::new(),
});
Box::into_raw(ctx) as *mut c_void
}
#[no_mangle]
pub unsafe extern "C" fn insert_counter_context(context: *mut c_void, value: i32) {
let mut counter = Box::from_raw(context as *mut CounterContext);
counter.set.insert(value);
Box::into_raw(counter);
}
#[no_mangle]
pub unsafe extern "C" fn delete_counter_context(context: *mut c_void) {
let counter = Box::from_raw(context as *mut CounterContext);
for value in counter.set.iter() {
println!("counter value: {}", value)
}
}
#[repr(C)]
pub struct CounterContext {
pub set: HashSet<i32>,
}
#[no_mangle] #[no_mangle]
pub extern "C" fn my_bool( pub extern "C" fn my_bool(
x: bool, x: bool,
@ -114,7 +147,6 @@ pub extern "C" fn delete_context(context: *mut Context) {
unsafe { Box::from_raw(context) }; unsafe { Box::from_raw(context) };
} }
#[no_mangle] #[no_mangle]
pub extern "C" fn call_bindgen() { pub extern "C" fn call_bindgen() {
let path = std::env::current_dir().unwrap(); let path = std::env::current_dir().unwrap();
@ -144,7 +176,6 @@ fn build_test() {
// // println!("lz4 num: {}", num); // // println!("lz4 num: {}", num);
// // } // // }
csbindgen::Builder::default() csbindgen::Builder::default()
.input_extern_file("csbindgen-tests/src/lib.rs") .input_extern_file("csbindgen-tests/src/lib.rs")
.csharp_class_name("LibRust") .csharp_class_name("LibRust")

View File

@ -9,7 +9,7 @@ use super::lz4;
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_versionNumber( pub unsafe extern "C" fn csbindgen_LZ4_versionNumber(
) -> c_int ) -> c_int
{ {
lz4::LZ4_versionNumber( lz4::LZ4_versionNumber(
@ -30,9 +30,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_versionString(
pub unsafe extern "C" fn csbindgen_LZ4_compress_default( pub unsafe extern "C" fn csbindgen_LZ4_compress_default(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSize: c_int, srcSize: c_int,
dstCapacity: c_int dstCapacity: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_default( lz4::LZ4_compress_default(
src, src,
@ -46,9 +46,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_default(
pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe( pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
compressedSize: c_int, compressedSize: c_int,
dstCapacity: c_int dstCapacity: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_decompress_safe( lz4::LZ4_decompress_safe(
src, src,
@ -60,8 +60,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_compressBound( pub unsafe extern "C" fn csbindgen_LZ4_compressBound(
inputSize: c_int inputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressBound( lz4::LZ4_compressBound(
inputSize inputSize
@ -72,10 +72,10 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressBound(
pub unsafe extern "C" fn csbindgen_LZ4_compress_fast( pub unsafe extern "C" fn csbindgen_LZ4_compress_fast(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSize: c_int, srcSize: c_int,
dstCapacity: c_int, dstCapacity: c_int,
acceleration: c_int acceleration: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_fast( lz4::LZ4_compress_fast(
src, src,
@ -89,7 +89,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_fast(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_sizeofState( pub unsafe extern "C" fn csbindgen_LZ4_sizeofState(
) -> c_int ) -> c_int
{ {
lz4::LZ4_sizeofState( lz4::LZ4_sizeofState(
@ -101,10 +101,10 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_fast_extState(
state: *mut c_void, state: *mut c_void,
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSize: c_int, srcSize: c_int,
dstCapacity: c_int, dstCapacity: c_int,
acceleration: c_int acceleration: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_fast_extState( lz4::LZ4_compress_fast_extState(
state, state,
@ -121,8 +121,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_destSize(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSizePtr: *mut c_int, srcSizePtr: *mut c_int,
targetDstSize: c_int targetDstSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_destSize( lz4::LZ4_compress_destSize(
src, src,
@ -136,10 +136,10 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_destSize(
pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_partial( pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_partial(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSize: c_int, srcSize: c_int,
targetOutputSize: c_int, targetOutputSize: c_int,
dstCapacity: c_int dstCapacity: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_decompress_safe_partial( lz4::LZ4_decompress_safe_partial(
src, src,
@ -163,7 +163,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_createStream(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_freeStream( pub unsafe extern "C" fn csbindgen_LZ4_freeStream(
streamPtr: *mut lz4::LZ4_stream_t streamPtr: *mut lz4::LZ4_stream_t
) -> c_int ) -> c_int
{ {
lz4::LZ4_freeStream( lz4::LZ4_freeStream(
streamPtr streamPtr
@ -184,8 +184,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_resetStream_fast(
pub unsafe extern "C" fn csbindgen_LZ4_loadDict( pub unsafe extern "C" fn csbindgen_LZ4_loadDict(
streamPtr: *mut lz4::LZ4_stream_t, streamPtr: *mut lz4::LZ4_stream_t,
dictionary: *const c_char, dictionary: *const c_char,
dictSize: c_int dictSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_loadDict( lz4::LZ4_loadDict(
streamPtr, streamPtr,
@ -199,10 +199,10 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_fast_continue(
streamPtr: *mut lz4::LZ4_stream_t, streamPtr: *mut lz4::LZ4_stream_t,
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSize: c_int, srcSize: c_int,
dstCapacity: c_int, dstCapacity: c_int,
acceleration: c_int acceleration: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_fast_continue( lz4::LZ4_compress_fast_continue(
streamPtr, streamPtr,
@ -218,8 +218,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_fast_continue(
pub unsafe extern "C" fn csbindgen_LZ4_saveDict( pub unsafe extern "C" fn csbindgen_LZ4_saveDict(
streamPtr: *mut lz4::LZ4_stream_t, streamPtr: *mut lz4::LZ4_stream_t,
safeBuffer: *mut c_char, safeBuffer: *mut c_char,
maxDictSize: c_int maxDictSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_saveDict( lz4::LZ4_saveDict(
streamPtr, streamPtr,
@ -241,7 +241,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_createStreamDecode(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_freeStreamDecode( pub unsafe extern "C" fn csbindgen_LZ4_freeStreamDecode(
LZ4_stream: *mut lz4::LZ4_streamDecode_t LZ4_stream: *mut lz4::LZ4_streamDecode_t
) -> c_int ) -> c_int
{ {
lz4::LZ4_freeStreamDecode( lz4::LZ4_freeStreamDecode(
LZ4_stream LZ4_stream
@ -252,8 +252,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_freeStreamDecode(
pub unsafe extern "C" fn csbindgen_LZ4_setStreamDecode( pub unsafe extern "C" fn csbindgen_LZ4_setStreamDecode(
LZ4_streamDecode: *mut lz4::LZ4_streamDecode_t, LZ4_streamDecode: *mut lz4::LZ4_streamDecode_t,
dictionary: *const c_char, dictionary: *const c_char,
dictSize: c_int dictSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_setStreamDecode( lz4::LZ4_setStreamDecode(
LZ4_streamDecode, LZ4_streamDecode,
@ -264,8 +264,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_setStreamDecode(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_decoderRingBufferSize( pub unsafe extern "C" fn csbindgen_LZ4_decoderRingBufferSize(
maxBlockSize: c_int maxBlockSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_decoderRingBufferSize( lz4::LZ4_decoderRingBufferSize(
maxBlockSize maxBlockSize
@ -277,9 +277,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_continue(
LZ4_streamDecode: *mut lz4::LZ4_streamDecode_t, LZ4_streamDecode: *mut lz4::LZ4_streamDecode_t,
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSize: c_int, srcSize: c_int,
dstCapacity: c_int dstCapacity: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_decompress_safe_continue( lz4::LZ4_decompress_safe_continue(
LZ4_streamDecode, LZ4_streamDecode,
@ -294,11 +294,11 @@ pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_continue(
pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_usingDict( pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_usingDict(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSize: c_int, srcSize: c_int,
dstCapacity: c_int, dstCapacity: c_int,
dictStart: *const c_char, dictStart: *const c_char,
dictSize: c_int dictSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_decompress_safe_usingDict( lz4::LZ4_decompress_safe_usingDict(
src, src,
@ -314,12 +314,12 @@ pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_usingDict(
pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_partial_usingDict( pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_partial_usingDict(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
compressedSize: c_int, compressedSize: c_int,
targetOutputSize: c_int, targetOutputSize: c_int,
maxOutputSize: c_int, maxOutputSize: c_int,
dictStart: *const c_char, dictStart: *const c_char,
dictSize: c_int dictSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_decompress_safe_partial_usingDict( lz4::LZ4_decompress_safe_partial_usingDict(
src, src,
@ -335,7 +335,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_partial_usingDict(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_initStream( pub unsafe extern "C" fn csbindgen_LZ4_initStream(
buffer: *mut c_void, buffer: *mut c_void,
size: usize size: usize
) -> *mut lz4::LZ4_stream_t ) -> *mut lz4::LZ4_stream_t
{ {
lz4::LZ4_initStream( lz4::LZ4_initStream(
@ -348,8 +348,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_initStream(
pub unsafe extern "C" fn csbindgen_LZ4_compress( pub unsafe extern "C" fn csbindgen_LZ4_compress(
src: *const c_char, src: *const c_char,
dest: *mut c_char, dest: *mut c_char,
srcSize: c_int srcSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress( lz4::LZ4_compress(
src, src,
@ -362,9 +362,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress(
pub unsafe extern "C" fn csbindgen_LZ4_compress_limitedOutput( pub unsafe extern "C" fn csbindgen_LZ4_compress_limitedOutput(
src: *const c_char, src: *const c_char,
dest: *mut c_char, dest: *mut c_char,
srcSize: c_int, srcSize: c_int,
maxOutputSize: c_int maxOutputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_limitedOutput( lz4::LZ4_compress_limitedOutput(
src, src,
@ -379,8 +379,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_withState(
state: *mut c_void, state: *mut c_void,
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int inputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_withState( lz4::LZ4_compress_withState(
state, state,
@ -395,9 +395,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_limitedOutput_withState(
state: *mut c_void, state: *mut c_void,
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int, inputSize: c_int,
maxOutputSize: c_int maxOutputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_limitedOutput_withState( lz4::LZ4_compress_limitedOutput_withState(
state, state,
@ -413,8 +413,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_continue(
LZ4_streamPtr: *mut lz4::LZ4_stream_t, LZ4_streamPtr: *mut lz4::LZ4_stream_t,
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int inputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_continue( lz4::LZ4_compress_continue(
LZ4_streamPtr, LZ4_streamPtr,
@ -429,9 +429,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_limitedOutput_continue(
LZ4_streamPtr: *mut lz4::LZ4_stream_t, LZ4_streamPtr: *mut lz4::LZ4_stream_t,
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int, inputSize: c_int,
maxOutputSize: c_int maxOutputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_limitedOutput_continue( lz4::LZ4_compress_limitedOutput_continue(
LZ4_streamPtr, LZ4_streamPtr,
@ -446,8 +446,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_limitedOutput_continue(
pub unsafe extern "C" fn csbindgen_LZ4_uncompress( pub unsafe extern "C" fn csbindgen_LZ4_uncompress(
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
outputSize: c_int outputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_uncompress( lz4::LZ4_uncompress(
source, source,
@ -460,9 +460,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_uncompress(
pub unsafe extern "C" fn csbindgen_LZ4_uncompress_unknownOutputSize( pub unsafe extern "C" fn csbindgen_LZ4_uncompress_unknownOutputSize(
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
isize_: c_int, isize_: c_int,
maxOutputSize: c_int maxOutputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_uncompress_unknownOutputSize( lz4::LZ4_uncompress_unknownOutputSize(
source, source,
@ -485,7 +485,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_create(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_sizeofStreamState( pub unsafe extern "C" fn csbindgen_LZ4_sizeofStreamState(
) -> c_int ) -> c_int
{ {
lz4::LZ4_sizeofStreamState( lz4::LZ4_sizeofStreamState(
@ -496,7 +496,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_sizeofStreamState(
pub unsafe extern "C" fn csbindgen_LZ4_resetStreamState( pub unsafe extern "C" fn csbindgen_LZ4_resetStreamState(
state: *mut c_void, state: *mut c_void,
inputBuffer: *mut c_char inputBuffer: *mut c_char
) -> c_int ) -> c_int
{ {
lz4::LZ4_resetStreamState( lz4::LZ4_resetStreamState(
state, state,
@ -518,9 +518,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_slideInputBuffer(
pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_withPrefix64k( pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_withPrefix64k(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
compressedSize: c_int, compressedSize: c_int,
maxDstSize: c_int maxDstSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_decompress_safe_withPrefix64k( lz4::LZ4_decompress_safe_withPrefix64k(
src, src,
@ -534,8 +534,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_decompress_safe_withPrefix64k(
pub unsafe extern "C" fn csbindgen_LZ4_decompress_fast_withPrefix64k( pub unsafe extern "C" fn csbindgen_LZ4_decompress_fast_withPrefix64k(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
originalSize: c_int originalSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_decompress_fast_withPrefix64k( lz4::LZ4_decompress_fast_withPrefix64k(
src, src,
@ -548,8 +548,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_decompress_fast_withPrefix64k(
pub unsafe extern "C" fn csbindgen_LZ4_decompress_fast( pub unsafe extern "C" fn csbindgen_LZ4_decompress_fast(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
originalSize: c_int originalSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_decompress_fast( lz4::LZ4_decompress_fast(
src, src,
@ -563,8 +563,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_decompress_fast_continue(
LZ4_streamDecode: *mut lz4::LZ4_streamDecode_t, LZ4_streamDecode: *mut lz4::LZ4_streamDecode_t,
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
originalSize: c_int originalSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_decompress_fast_continue( lz4::LZ4_decompress_fast_continue(
LZ4_streamDecode, LZ4_streamDecode,
@ -578,10 +578,10 @@ pub unsafe extern "C" fn csbindgen_LZ4_decompress_fast_continue(
pub unsafe extern "C" fn csbindgen_LZ4_decompress_fast_usingDict( pub unsafe extern "C" fn csbindgen_LZ4_decompress_fast_usingDict(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
originalSize: c_int, originalSize: c_int,
dictStart: *const c_char, dictStart: *const c_char,
dictSize: c_int dictSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_decompress_fast_usingDict( lz4::LZ4_decompress_fast_usingDict(
src, src,
@ -606,10 +606,10 @@ pub unsafe extern "C" fn csbindgen_LZ4_resetStream(
pub unsafe extern "C" fn csbindgen_LZ4_compress_HC( pub unsafe extern "C" fn csbindgen_LZ4_compress_HC(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSize: c_int, srcSize: c_int,
dstCapacity: c_int, dstCapacity: c_int,
compressionLevel: c_int compressionLevel: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_HC( lz4::LZ4_compress_HC(
src, src,
@ -623,7 +623,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_HC(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_sizeofStateHC( pub unsafe extern "C" fn csbindgen_LZ4_sizeofStateHC(
) -> c_int ) -> c_int
{ {
lz4::LZ4_sizeofStateHC( lz4::LZ4_sizeofStateHC(
@ -635,10 +635,10 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_HC_extStateHC(
stateHC: *mut c_void, stateHC: *mut c_void,
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSize: c_int, srcSize: c_int,
maxDstSize: c_int, maxDstSize: c_int,
compressionLevel: c_int compressionLevel: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_HC_extStateHC( lz4::LZ4_compress_HC_extStateHC(
stateHC, stateHC,
@ -656,9 +656,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_HC_destSize(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSizePtr: *mut c_int, srcSizePtr: *mut c_int,
targetDstSize: c_int, targetDstSize: c_int,
compressionLevel: c_int compressionLevel: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_HC_destSize( lz4::LZ4_compress_HC_destSize(
stateHC, stateHC,
@ -683,7 +683,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_createStreamHC(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_freeStreamHC( pub unsafe extern "C" fn csbindgen_LZ4_freeStreamHC(
streamHCPtr: *mut lz4::LZ4_streamHC_t streamHCPtr: *mut lz4::LZ4_streamHC_t
) -> c_int ) -> c_int
{ {
lz4::LZ4_freeStreamHC( lz4::LZ4_freeStreamHC(
streamHCPtr streamHCPtr
@ -693,7 +693,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_freeStreamHC(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_resetStreamHC_fast( pub unsafe extern "C" fn csbindgen_LZ4_resetStreamHC_fast(
streamHCPtr: *mut lz4::LZ4_streamHC_t, streamHCPtr: *mut lz4::LZ4_streamHC_t,
compressionLevel: c_int compressionLevel: c_int
) )
{ {
lz4::LZ4_resetStreamHC_fast( lz4::LZ4_resetStreamHC_fast(
@ -706,8 +706,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_resetStreamHC_fast(
pub unsafe extern "C" fn csbindgen_LZ4_loadDictHC( pub unsafe extern "C" fn csbindgen_LZ4_loadDictHC(
streamHCPtr: *mut lz4::LZ4_streamHC_t, streamHCPtr: *mut lz4::LZ4_streamHC_t,
dictionary: *const c_char, dictionary: *const c_char,
dictSize: c_int dictSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_loadDictHC( lz4::LZ4_loadDictHC(
streamHCPtr, streamHCPtr,
@ -721,9 +721,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_HC_continue(
streamHCPtr: *mut lz4::LZ4_streamHC_t, streamHCPtr: *mut lz4::LZ4_streamHC_t,
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSize: c_int, srcSize: c_int,
maxDstSize: c_int maxDstSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_HC_continue( lz4::LZ4_compress_HC_continue(
streamHCPtr, streamHCPtr,
@ -740,8 +740,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_HC_continue_destSize(
src: *const c_char, src: *const c_char,
dst: *mut c_char, dst: *mut c_char,
srcSizePtr: *mut c_int, srcSizePtr: *mut c_int,
targetDstSize: c_int targetDstSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compress_HC_continue_destSize( lz4::LZ4_compress_HC_continue_destSize(
LZ4_streamHCPtr, LZ4_streamHCPtr,
@ -756,8 +756,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_compress_HC_continue_destSize(
pub unsafe extern "C" fn csbindgen_LZ4_saveDictHC( pub unsafe extern "C" fn csbindgen_LZ4_saveDictHC(
streamHCPtr: *mut lz4::LZ4_streamHC_t, streamHCPtr: *mut lz4::LZ4_streamHC_t,
safeBuffer: *mut c_char, safeBuffer: *mut c_char,
maxDictSize: c_int maxDictSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_saveDictHC( lz4::LZ4_saveDictHC(
streamHCPtr, streamHCPtr,
@ -769,7 +769,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_saveDictHC(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_initStreamHC( pub unsafe extern "C" fn csbindgen_LZ4_initStreamHC(
buffer: *mut c_void, buffer: *mut c_void,
size: usize size: usize
) -> *mut lz4::LZ4_streamHC_t ) -> *mut lz4::LZ4_streamHC_t
{ {
lz4::LZ4_initStreamHC( lz4::LZ4_initStreamHC(
@ -782,8 +782,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_initStreamHC(
pub unsafe extern "C" fn csbindgen_LZ4_compressHC( pub unsafe extern "C" fn csbindgen_LZ4_compressHC(
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int inputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressHC( lz4::LZ4_compressHC(
source, source,
@ -796,9 +796,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressHC(
pub unsafe extern "C" fn csbindgen_LZ4_compressHC_limitedOutput( pub unsafe extern "C" fn csbindgen_LZ4_compressHC_limitedOutput(
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int, inputSize: c_int,
maxOutputSize: c_int maxOutputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressHC_limitedOutput( lz4::LZ4_compressHC_limitedOutput(
source, source,
@ -812,9 +812,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressHC_limitedOutput(
pub unsafe extern "C" fn csbindgen_LZ4_compressHC2( pub unsafe extern "C" fn csbindgen_LZ4_compressHC2(
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int, inputSize: c_int,
compressionLevel: c_int compressionLevel: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressHC2( lz4::LZ4_compressHC2(
source, source,
@ -828,10 +828,10 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressHC2(
pub unsafe extern "C" fn csbindgen_LZ4_compressHC2_limitedOutput( pub unsafe extern "C" fn csbindgen_LZ4_compressHC2_limitedOutput(
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int, inputSize: c_int,
maxOutputSize: c_int, maxOutputSize: c_int,
compressionLevel: c_int compressionLevel: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressHC2_limitedOutput( lz4::LZ4_compressHC2_limitedOutput(
source, source,
@ -847,8 +847,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressHC_withStateHC(
state: *mut c_void, state: *mut c_void,
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int inputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressHC_withStateHC( lz4::LZ4_compressHC_withStateHC(
state, state,
@ -863,9 +863,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressHC_limitedOutput_withStateHC(
state: *mut c_void, state: *mut c_void,
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int, inputSize: c_int,
maxOutputSize: c_int maxOutputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressHC_limitedOutput_withStateHC( lz4::LZ4_compressHC_limitedOutput_withStateHC(
state, state,
@ -881,9 +881,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressHC2_withStateHC(
state: *mut c_void, state: *mut c_void,
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int, inputSize: c_int,
compressionLevel: c_int compressionLevel: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressHC2_withStateHC( lz4::LZ4_compressHC2_withStateHC(
state, state,
@ -899,10 +899,10 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressHC2_limitedOutput_withStateHC(
state: *mut c_void, state: *mut c_void,
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int, inputSize: c_int,
maxOutputSize: c_int, maxOutputSize: c_int,
compressionLevel: c_int compressionLevel: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressHC2_limitedOutput_withStateHC( lz4::LZ4_compressHC2_limitedOutput_withStateHC(
state, state,
@ -919,8 +919,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressHC_continue(
LZ4_streamHCPtr: *mut lz4::LZ4_streamHC_t, LZ4_streamHCPtr: *mut lz4::LZ4_streamHC_t,
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int inputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressHC_continue( lz4::LZ4_compressHC_continue(
LZ4_streamHCPtr, LZ4_streamHCPtr,
@ -935,9 +935,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressHC_limitedOutput_continue(
LZ4_streamHCPtr: *mut lz4::LZ4_streamHC_t, LZ4_streamHCPtr: *mut lz4::LZ4_streamHC_t,
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int, inputSize: c_int,
maxOutputSize: c_int maxOutputSize: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressHC_limitedOutput_continue( lz4::LZ4_compressHC_limitedOutput_continue(
LZ4_streamHCPtr, LZ4_streamHCPtr,
@ -961,7 +961,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_createHC(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_freeHC( pub unsafe extern "C" fn csbindgen_LZ4_freeHC(
LZ4HC_Data: *mut c_void LZ4HC_Data: *mut c_void
) -> c_int ) -> c_int
{ {
lz4::LZ4_freeHC( lz4::LZ4_freeHC(
LZ4HC_Data LZ4HC_Data
@ -983,9 +983,9 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressHC2_continue(
LZ4HC_Data: *mut c_void, LZ4HC_Data: *mut c_void,
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int, inputSize: c_int,
compressionLevel: c_int compressionLevel: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressHC2_continue( lz4::LZ4_compressHC2_continue(
LZ4HC_Data, LZ4HC_Data,
@ -1001,10 +1001,10 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressHC2_limitedOutput_continue(
LZ4HC_Data: *mut c_void, LZ4HC_Data: *mut c_void,
source: *const c_char, source: *const c_char,
dest: *mut c_char, dest: *mut c_char,
inputSize: c_int, inputSize: c_int,
maxOutputSize: c_int, maxOutputSize: c_int,
compressionLevel: c_int compressionLevel: c_int
) -> c_int ) -> c_int
{ {
lz4::LZ4_compressHC2_limitedOutput_continue( lz4::LZ4_compressHC2_limitedOutput_continue(
LZ4HC_Data, LZ4HC_Data,
@ -1019,7 +1019,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_compressHC2_limitedOutput_continue(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_sizeofStreamStateHC( pub unsafe extern "C" fn csbindgen_LZ4_sizeofStreamStateHC(
) -> c_int ) -> c_int
{ {
lz4::LZ4_sizeofStreamStateHC( lz4::LZ4_sizeofStreamStateHC(
@ -1030,7 +1030,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_sizeofStreamStateHC(
pub unsafe extern "C" fn csbindgen_LZ4_resetStreamStateHC( pub unsafe extern "C" fn csbindgen_LZ4_resetStreamStateHC(
state: *mut c_void, state: *mut c_void,
inputBuffer: *mut c_char inputBuffer: *mut c_char
) -> c_int ) -> c_int
{ {
lz4::LZ4_resetStreamStateHC( lz4::LZ4_resetStreamStateHC(
state, state,
@ -1041,7 +1041,7 @@ pub unsafe extern "C" fn csbindgen_LZ4_resetStreamStateHC(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4_resetStreamHC( pub unsafe extern "C" fn csbindgen_LZ4_resetStreamHC(
streamHCPtr: *mut lz4::LZ4_streamHC_t, streamHCPtr: *mut lz4::LZ4_streamHC_t,
compressionLevel: c_int compressionLevel: c_int
) )
{ {
lz4::LZ4_resetStreamHC( lz4::LZ4_resetStreamHC(
@ -1052,8 +1052,8 @@ pub unsafe extern "C" fn csbindgen_LZ4_resetStreamHC(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4F_isError( pub unsafe extern "C" fn csbindgen_LZ4F_isError(
code: lz4::LZ4F_errorCode_t code: lz4::LZ4F_errorCode_t
) -> c_uint ) -> c_uint
{ {
lz4::LZ4F_isError( lz4::LZ4F_isError(
code code
@ -1062,7 +1062,7 @@ pub unsafe extern "C" fn csbindgen_LZ4F_isError(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4F_getErrorName( pub unsafe extern "C" fn csbindgen_LZ4F_getErrorName(
code: lz4::LZ4F_errorCode_t code: lz4::LZ4F_errorCode_t
) -> *const c_char ) -> *const c_char
{ {
lz4::LZ4F_getErrorName( lz4::LZ4F_getErrorName(
@ -1073,7 +1073,7 @@ pub unsafe extern "C" fn csbindgen_LZ4F_getErrorName(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4F_compressionLevel_max( pub unsafe extern "C" fn csbindgen_LZ4F_compressionLevel_max(
) -> c_int ) -> c_int
{ {
lz4::LZ4F_compressionLevel_max( lz4::LZ4F_compressionLevel_max(
@ -1082,9 +1082,9 @@ pub unsafe extern "C" fn csbindgen_LZ4F_compressionLevel_max(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4F_compressFrameBound( pub unsafe extern "C" fn csbindgen_LZ4F_compressFrameBound(
srcSize: usize, srcSize: usize,
preferencesPtr: *const lz4::LZ4F_preferences_t preferencesPtr: *const lz4::LZ4F_preferences_t
) -> usize ) -> usize
{ {
lz4::LZ4F_compressFrameBound( lz4::LZ4F_compressFrameBound(
srcSize, srcSize,
@ -1095,11 +1095,11 @@ pub unsafe extern "C" fn csbindgen_LZ4F_compressFrameBound(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4F_compressFrame( pub unsafe extern "C" fn csbindgen_LZ4F_compressFrame(
dstBuffer: *mut c_void, dstBuffer: *mut c_void,
dstCapacity: usize, dstCapacity: usize,
srcBuffer: *const c_void, srcBuffer: *const c_void,
srcSize: usize, srcSize: usize,
preferencesPtr: *const lz4::LZ4F_preferences_t preferencesPtr: *const lz4::LZ4F_preferences_t
) -> usize ) -> usize
{ {
lz4::LZ4F_compressFrame( lz4::LZ4F_compressFrame(
dstBuffer, dstBuffer,
@ -1113,7 +1113,7 @@ pub unsafe extern "C" fn csbindgen_LZ4F_compressFrame(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4F_getVersion( pub unsafe extern "C" fn csbindgen_LZ4F_getVersion(
) -> c_uint ) -> c_uint
{ {
lz4::LZ4F_getVersion( lz4::LZ4F_getVersion(
@ -1123,8 +1123,8 @@ pub unsafe extern "C" fn csbindgen_LZ4F_getVersion(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4F_createCompressionContext( pub unsafe extern "C" fn csbindgen_LZ4F_createCompressionContext(
cctxPtr: *mut *mut lz4::LZ4F_cctx, cctxPtr: *mut *mut lz4::LZ4F_cctx,
version: c_uint version: c_uint
) -> lz4::LZ4F_errorCode_t ) -> lz4::LZ4F_errorCode_t
{ {
lz4::LZ4F_createCompressionContext( lz4::LZ4F_createCompressionContext(
cctxPtr, cctxPtr,
@ -1135,7 +1135,7 @@ pub unsafe extern "C" fn csbindgen_LZ4F_createCompressionContext(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4F_freeCompressionContext( pub unsafe extern "C" fn csbindgen_LZ4F_freeCompressionContext(
cctx: *mut lz4::LZ4F_cctx cctx: *mut lz4::LZ4F_cctx
) -> lz4::LZ4F_errorCode_t ) -> lz4::LZ4F_errorCode_t
{ {
lz4::LZ4F_freeCompressionContext( lz4::LZ4F_freeCompressionContext(
cctx cctx
@ -1146,9 +1146,9 @@ pub unsafe extern "C" fn csbindgen_LZ4F_freeCompressionContext(
pub unsafe extern "C" fn csbindgen_LZ4F_compressBegin( pub unsafe extern "C" fn csbindgen_LZ4F_compressBegin(
cctx: *mut lz4::LZ4F_cctx, cctx: *mut lz4::LZ4F_cctx,
dstBuffer: *mut c_void, dstBuffer: *mut c_void,
dstCapacity: usize, dstCapacity: usize,
prefsPtr: *const lz4::LZ4F_preferences_t prefsPtr: *const lz4::LZ4F_preferences_t
) -> usize ) -> usize
{ {
lz4::LZ4F_compressBegin( lz4::LZ4F_compressBegin(
cctx, cctx,
@ -1160,9 +1160,9 @@ pub unsafe extern "C" fn csbindgen_LZ4F_compressBegin(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4F_compressBound( pub unsafe extern "C" fn csbindgen_LZ4F_compressBound(
srcSize: usize, srcSize: usize,
prefsPtr: *const lz4::LZ4F_preferences_t prefsPtr: *const lz4::LZ4F_preferences_t
) -> usize ) -> usize
{ {
lz4::LZ4F_compressBound( lz4::LZ4F_compressBound(
srcSize, srcSize,
@ -1174,11 +1174,11 @@ pub unsafe extern "C" fn csbindgen_LZ4F_compressBound(
pub unsafe extern "C" fn csbindgen_LZ4F_compressUpdate( pub unsafe extern "C" fn csbindgen_LZ4F_compressUpdate(
cctx: *mut lz4::LZ4F_cctx, cctx: *mut lz4::LZ4F_cctx,
dstBuffer: *mut c_void, dstBuffer: *mut c_void,
dstCapacity: usize, dstCapacity: usize,
srcBuffer: *const c_void, srcBuffer: *const c_void,
srcSize: usize, srcSize: usize,
cOptPtr: *const lz4::LZ4F_compressOptions_t cOptPtr: *const lz4::LZ4F_compressOptions_t
) -> usize ) -> usize
{ {
lz4::LZ4F_compressUpdate( lz4::LZ4F_compressUpdate(
cctx, cctx,
@ -1194,9 +1194,9 @@ pub unsafe extern "C" fn csbindgen_LZ4F_compressUpdate(
pub unsafe extern "C" fn csbindgen_LZ4F_flush( pub unsafe extern "C" fn csbindgen_LZ4F_flush(
cctx: *mut lz4::LZ4F_cctx, cctx: *mut lz4::LZ4F_cctx,
dstBuffer: *mut c_void, dstBuffer: *mut c_void,
dstCapacity: usize, dstCapacity: usize,
cOptPtr: *const lz4::LZ4F_compressOptions_t cOptPtr: *const lz4::LZ4F_compressOptions_t
) -> usize ) -> usize
{ {
lz4::LZ4F_flush( lz4::LZ4F_flush(
cctx, cctx,
@ -1210,9 +1210,9 @@ pub unsafe extern "C" fn csbindgen_LZ4F_flush(
pub unsafe extern "C" fn csbindgen_LZ4F_compressEnd( pub unsafe extern "C" fn csbindgen_LZ4F_compressEnd(
cctx: *mut lz4::LZ4F_cctx, cctx: *mut lz4::LZ4F_cctx,
dstBuffer: *mut c_void, dstBuffer: *mut c_void,
dstCapacity: usize, dstCapacity: usize,
cOptPtr: *const lz4::LZ4F_compressOptions_t cOptPtr: *const lz4::LZ4F_compressOptions_t
) -> usize ) -> usize
{ {
lz4::LZ4F_compressEnd( lz4::LZ4F_compressEnd(
cctx, cctx,
@ -1225,8 +1225,8 @@ pub unsafe extern "C" fn csbindgen_LZ4F_compressEnd(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4F_createDecompressionContext( pub unsafe extern "C" fn csbindgen_LZ4F_createDecompressionContext(
dctxPtr: *mut *mut lz4::LZ4F_dctx, dctxPtr: *mut *mut lz4::LZ4F_dctx,
version: c_uint version: c_uint
) -> lz4::LZ4F_errorCode_t ) -> lz4::LZ4F_errorCode_t
{ {
lz4::LZ4F_createDecompressionContext( lz4::LZ4F_createDecompressionContext(
dctxPtr, dctxPtr,
@ -1237,7 +1237,7 @@ pub unsafe extern "C" fn csbindgen_LZ4F_createDecompressionContext(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4F_freeDecompressionContext( pub unsafe extern "C" fn csbindgen_LZ4F_freeDecompressionContext(
dctx: *mut lz4::LZ4F_dctx dctx: *mut lz4::LZ4F_dctx
) -> lz4::LZ4F_errorCode_t ) -> lz4::LZ4F_errorCode_t
{ {
lz4::LZ4F_freeDecompressionContext( lz4::LZ4F_freeDecompressionContext(
dctx dctx
@ -1247,8 +1247,8 @@ pub unsafe extern "C" fn csbindgen_LZ4F_freeDecompressionContext(
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn csbindgen_LZ4F_headerSize( pub unsafe extern "C" fn csbindgen_LZ4F_headerSize(
src: *const c_void, src: *const c_void,
srcSize: usize srcSize: usize
) -> usize ) -> usize
{ {
lz4::LZ4F_headerSize( lz4::LZ4F_headerSize(
src, src,
@ -1262,7 +1262,7 @@ pub unsafe extern "C" fn csbindgen_LZ4F_getFrameInfo(
frameInfoPtr: *mut lz4::LZ4F_frameInfo_t, frameInfoPtr: *mut lz4::LZ4F_frameInfo_t,
srcBuffer: *const c_void, srcBuffer: *const c_void,
srcSizePtr: *mut usize srcSizePtr: *mut usize
) -> usize ) -> usize
{ {
lz4::LZ4F_getFrameInfo( lz4::LZ4F_getFrameInfo(
dctx, dctx,
@ -1280,7 +1280,7 @@ pub unsafe extern "C" fn csbindgen_LZ4F_decompress(
srcBuffer: *const c_void, srcBuffer: *const c_void,
srcSizePtr: *mut usize, srcSizePtr: *mut usize,
dOptPtr: *const lz4::LZ4F_decompressOptions_t dOptPtr: *const lz4::LZ4F_decompressOptions_t
) -> usize ) -> usize
{ {
lz4::LZ4F_decompress( lz4::LZ4F_decompress(
dctx, dctx,

View File

@ -170,8 +170,8 @@ pub fn emit_csharp(
structs_string structs_string
.push_str(format!(" {}public {} {}", attr, type_name, field.name).as_str()); .push_str(format!(" {}public {} {}", attr, type_name, field.name).as_str());
if field.rust_type.is_fixed_array { if let TypeKind::FixedArray(digits, _) = &field.rust_type.type_kind {
let mut digits = field.rust_type.fixed_array_digits.clone(); let mut digits = digits.clone();
if digits == "0" { if digits == "0" {
digits = "1".to_string(); // 0 fixed array is not allowed in C# digits = "1".to_string(); // 0 fixed array is not allowed in C#
}; };

View File

@ -1,5 +1,7 @@
use crate::{builder::BindgenOptions, type_meta::*}; use crate::{builder::BindgenOptions, type_meta::*};
use std::collections::{HashMap, HashSet}; use std::{
collections::{HashMap, HashSet},
};
use syn::{ForeignItem, Item, Pat, ReturnType}; use syn::{ForeignItem, Item, Pat, ReturnType};
enum FnItem { enum FnItem {
@ -65,7 +67,7 @@ fn parse_method(item: FnItem, options: &BindgenOptions) -> Option<ExternMethod>
} }
let rust_type = parse_type(&t.ty); let rust_type = parse_type(&t.ty);
if rust_type.type_name.is_empty(){ if rust_type.type_name.is_empty() {
println!("Csbindgen can't handle this parameter type so ignore generate, method_name: {} parameter_name: {}", method_name, parameter_name); println!("Csbindgen can't handle this parameter type so ignore generate, method_name: {} parameter_name: {}", method_name, parameter_name);
return None; return None;
} }
@ -81,7 +83,10 @@ fn parse_method(item: FnItem, options: &BindgenOptions) -> Option<ExternMethod>
if let ReturnType::Type(_, b) = &sig.output { if let ReturnType::Type(_, b) = &sig.output {
let rust_type = parse_type(b); let rust_type = parse_type(b);
if rust_type.type_name.is_empty() { if rust_type.type_name.is_empty() {
println!("Csbindgen can't handle this return type so ignore generate, method_name: {}", method_name); println!(
"Csbindgen can't handle this return type so ignore generate, method_name: {}",
method_name
);
return None; return None;
} }
@ -114,14 +119,9 @@ pub fn collect_type_alias(ast: &syn::File) -> Vec<(String, RustType)> {
result.push(( result.push((
name, name,
RustType { RustType {
is_const: false,
is_fixed_array: false,
is_mut: false,
is_pointer: false,
is_pointer_pointer: false,
fixed_array_digits: "".to_string(),
type_name: alias.to_string(), type_name: alias.to_string(),
}, type_kind: TypeKind::Normal
}
)); ));
} }
} }
@ -209,59 +209,62 @@ pub fn reduce_struct(structs: &Vec<RustStruct>, using_types: &HashSet<String>) -
} }
fn parse_type(t: &syn::Type) -> RustType { fn parse_type(t: &syn::Type) -> RustType {
let mut has_star = false; match t {
let mut has_star_star = false;
let mut has_const = false;
let mut has_mut = false;
let mut digits: String = "".to_string();
let name = match t {
syn::Type::Ptr(t) => { syn::Type::Ptr(t) => {
has_star = true; let has_const = t.const_token.is_some();
has_const = t.const_token.is_some(); // let has_mut = t.mutability.is_some();
has_mut = t.mutability.is_some();
if let syn::Type::Path(path) = &*t.elem { if let syn::Type::Path(path) = &*t.elem {
path.path.segments.last().unwrap().ident.to_string() return RustType {
type_name: path.path.segments.last().unwrap().ident.to_string(),
type_kind: TypeKind::Pointer(if has_const { PointerType::ConstPointer } else { PointerType::MutPointer })
};
} else if let syn::Type::Ptr(t) = &*t.elem { } else if let syn::Type::Ptr(t) = &*t.elem {
has_star = false;
has_star_star = true;
if let syn::Type::Path(path) = &*t.elem { if let syn::Type::Path(path) = &*t.elem {
path.path.segments.last().unwrap().ident.to_string() return RustType {
} else { type_name: path.path.segments.last().unwrap().ident.to_string(),
"".to_string() type_kind: TypeKind::Pointer(if has_const { PointerType::ConstPointerPointer } else { PointerType::MutPointerPointer })
};
} }
} else { }
"".to_string() }
} syn::Type::Path(t) => {
return RustType{
type_name:t.path.segments.last().unwrap().ident.to_string(),
type_kind: TypeKind::Normal
}
} }
syn::Type::Path(t) => t.path.segments.last().unwrap().ident.to_string(),
syn::Type::Array(t) => { syn::Type::Array(t) => {
let mut digits = "".to_string();
if let syn::Expr::Lit(x) = &t.len { if let syn::Expr::Lit(x) = &t.len {
if let syn::Lit::Int(x) = &x.lit { if let syn::Lit::Int(x) = &x.lit {
digits = x.base10_digits().to_string(); digits = x.base10_digits().to_string();
} }
}; };
parse_type(&t.elem).type_name // maybe ok, only retrieve type_name let type_name = parse_type(&t.elem).type_name; // maybe ok, only retrieve type_name
return RustType {
type_name,
type_kind: TypeKind::FixedArray(digits, None),
};
} }
syn::Type::Tuple(t) => { syn::Type::Tuple(t) => {
if t.elems.len() == 0 { if t.elems.len() == 0 {
"()".to_string() return RustType {
} else { type_name: "()".to_string(),
"".to_string() type_kind: TypeKind::Normal,
} };
};
} }
_ => "".to_string(), syn::Type::BareFn(_) => {
//todo!();
}
_ => {}
}; };
// type_name = "" will ignore in collect method
RustType { RustType {
is_const: has_const, type_name: "".to_string(),
is_mut: has_mut, type_kind: TypeKind::Normal,
is_pointer: has_star,
is_pointer_pointer: has_star_star,
is_fixed_array: !digits.is_empty(),
type_name: name,
fixed_array_digits: digits,
} }
} }

View File

@ -41,54 +41,49 @@ pub struct ExternMethod {
pub return_type: Option<RustType>, pub return_type: Option<RustType>,
} }
#[derive(Clone, Debug, PartialEq, Eq, Hash)] #[derive(Clone, Debug)]
pub struct RustType { pub struct RustType {
pub type_name: String, pub type_name: String,
pub is_pointer: bool, pub type_kind: TypeKind,
pub is_pointer_pointer: bool, }
pub is_const: bool,
pub is_mut: bool, #[derive(Clone, Debug)]
pub is_fixed_array: bool, pub enum TypeKind {
pub fixed_array_digits: String, Normal,
Pointer(PointerType),
FixedArray(String, Option<PointerType>), // digits
Function(Vec<RustType>, Option<Box<RustType>>), // parameter, return
}
#[derive(Clone, Debug)]
pub enum PointerType {
ConstPointer,
MutPointer,
ConstPointerPointer,
MutPointerPointer,
} }
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct RustStruct { pub struct RustStruct {
pub struct_name: String, pub struct_name: String,
pub fields: Vec<FieldMember>, pub fields: Vec<FieldMember>,
pub is_union: bool pub is_union: bool,
} }
impl RustType { impl RustType {
pub fn to_string(&self, type_path: &str) -> String { pub fn to_string(&self, type_path: &str) -> String {
let mut sb = String::new(); let mut sb = String::new();
if self.is_pointer || self.is_pointer_pointer { fn emit_pointer(sb: &mut String, p: &PointerType) {
sb.push('*'); match p {
} ConstPointer => sb.push_str("*const"),
if self.is_const { MutPointer => sb.push_str("*mut"),
sb.push_str("const"); ConstPointerPointer => sb.push_str("*const *const"),
} MutPointerPointer => sb.push_str("*mut *mut"),
if self.is_mut { };
sb.push_str("mut");
}
if self.is_pointer_pointer {
if self.is_const {
sb.push_str(" *const");
} else {
sb.push_str(" *mut");
}
} }
sb.push(' '); let emit_type_name = |sb: &mut String| {
if self.is_fixed_array {
sb.push('[');
sb.push_str(self.type_name.as_str());
sb.push_str("; ");
sb.push_str(self.fixed_array_digits.as_str());
sb.push(']');
} else {
if !(self.type_name.starts_with("c_") if !(self.type_name.starts_with("c_")
|| self.type_name == "usize" || self.type_name == "usize"
|| self.type_name == "isize" || self.type_name == "isize"
@ -98,7 +93,35 @@ impl RustType {
sb.push_str("::"); sb.push_str("::");
} }
sb.push_str(self.type_name.as_str()); sb.push_str(self.type_name.as_str());
} };
use PointerType::*;
use TypeKind::*;
match &self.type_kind {
Normal => {
emit_type_name(&mut sb);
}
Pointer(p) => {
emit_pointer(&mut sb, p);
sb.push(' ');
emit_type_name(&mut sb);
}
FixedArray(digits, pointer) => {
if let Some(p) = pointer {
emit_pointer(&mut sb, p);
sb.push(' ');
}
sb.push('[');
emit_type_name(&mut sb);
sb.push_str("; ");
sb.push_str(digits.as_str());
sb.push(']');
}
Function(x, y) => {
todo!();
}
};
sb sb
} }
@ -157,36 +180,48 @@ impl RustType {
let mut sb = String::new(); let mut sb = String::new();
if self.is_fixed_array { match self.type_kind {
sb.push_str("fixed "); TypeKind::FixedArray(_, _) => {
sb.push_str("fixed ");
let type_name = convert_type_name(use_type.type_name.as_str(), options); let type_name = convert_type_name(use_type.type_name.as_str(), options);
let type_name = match type_name.as_str() { let type_name = match type_name.as_str() {
// C# fixed allow types // C# fixed allow types
"bool" | "byte" | "short" | "int" | "long" | "char" | "sbyte" | "ushort" "bool" | "byte" | "short" | "int" | "long" | "char" | "sbyte" | "ushort"
| "uint" | "ulong" | "float" | "double" => type_name, | "uint" | "ulong" | "float" | "double" => type_name,
_ => format!("byte/* {}, this length is invalid so must keep pointer and can't edit from C# */", type_name) _ => format!("byte/* {}, this length is invalid so must keep pointer and can't edit from C# */", type_name)
}; };
sb.push_str(type_name.as_str()); sb.push_str(type_name.as_str());
} else { }
sb.push_str(convert_type_name(use_type.type_name.as_str(), options).as_str()); _ => {
if use_alias { sb.push_str(convert_type_name(use_type.type_name.as_str(), options).as_str());
if use_type.is_pointer {
sb.push('*'); if use_alias {
if let TypeKind::Pointer(p) = &use_type.type_kind {
match p {
PointerType::MutPointer | PointerType::ConstPointer => {
sb.push('*');
}
PointerType::MutPointerPointer | PointerType::ConstPointerPointer => {
sb.push_str("**");
}
}
}
} }
if use_type.is_pointer_pointer {
sb.push_str("**"); if let TypeKind::Pointer(p) = &self.type_kind {
match p {
PointerType::MutPointer | PointerType::ConstPointer => {
sb.push('*');
}
PointerType::MutPointerPointer | PointerType::ConstPointerPointer => {
sb.push_str("**");
}
}
} }
} }
};
if self.is_pointer {
sb.push('*');
}
if self.is_pointer_pointer {
sb.push_str("**");
}
}
sb sb
} }

View File

@ -13,47 +13,54 @@ using System.Text;
unsafe unsafe
{ {
LibRust.call_bindgen(); // LibRust.call_bindgen();
var cString = LibRust.alloc_c_string(); var ctx = LibRust.create_counter_context();
var u8String = LibRust.alloc_u8_string(); LibRust.insert_counter_context(ctx, 10);
var u8Buffer = LibRust.alloc_u8_buffer(); LibRust.insert_counter_context(ctx, 20);
var i32Buffer = LibRust.alloc_i32_buffer(); LibRust.insert_counter_context(ctx, 20);
try LibRust.insert_counter_context(ctx, 30);
{ LibRust.insert_counter_context(ctx, 99);
var str = new String((sbyte*)cString); LibRust.delete_counter_context(ctx);
Console.WriteLine(str);
Console.WriteLine("----"); //var cString = LibRust.alloc_c_string();
//var u8String = LibRust.alloc_u8_string();
//var u8Buffer = LibRust.alloc_u8_buffer();
//var i32Buffer = LibRust.alloc_i32_buffer();
//try
//{
// var str = new String((sbyte*)cString);
// Console.WriteLine(str);
var str2 = Encoding.UTF8.GetString(u8String->AsSpan()); // Console.WriteLine("----");
Console.WriteLine(str2);
Console.WriteLine("----"); // var str2 = Encoding.UTF8.GetString(u8String->AsSpan());
// Console.WriteLine(str2);
var buffer3 = u8Buffer->AsSpan(); // Console.WriteLine("----");
foreach (var item in buffer3)
{
Console.WriteLine(item);
}
Console.WriteLine("----"); // var buffer3 = u8Buffer->AsSpan();
// foreach (var item in buffer3)
// {
// Console.WriteLine(item);
// }
var i32Span = i32Buffer->AsSpan<int>(); // Console.WriteLine("----");
foreach (var item in i32Span)
{ // var i32Span = i32Buffer->AsSpan<int>();
Console.WriteLine(item); // foreach (var item in i32Span)
} // {
} // Console.WriteLine(item);
finally // }
{ //}
LibRust.free_c_string(cString); //finally
LibRust.free_u8_string(u8String); //{
LibRust.free_u8_buffer(u8Buffer); // LibRust.free_c_string(cString);
LibRust.free_i32_buffer(i32Buffer); // LibRust.free_u8_string(u8String);
} // LibRust.free_u8_buffer(u8Buffer);
// LibRust.free_i32_buffer(i32Buffer);
//}
//var buf = LibRust.return_raw_buffer(); //var buf = LibRust.return_raw_buffer();

View File

@ -17,6 +17,15 @@ namespace CsBindgen
[DllImport(__DllName, EntryPoint = "my_add", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "my_add", CallingConvention = CallingConvention.Cdecl)]
public static extern int my_add(int x, int y); public static extern int my_add(int x, int y);
[DllImport(__DllName, EntryPoint = "create_counter_context", CallingConvention = CallingConvention.Cdecl)]
public static extern void* create_counter_context();
[DllImport(__DllName, EntryPoint = "insert_counter_context", CallingConvention = CallingConvention.Cdecl)]
public static extern void insert_counter_context(void* context, int value);
[DllImport(__DllName, EntryPoint = "delete_counter_context", CallingConvention = CallingConvention.Cdecl)]
public static extern void delete_counter_context(void* context);
[DllImport(__DllName, EntryPoint = "my_bool", CallingConvention = CallingConvention.Cdecl)] [DllImport(__DllName, EntryPoint = "my_bool", CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.U1)] [return: MarshalAs(UnmanagedType.U1)]
public static extern bool my_bool([MarshalAs(UnmanagedType.U1)] bool x, [MarshalAs(UnmanagedType.U1)] bool y, [MarshalAs(UnmanagedType.U1)] bool z, bool* xr, bool* yr, bool* zr); public static extern bool my_bool([MarshalAs(UnmanagedType.U1)] bool x, [MarshalAs(UnmanagedType.U1)] bool y, [MarshalAs(UnmanagedType.U1)] bool z, bool* xr, bool* yr, bool* zr);