bindgen: enable "void prototype" while writing struct field

This fixs typedef's signature in C as well because a typedef statement is
constructed like, "typedef " + field_like_string.
This commit is contained in:
yingrueil 2020-02-15 13:03:44 +08:00
parent c6809b00fb
commit 0163b83d76
21 changed files with 47 additions and 47 deletions

View File

@ -286,7 +286,7 @@ pub fn write_func<F: Write>(
}
pub fn write_field<F: Write>(out: &mut SourceWriter<F>, t: &Type, ident: &str) {
CDecl::from_type(t).write(out, Some(ident), false);
CDecl::from_type(t).write(out, Some(ident), true);
}
pub fn write_type<F: Write>(out: &mut SourceWriter<F>, t: &Type) {

View File

@ -3,15 +3,15 @@
#include <stdint.h>
#include <stdlib.h>
typedef void (*A)();
typedef void (*A)(void);
typedef void (*B)();
typedef void (*B)(void);
typedef bool (*C)(int32_t, int32_t);
typedef bool (*(*D)(int32_t))(float);
typedef const int32_t (*(*E)())[16];
typedef const int32_t (*(*E)(void))[16];
typedef const int32_t *F;

View File

@ -3,15 +3,15 @@
#include <stdint.h>
#include <stdlib.h>
typedef void (*A)();
typedef void (*A)(void);
typedef void (*B)();
typedef void (*B)(void);
typedef bool (*C)(int32_t, int32_t);
typedef bool (*(*D)(int32_t))(float);
typedef const int32_t (*(*E)())[16];
typedef const int32_t (*(*E)(void))[16];
typedef const int32_t *F;

View File

@ -4,9 +4,9 @@
#include <stdlib.h>
typedef struct Fns {
void (*noArgs)();
void (*noArgs)(void);
void (*anonymousArg)(int32_t);
int32_t (*returnsNumber)();
int32_t (*returnsNumber)(void);
int8_t (*namedArgs)(int32_t first, int16_t snd);
int8_t (*namedArgsWildcards)(int32_t _, int16_t named, int64_t _1);
} Fns;

View File

@ -4,9 +4,9 @@
#include <stdlib.h>
typedef struct Fns {
void (*noArgs)();
void (*noArgs)(void);
void (*anonymousArg)(int32_t);
int32_t (*returnsNumber)();
int32_t (*returnsNumber)(void);
int8_t (*namedArgs)(int32_t first, int16_t snd);
int8_t (*namedArgsWildcards)(int32_t _, int16_t named, int64_t _1);
} Fns;

View File

@ -8,13 +8,13 @@ typedef struct Opaque Opaque;
typedef struct Foo {
const Opaque *x;
Opaque *y;
void (*z)();
void (*z)(void);
} Foo;
typedef union Bar {
const Opaque *x;
Opaque *y;
void (*z)();
void (*z)(void);
} Bar;
void root(const Opaque *a, Opaque *b, Foo c, Bar d);

View File

@ -8,13 +8,13 @@ typedef struct Opaque Opaque;
typedef struct Foo {
const Opaque *x;
Opaque *y;
void (*z)();
void (*z)(void);
} Foo;
typedef union Bar {
const Opaque *x;
Opaque *y;
void (*z)();
void (*z)(void);
} Bar;
#ifdef __cplusplus

View File

@ -3,15 +3,15 @@
#include <stdint.h>
#include <stdlib.h>
typedef void (*A)();
typedef void (*A)(void);
typedef void (*B)();
typedef void (*B)(void);
typedef bool (*C)(int32_t, int32_t);
typedef bool (*(*D)(int32_t))(float);
typedef const int32_t (*(*E)())[16];
typedef const int32_t (*(*E)(void))[16];
typedef const int32_t *F;

View File

@ -3,15 +3,15 @@
#include <stdint.h>
#include <stdlib.h>
typedef void (*A)();
typedef void (*A)(void);
typedef void (*B)();
typedef void (*B)(void);
typedef bool (*C)(int32_t, int32_t);
typedef bool (*(*D)(int32_t))(float);
typedef const int32_t (*(*E)())[16];
typedef const int32_t (*(*E)(void))[16];
typedef const int32_t *F;

View File

@ -4,9 +4,9 @@
#include <stdlib.h>
typedef struct {
void (*noArgs)();
void (*noArgs)(void);
void (*anonymousArg)(int32_t);
int32_t (*returnsNumber)();
int32_t (*returnsNumber)(void);
int8_t (*namedArgs)(int32_t first, int16_t snd);
int8_t (*namedArgsWildcards)(int32_t _, int16_t named, int64_t _1);
} Fns;

View File

@ -4,9 +4,9 @@
#include <stdlib.h>
typedef struct {
void (*noArgs)();
void (*noArgs)(void);
void (*anonymousArg)(int32_t);
int32_t (*returnsNumber)();
int32_t (*returnsNumber)(void);
int8_t (*namedArgs)(int32_t first, int16_t snd);
int8_t (*namedArgsWildcards)(int32_t _, int16_t named, int64_t _1);
} Fns;

View File

@ -4,9 +4,9 @@
#include <new>
struct Fns {
void (*noArgs)();
void (*noArgs)(void);
void (*anonymousArg)(int32_t);
int32_t (*returnsNumber)();
int32_t (*returnsNumber)(void);
int8_t (*namedArgs)(int32_t first, int16_t snd);
int8_t (*namedArgsWildcards)(int32_t _, int16_t named, int64_t _1);
};

View File

@ -8,13 +8,13 @@ typedef struct Opaque Opaque;
typedef struct {
const Opaque *x;
Opaque *y;
void (*z)();
void (*z)(void);
} Foo;
typedef union {
const Opaque *x;
Opaque *y;
void (*z)();
void (*z)(void);
} Bar;
void root(const Opaque *a, Opaque *b, Foo c, Bar d);

View File

@ -8,13 +8,13 @@ typedef struct Opaque Opaque;
typedef struct {
const Opaque *x;
Opaque *y;
void (*z)();
void (*z)(void);
} Foo;
typedef union {
const Opaque *x;
Opaque *y;
void (*z)();
void (*z)(void);
} Bar;
#ifdef __cplusplus

View File

@ -8,13 +8,13 @@ struct Opaque;
struct Foo {
const Opaque *x;
Opaque *y;
void (*z)();
void (*z)(void);
};
union Bar {
const Opaque *x;
Opaque *y;
void (*z)();
void (*z)(void);
};
extern "C" {

View File

@ -3,15 +3,15 @@
#include <stdint.h>
#include <stdlib.h>
typedef void (*A)();
typedef void (*A)(void);
typedef void (*B)();
typedef void (*B)(void);
typedef bool (*C)(int32_t, int32_t);
typedef bool (*(*D)(int32_t))(float);
typedef const int32_t (*(*E)())[16];
typedef const int32_t (*(*E)(void))[16];
typedef const int32_t *F;

View File

@ -3,15 +3,15 @@
#include <stdint.h>
#include <stdlib.h>
typedef void (*A)();
typedef void (*A)(void);
typedef void (*B)();
typedef void (*B)(void);
typedef bool (*C)(int32_t, int32_t);
typedef bool (*(*D)(int32_t))(float);
typedef const int32_t (*(*E)())[16];
typedef const int32_t (*(*E)(void))[16];
typedef const int32_t *F;

View File

@ -4,9 +4,9 @@
#include <stdlib.h>
struct Fns {
void (*noArgs)();
void (*noArgs)(void);
void (*anonymousArg)(int32_t);
int32_t (*returnsNumber)();
int32_t (*returnsNumber)(void);
int8_t (*namedArgs)(int32_t first, int16_t snd);
int8_t (*namedArgsWildcards)(int32_t _, int16_t named, int64_t _1);
};

View File

@ -4,9 +4,9 @@
#include <stdlib.h>
struct Fns {
void (*noArgs)();
void (*noArgs)(void);
void (*anonymousArg)(int32_t);
int32_t (*returnsNumber)();
int32_t (*returnsNumber)(void);
int8_t (*namedArgs)(int32_t first, int16_t snd);
int8_t (*namedArgsWildcards)(int32_t _, int16_t named, int64_t _1);
};

View File

@ -8,13 +8,13 @@ struct Opaque;
struct Foo {
const struct Opaque *x;
struct Opaque *y;
void (*z)();
void (*z)(void);
};
union Bar {
const struct Opaque *x;
struct Opaque *y;
void (*z)();
void (*z)(void);
};
void root(const struct Opaque *a, struct Opaque *b, struct Foo c, union Bar d);

View File

@ -8,13 +8,13 @@ struct Opaque;
struct Foo {
const struct Opaque *x;
struct Opaque *y;
void (*z)();
void (*z)(void);
};
union Bar {
const struct Opaque *x;
struct Opaque *y;
void (*z)();
void (*z)(void);
};
#ifdef __cplusplus