diff --git a/src/bindgen/ir/ty.rs b/src/bindgen/ir/ty.rs index e111559d..4a41d4cf 100644 --- a/src/bindgen/ir/ty.rs +++ b/src/bindgen/ir/ty.rs @@ -417,7 +417,7 @@ impl Type { } syn::Type::BareFn(ref function) => { let mut wildcard_counter = 0; - let args = function.inputs.iter().try_skip_map(|x| { + let mut args = function.inputs.iter().try_skip_map(|x| { Type::load(&x.ty).map(|opt_ty| { opt_ty.map(|ty| { ( @@ -438,6 +438,9 @@ impl Type { }) }) })?; + if function.variadic.is_some() { + args.push((None, Type::Primitive(super::PrimitiveType::VaList))) + } let (ret, never_return) = Type::load_from_output(&function.output)?; Type::FuncPtr { ret: Box::new(ret), diff --git a/tests/expectations/va_list.c b/tests/expectations/va_list.c index 996a9b0d..fb5d8b42 100644 --- a/tests/expectations/va_list.c +++ b/tests/expectations/va_list.c @@ -5,23 +5,19 @@ typedef int32_t (*VaListFnPtr)(int32_t count, ...); -typedef int32_t (*VaListFnPtr2)(int32_t count); +typedef int32_t (*VaListFnPtr2)(int32_t count, ...); typedef struct { int32_t (*fn1)(int32_t count, ...); } Interface_______i32_______i32_______va_list; -typedef struct { - int32_t (*fn1)(int32_t count); -} Interface_______i32_______i32; - int32_t va_list_test(int32_t count, ...); int32_t va_list_test2(int32_t count, ...); void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), - int32_t (*fn2)(int32_t count), + int32_t (*fn2)(int32_t count, ...), VaListFnPtr fn3, VaListFnPtr2 fn4, Interface_______i32_______i32_______va_list fn5, - Interface_______i32_______i32 fn6); + Interface_______i32_______i32_______va_list fn6); diff --git a/tests/expectations/va_list.compat.c b/tests/expectations/va_list.compat.c index 051cded7..d9b9518e 100644 --- a/tests/expectations/va_list.compat.c +++ b/tests/expectations/va_list.compat.c @@ -5,16 +5,12 @@ typedef int32_t (*VaListFnPtr)(int32_t count, ...); -typedef int32_t (*VaListFnPtr2)(int32_t count); +typedef int32_t (*VaListFnPtr2)(int32_t count, ...); typedef struct { int32_t (*fn1)(int32_t count, ...); } Interface_______i32_______i32_______va_list; -typedef struct { - int32_t (*fn1)(int32_t count); -} Interface_______i32_______i32; - #ifdef __cplusplus extern "C" { #endif // __cplusplus @@ -24,11 +20,11 @@ int32_t va_list_test(int32_t count, ...); int32_t va_list_test2(int32_t count, ...); void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), - int32_t (*fn2)(int32_t count), + int32_t (*fn2)(int32_t count, ...), VaListFnPtr fn3, VaListFnPtr2 fn4, Interface_______i32_______i32_______va_list fn5, - Interface_______i32_______i32 fn6); + Interface_______i32_______i32_______va_list fn6); #ifdef __cplusplus } // extern "C" diff --git a/tests/expectations/va_list.cpp b/tests/expectations/va_list.cpp index ff6eac66..86e0d99a 100644 --- a/tests/expectations/va_list.cpp +++ b/tests/expectations/va_list.cpp @@ -6,7 +6,7 @@ using VaListFnPtr = int32_t(*)(int32_t count, ...); -using VaListFnPtr2 = int32_t(*)(int32_t count); +using VaListFnPtr2 = int32_t(*)(int32_t count, ...); template struct Interface { @@ -20,10 +20,10 @@ int32_t va_list_test(int32_t count, ...); int32_t va_list_test2(int32_t count, ...); void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), - int32_t (*fn2)(int32_t count), + int32_t (*fn2)(int32_t count, ...), VaListFnPtr fn3, VaListFnPtr2 fn4, Interface fn5, - Interface fn6); + Interface fn6); } // extern "C" diff --git a/tests/expectations/va_list.pyx b/tests/expectations/va_list.pyx index 5b954841..c0c297c2 100644 --- a/tests/expectations/va_list.pyx +++ b/tests/expectations/va_list.pyx @@ -8,21 +8,18 @@ cdef extern from *: ctypedef int32_t (*VaListFnPtr)(int32_t count, ...); - ctypedef int32_t (*VaListFnPtr2)(int32_t count); + ctypedef int32_t (*VaListFnPtr2)(int32_t count, ...); ctypedef struct Interface_______i32_______i32_______va_list: int32_t (*fn1)(int32_t count, ...); - ctypedef struct Interface_______i32_______i32: - int32_t (*fn1)(int32_t count); - int32_t va_list_test(int32_t count, ...); int32_t va_list_test2(int32_t count, ...); void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), - int32_t (*fn2)(int32_t count), + int32_t (*fn2)(int32_t count, ...), VaListFnPtr fn3, VaListFnPtr2 fn4, Interface_______i32_______i32_______va_list fn5, - Interface_______i32_______i32 fn6); + Interface_______i32_______i32_______va_list fn6); diff --git a/tests/expectations/va_list_both.c b/tests/expectations/va_list_both.c index 6247f51c..a403a5c7 100644 --- a/tests/expectations/va_list_both.c +++ b/tests/expectations/va_list_both.c @@ -5,23 +5,19 @@ typedef int32_t (*VaListFnPtr)(int32_t count, ...); -typedef int32_t (*VaListFnPtr2)(int32_t count); +typedef int32_t (*VaListFnPtr2)(int32_t count, ...); typedef struct Interface_______i32_______i32_______va_list { int32_t (*fn1)(int32_t count, ...); } Interface_______i32_______i32_______va_list; -typedef struct Interface_______i32_______i32 { - int32_t (*fn1)(int32_t count); -} Interface_______i32_______i32; - int32_t va_list_test(int32_t count, ...); int32_t va_list_test2(int32_t count, ...); void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), - int32_t (*fn2)(int32_t count), + int32_t (*fn2)(int32_t count, ...), VaListFnPtr fn3, VaListFnPtr2 fn4, struct Interface_______i32_______i32_______va_list fn5, - struct Interface_______i32_______i32 fn6); + struct Interface_______i32_______i32_______va_list fn6); diff --git a/tests/expectations/va_list_both.compat.c b/tests/expectations/va_list_both.compat.c index cb125089..8c1f898f 100644 --- a/tests/expectations/va_list_both.compat.c +++ b/tests/expectations/va_list_both.compat.c @@ -5,16 +5,12 @@ typedef int32_t (*VaListFnPtr)(int32_t count, ...); -typedef int32_t (*VaListFnPtr2)(int32_t count); +typedef int32_t (*VaListFnPtr2)(int32_t count, ...); typedef struct Interface_______i32_______i32_______va_list { int32_t (*fn1)(int32_t count, ...); } Interface_______i32_______i32_______va_list; -typedef struct Interface_______i32_______i32 { - int32_t (*fn1)(int32_t count); -} Interface_______i32_______i32; - #ifdef __cplusplus extern "C" { #endif // __cplusplus @@ -24,11 +20,11 @@ int32_t va_list_test(int32_t count, ...); int32_t va_list_test2(int32_t count, ...); void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), - int32_t (*fn2)(int32_t count), + int32_t (*fn2)(int32_t count, ...), VaListFnPtr fn3, VaListFnPtr2 fn4, struct Interface_______i32_______i32_______va_list fn5, - struct Interface_______i32_______i32 fn6); + struct Interface_______i32_______i32_______va_list fn6); #ifdef __cplusplus } // extern "C" diff --git a/tests/expectations/va_list_tag.c b/tests/expectations/va_list_tag.c index 3ff119ff..fd488287 100644 --- a/tests/expectations/va_list_tag.c +++ b/tests/expectations/va_list_tag.c @@ -5,23 +5,19 @@ typedef int32_t (*VaListFnPtr)(int32_t count, ...); -typedef int32_t (*VaListFnPtr2)(int32_t count); +typedef int32_t (*VaListFnPtr2)(int32_t count, ...); struct Interface_______i32_______i32_______va_list { int32_t (*fn1)(int32_t count, ...); }; -struct Interface_______i32_______i32 { - int32_t (*fn1)(int32_t count); -}; - int32_t va_list_test(int32_t count, ...); int32_t va_list_test2(int32_t count, ...); void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), - int32_t (*fn2)(int32_t count), + int32_t (*fn2)(int32_t count, ...), VaListFnPtr fn3, VaListFnPtr2 fn4, struct Interface_______i32_______i32_______va_list fn5, - struct Interface_______i32_______i32 fn6); + struct Interface_______i32_______i32_______va_list fn6); diff --git a/tests/expectations/va_list_tag.compat.c b/tests/expectations/va_list_tag.compat.c index 3f8b6b85..2853bfa0 100644 --- a/tests/expectations/va_list_tag.compat.c +++ b/tests/expectations/va_list_tag.compat.c @@ -5,16 +5,12 @@ typedef int32_t (*VaListFnPtr)(int32_t count, ...); -typedef int32_t (*VaListFnPtr2)(int32_t count); +typedef int32_t (*VaListFnPtr2)(int32_t count, ...); struct Interface_______i32_______i32_______va_list { int32_t (*fn1)(int32_t count, ...); }; -struct Interface_______i32_______i32 { - int32_t (*fn1)(int32_t count); -}; - #ifdef __cplusplus extern "C" { #endif // __cplusplus @@ -24,11 +20,11 @@ int32_t va_list_test(int32_t count, ...); int32_t va_list_test2(int32_t count, ...); void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), - int32_t (*fn2)(int32_t count), + int32_t (*fn2)(int32_t count, ...), VaListFnPtr fn3, VaListFnPtr2 fn4, struct Interface_______i32_______i32_______va_list fn5, - struct Interface_______i32_______i32 fn6); + struct Interface_______i32_______i32_______va_list fn6); #ifdef __cplusplus } // extern "C"