Skip to content

Commit

Permalink
Used documented method of specifying variadic arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
gerard-ryan-immersaview authored and emilio committed May 28, 2024
1 parent 6f13a5d commit 1dda616
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 47 deletions.
6 changes: 5 additions & 1 deletion src/bindgen/ir/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
2 changes: 1 addition & 1 deletion src/bindgen/ir/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl PrimitiveType {
PrimitiveType::Float => "float",
PrimitiveType::Double => "double",
PrimitiveType::PtrDiffT => "ptrdiff_t",
PrimitiveType::VaList => "va_list",
PrimitiveType::VaList => "...",
}
}

Expand Down
10 changes: 5 additions & 5 deletions tests/expectations/va_list.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
#include <stdint.h>
#include <stdlib.h>

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,
Expand Down
10 changes: 5 additions & 5 deletions tests/expectations/va_list.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include <stdint.h>
#include <stdlib.h>

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 {
Expand All @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions tests/expectations/va_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <ostream>
#include <new>

using VaListFnPtr = int32_t(*)(int32_t count, va_list);
using VaListFnPtr = int32_t(*)(int32_t count, ...);

using VaListFnPtr2 = int32_t(*)(int32_t count);

Expand All @@ -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<int32_t(*)(int32_t count, va_list)> fn5,
Interface<int32_t(*)(int32_t count, ...)> fn5,
Interface<int32_t(*)(int32_t count)> fn6);

} // extern "C"
10 changes: 5 additions & 5 deletions tests/expectations/va_list.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions tests/expectations/va_list_both.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
#include <stdint.h>
#include <stdlib.h>

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,
Expand Down
10 changes: 5 additions & 5 deletions tests/expectations/va_list_both.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include <stdint.h>
#include <stdlib.h>

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 {
Expand All @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions tests/expectations/va_list_tag.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
#include <stdint.h>
#include <stdlib.h>

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,
Expand Down
10 changes: 5 additions & 5 deletions tests/expectations/va_list_tag.compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
#include <stdint.h>
#include <stdlib.h>

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 {
Expand All @@ -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,
Expand Down
10 changes: 5 additions & 5 deletions tests/expectations/va_list_tag.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1dda616

Please sign in to comment.