From c8546ad42dc70dcc1da305c87cc42118a38567af Mon Sep 17 00:00:00 2001 From: Sjors Holtrop Date: Tue, 3 Jan 2023 19:55:57 +0100 Subject: [PATCH] Parse `...` as a `VaList` --- src/bindgen/ir/ty.rs | 3 +++ tests/expectations/va_list.c | 2 ++ tests/expectations/va_list.compat.c | 2 ++ tests/expectations/va_list.cpp | 2 ++ tests/expectations/va_list.pyx | 2 ++ tests/rust/va_list.rs | 5 +++++ 6 files changed, 16 insertions(+) diff --git a/src/bindgen/ir/ty.rs b/src/bindgen/ir/ty.rs index d51cd63..5a31fb6 100644 --- a/src/bindgen/ir/ty.rs +++ b/src/bindgen/ir/ty.rs @@ -535,6 +535,9 @@ impl Type { } return Err("Tuples are not supported types.".to_owned()); } + syn::Type::Verbatim(ref tokens) if tokens.to_string() == "..." => { + Type::Primitive(PrimitiveType::VaList) + } _ => return Err(format!("Unsupported type: {:?}", ty)), }; diff --git a/tests/expectations/va_list.c b/tests/expectations/va_list.c index 2332c27..d2f9ac3 100644 --- a/tests/expectations/va_list.c +++ b/tests/expectations/va_list.c @@ -4,3 +4,5 @@ #include int32_t va_list_test(va_list ap); + +int32_t va_list_test2(va_list ap); diff --git a/tests/expectations/va_list.compat.c b/tests/expectations/va_list.compat.c index acaae09..bdd8f4b 100644 --- a/tests/expectations/va_list.compat.c +++ b/tests/expectations/va_list.compat.c @@ -9,6 +9,8 @@ extern "C" { int32_t va_list_test(va_list ap); +int32_t va_list_test2(va_list ap); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/va_list.cpp b/tests/expectations/va_list.cpp index 8059074..2a3344b 100644 --- a/tests/expectations/va_list.cpp +++ b/tests/expectations/va_list.cpp @@ -8,4 +8,6 @@ extern "C" { int32_t va_list_test(va_list ap); +int32_t va_list_test2(va_list ap); + } // extern "C" diff --git a/tests/expectations/va_list.pyx b/tests/expectations/va_list.pyx index a692808..4ce0c8d 100644 --- a/tests/expectations/va_list.pyx +++ b/tests/expectations/va_list.pyx @@ -7,3 +7,5 @@ cdef extern from *: cdef extern from *: int32_t va_list_test(va_list ap); + + int32_t va_list_test2(va_list ap); diff --git a/tests/rust/va_list.rs b/tests/rust/va_list.rs index 1016091..13503dd 100644 --- a/tests/rust/va_list.rs +++ b/tests/rust/va_list.rs @@ -4,3 +4,8 @@ use std::ffi::VaList; pub unsafe extern "C" fn va_list_test(mut ap: VaList) -> int32_t { ap.arg() } + +#[no_mangle] +pub unsafe extern "C" fn va_list_test2(mut ap: ...) -> int32_t { + ap.arg() +}