Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap va_list function as variadic function #2502

Merged
merged 6 commits into from
Jun 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add more generic version of fnsig_arguments based on iterator
Urgau committed Jun 5, 2023
commit 60b316d42b77b44fab332f9e2097297aaf058faa
25 changes: 19 additions & 6 deletions bindgen/codegen/mod.rs
Original file line number Diff line number Diff line change
@@ -5260,16 +5260,18 @@ pub(crate) mod utils {
fnsig_return_ty_internal(ctx, sig, /* include_arrow = */ true)
}

pub(crate) fn fnsig_arguments(
pub(crate) fn fnsig_arguments_iter<
'a,
I: Iterator<Item = &'a (Option<String>, crate::ir::context::TypeId)>,
>(
ctx: &BindgenContext,
sig: &FunctionSig,
args_iter: I,
is_variadic: bool,
) -> Vec<proc_macro2::TokenStream> {
use super::ToPtr;

let mut unnamed_arguments = 0;
let mut args = sig
.argument_types()
.iter()
let mut args = args_iter
.map(|&(ref name, ty)| {
let arg_item = ctx.resolve_item(ty);
let arg_ty = arg_item.kind().expect_type();
@@ -5326,13 +5328,24 @@ pub(crate) mod utils {
})
.collect::<Vec<_>>();

if sig.is_variadic() {
if is_variadic {
args.push(quote! { ... })
}

args
}

pub(crate) fn fnsig_arguments(
ctx: &BindgenContext,
sig: &FunctionSig,
) -> Vec<proc_macro2::TokenStream> {
fnsig_arguments_iter(
ctx,
sig.argument_types().iter(),
sig.is_variadic(),
)
}

pub(crate) fn fnsig_argument_identifiers(
ctx: &BindgenContext,
sig: &FunctionSig,