From 1dda6162e53df57cb1769e9a6f942f6de839f50b Mon Sep 17 00:00:00 2001 From: Gerard Ryan Date: Mon, 27 May 2024 14:31:16 +1000 Subject: [PATCH] Used documented method of specifying variadic arguments `va_list` -> `...` * https://en.cppreference.com/w/c/language/variadic * https://en.cppreference.com/w/cpp/language/variadic_arguments --- src/bindgen/ir/function.rs | 6 +++++- src/bindgen/ir/ty.rs | 2 +- tests/expectations/va_list.c | 10 +++++----- tests/expectations/va_list.compat.c | 10 +++++----- tests/expectations/va_list.cpp | 10 +++++----- tests/expectations/va_list.pyx | 10 +++++----- tests/expectations/va_list_both.c | 10 +++++----- tests/expectations/va_list_both.compat.c | 10 +++++----- tests/expectations/va_list_tag.c | 10 +++++----- tests/expectations/va_list_tag.compat.c | 10 +++++----- tests/expectations/va_list_tag.pyx | 10 +++++----- 11 files changed, 51 insertions(+), 47 deletions(-) diff --git a/src/bindgen/ir/function.rs b/src/bindgen/ir/function.rs index ff75df43..2355d166 100644 --- a/src/bindgen/ir/function.rs +++ b/src/bindgen/ir/function.rs @@ -246,7 +246,11 @@ impl SynFnArgHelpers for syn::FnArg { let name = match **pat { syn::Pat::Wild(..) => None, syn::Pat::Ident(syn::PatIdent { ref ident, .. }) => { - Some(ident.unraw().to_string()) + if ty == Type::Primitive(super::PrimitiveType::VaList) { + None + } else { + Some(ident.unraw().to_string()) + } } _ => { return Err(format!( diff --git a/src/bindgen/ir/ty.rs b/src/bindgen/ir/ty.rs index 1f304d2f..e111559d 100644 --- a/src/bindgen/ir/ty.rs +++ b/src/bindgen/ir/ty.rs @@ -218,7 +218,7 @@ impl PrimitiveType { PrimitiveType::Float => "float", PrimitiveType::Double => "double", PrimitiveType::PtrDiffT => "ptrdiff_t", - PrimitiveType::VaList => "va_list", + PrimitiveType::VaList => "...", } } diff --git a/tests/expectations/va_list.c b/tests/expectations/va_list.c index ed1600ba..996a9b0d 100644 --- a/tests/expectations/va_list.c +++ b/tests/expectations/va_list.c @@ -3,23 +3,23 @@ #include #include -typedef int32_t (*VaListFnPtr)(int32_t count, va_list); +typedef int32_t (*VaListFnPtr)(int32_t count, ...); typedef int32_t (*VaListFnPtr2)(int32_t count); typedef struct { - int32_t (*fn1)(int32_t count, va_list); + 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, va_list ap); +int32_t va_list_test(int32_t count, ...); -int32_t va_list_test2(int32_t count, va_list ap); +int32_t va_list_test2(int32_t count, ...); -void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, va_list), +void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), int32_t (*fn2)(int32_t count), VaListFnPtr fn3, VaListFnPtr2 fn4, diff --git a/tests/expectations/va_list.compat.c b/tests/expectations/va_list.compat.c index 17567832..051cded7 100644 --- a/tests/expectations/va_list.compat.c +++ b/tests/expectations/va_list.compat.c @@ -3,12 +3,12 @@ #include #include -typedef int32_t (*VaListFnPtr)(int32_t count, va_list); +typedef int32_t (*VaListFnPtr)(int32_t count, ...); typedef int32_t (*VaListFnPtr2)(int32_t count); typedef struct { - int32_t (*fn1)(int32_t count, va_list); + int32_t (*fn1)(int32_t count, ...); } Interface_______i32_______i32_______va_list; typedef struct { @@ -19,11 +19,11 @@ typedef struct { extern "C" { #endif // __cplusplus -int32_t va_list_test(int32_t count, va_list ap); +int32_t va_list_test(int32_t count, ...); -int32_t va_list_test2(int32_t count, va_list ap); +int32_t va_list_test2(int32_t count, ...); -void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, va_list), +void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), int32_t (*fn2)(int32_t count), VaListFnPtr fn3, VaListFnPtr2 fn4, diff --git a/tests/expectations/va_list.cpp b/tests/expectations/va_list.cpp index 0454deef..ff6eac66 100644 --- a/tests/expectations/va_list.cpp +++ b/tests/expectations/va_list.cpp @@ -4,7 +4,7 @@ #include #include -using VaListFnPtr = int32_t(*)(int32_t count, va_list); +using VaListFnPtr = int32_t(*)(int32_t count, ...); using VaListFnPtr2 = int32_t(*)(int32_t count); @@ -15,15 +15,15 @@ struct Interface { extern "C" { -int32_t va_list_test(int32_t count, va_list ap); +int32_t va_list_test(int32_t count, ...); -int32_t va_list_test2(int32_t count, va_list ap); +int32_t va_list_test2(int32_t count, ...); -void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, va_list), +void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), int32_t (*fn2)(int32_t count), VaListFnPtr fn3, VaListFnPtr2 fn4, - Interface fn5, + Interface fn5, Interface fn6); } // extern "C" diff --git a/tests/expectations/va_list.pyx b/tests/expectations/va_list.pyx index d47324b3..5b954841 100644 --- a/tests/expectations/va_list.pyx +++ b/tests/expectations/va_list.pyx @@ -6,21 +6,21 @@ cdef extern from *: cdef extern from *: - ctypedef int32_t (*VaListFnPtr)(int32_t count, va_list); + ctypedef int32_t (*VaListFnPtr)(int32_t count, ...); ctypedef int32_t (*VaListFnPtr2)(int32_t count); ctypedef struct Interface_______i32_______i32_______va_list: - int32_t (*fn1)(int32_t count, 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, va_list ap); + int32_t va_list_test(int32_t count, ...); - int32_t va_list_test2(int32_t count, va_list ap); + int32_t va_list_test2(int32_t count, ...); - void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, va_list), + void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), int32_t (*fn2)(int32_t count), VaListFnPtr fn3, VaListFnPtr2 fn4, diff --git a/tests/expectations/va_list_both.c b/tests/expectations/va_list_both.c index dfa09789..6247f51c 100644 --- a/tests/expectations/va_list_both.c +++ b/tests/expectations/va_list_both.c @@ -3,23 +3,23 @@ #include #include -typedef int32_t (*VaListFnPtr)(int32_t count, va_list); +typedef int32_t (*VaListFnPtr)(int32_t count, ...); typedef int32_t (*VaListFnPtr2)(int32_t count); typedef struct Interface_______i32_______i32_______va_list { - int32_t (*fn1)(int32_t count, 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, va_list ap); +int32_t va_list_test(int32_t count, ...); -int32_t va_list_test2(int32_t count, va_list ap); +int32_t va_list_test2(int32_t count, ...); -void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, va_list), +void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), int32_t (*fn2)(int32_t count), VaListFnPtr fn3, VaListFnPtr2 fn4, diff --git a/tests/expectations/va_list_both.compat.c b/tests/expectations/va_list_both.compat.c index 50b978de..cb125089 100644 --- a/tests/expectations/va_list_both.compat.c +++ b/tests/expectations/va_list_both.compat.c @@ -3,12 +3,12 @@ #include #include -typedef int32_t (*VaListFnPtr)(int32_t count, va_list); +typedef int32_t (*VaListFnPtr)(int32_t count, ...); typedef int32_t (*VaListFnPtr2)(int32_t count); typedef struct Interface_______i32_______i32_______va_list { - int32_t (*fn1)(int32_t count, va_list); + int32_t (*fn1)(int32_t count, ...); } Interface_______i32_______i32_______va_list; typedef struct Interface_______i32_______i32 { @@ -19,11 +19,11 @@ typedef struct Interface_______i32_______i32 { extern "C" { #endif // __cplusplus -int32_t va_list_test(int32_t count, va_list ap); +int32_t va_list_test(int32_t count, ...); -int32_t va_list_test2(int32_t count, va_list ap); +int32_t va_list_test2(int32_t count, ...); -void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, va_list), +void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), int32_t (*fn2)(int32_t count), VaListFnPtr fn3, VaListFnPtr2 fn4, diff --git a/tests/expectations/va_list_tag.c b/tests/expectations/va_list_tag.c index 90ebaa9d..3ff119ff 100644 --- a/tests/expectations/va_list_tag.c +++ b/tests/expectations/va_list_tag.c @@ -3,23 +3,23 @@ #include #include -typedef int32_t (*VaListFnPtr)(int32_t count, va_list); +typedef int32_t (*VaListFnPtr)(int32_t count, ...); typedef int32_t (*VaListFnPtr2)(int32_t count); struct Interface_______i32_______i32_______va_list { - int32_t (*fn1)(int32_t count, 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, va_list ap); +int32_t va_list_test(int32_t count, ...); -int32_t va_list_test2(int32_t count, va_list ap); +int32_t va_list_test2(int32_t count, ...); -void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, va_list), +void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), int32_t (*fn2)(int32_t count), VaListFnPtr fn3, VaListFnPtr2 fn4, diff --git a/tests/expectations/va_list_tag.compat.c b/tests/expectations/va_list_tag.compat.c index b4fc21c5..3f8b6b85 100644 --- a/tests/expectations/va_list_tag.compat.c +++ b/tests/expectations/va_list_tag.compat.c @@ -3,12 +3,12 @@ #include #include -typedef int32_t (*VaListFnPtr)(int32_t count, va_list); +typedef int32_t (*VaListFnPtr)(int32_t count, ...); typedef int32_t (*VaListFnPtr2)(int32_t count); struct Interface_______i32_______i32_______va_list { - int32_t (*fn1)(int32_t count, va_list); + int32_t (*fn1)(int32_t count, ...); }; struct Interface_______i32_______i32 { @@ -19,11 +19,11 @@ struct Interface_______i32_______i32 { extern "C" { #endif // __cplusplus -int32_t va_list_test(int32_t count, va_list ap); +int32_t va_list_test(int32_t count, ...); -int32_t va_list_test2(int32_t count, va_list ap); +int32_t va_list_test2(int32_t count, ...); -void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, va_list), +void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), int32_t (*fn2)(int32_t count), VaListFnPtr fn3, VaListFnPtr2 fn4, diff --git a/tests/expectations/va_list_tag.pyx b/tests/expectations/va_list_tag.pyx index a21f778c..ad83cee4 100644 --- a/tests/expectations/va_list_tag.pyx +++ b/tests/expectations/va_list_tag.pyx @@ -6,21 +6,21 @@ cdef extern from *: cdef extern from *: - ctypedef int32_t (*VaListFnPtr)(int32_t count, va_list); + ctypedef int32_t (*VaListFnPtr)(int32_t count, ...); ctypedef int32_t (*VaListFnPtr2)(int32_t count); cdef struct Interface_______i32_______i32_______va_list: - int32_t (*fn1)(int32_t count, va_list); + int32_t (*fn1)(int32_t count, ...); cdef struct Interface_______i32_______i32: int32_t (*fn1)(int32_t count); - int32_t va_list_test(int32_t count, va_list ap); + int32_t va_list_test(int32_t count, ...); - int32_t va_list_test2(int32_t count, va_list ap); + int32_t va_list_test2(int32_t count, ...); - void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, va_list), + void va_list_fn_ptrs(int32_t (*fn1)(int32_t count, ...), int32_t (*fn2)(int32_t count), VaListFnPtr fn3, VaListFnPtr2 fn4,