Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| #define SIZE 4 | ||
| typedef struct WithoutAs { | ||
| uint32_t items[SIZE]; | ||
| } WithoutAs; | ||
| typedef struct WithAs { | ||
| uint32_t items[SIZE]; | ||
| } WithAs; | ||
| void some_fn(struct WithoutAs a, struct WithAs b); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| #define SIZE 4 | ||
| typedef struct WithoutAs { | ||
| uint32_t items[SIZE]; | ||
| } WithoutAs; | ||
| typedef struct WithAs { | ||
| uint32_t items[SIZE]; | ||
| } WithAs; | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| void some_fn(struct WithoutAs a, struct WithAs b); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| #define SIZE 4 | ||
| struct WithoutAs { | ||
| uint32_t items[SIZE]; | ||
| }; | ||
| struct WithAs { | ||
| uint32_t items[SIZE]; | ||
| }; | ||
| void some_fn(struct WithoutAs a, struct WithAs b); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| #define SIZE 4 | ||
| struct WithoutAs { | ||
| uint32_t items[SIZE]; | ||
| }; | ||
| struct WithAs { | ||
| uint32_t items[SIZE]; | ||
| }; | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| void some_fn(struct WithoutAs a, struct WithAs b); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
| from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
| cdef extern from *: | ||
| ctypedef bint bool | ||
| ctypedef struct va_list | ||
| cdef extern from *: | ||
| const intptr_t SIZE # = 4 | ||
| cdef struct WithoutAs: | ||
| uint32_t items[SIZE]; | ||
| cdef struct WithAs: | ||
| uint32_t items[SIZE]; | ||
| void some_fn(WithoutAs a, WithAs b); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| #define SIZE 4 | ||
| typedef struct { | ||
| uint32_t items[SIZE]; | ||
| } WithoutAs; | ||
| typedef struct { | ||
| uint32_t items[SIZE]; | ||
| } WithAs; | ||
| void some_fn(WithoutAs a, WithAs b); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| #define SIZE 4 | ||
| typedef struct { | ||
| uint32_t items[SIZE]; | ||
| } WithoutAs; | ||
| typedef struct { | ||
| uint32_t items[SIZE]; | ||
| } WithAs; | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| void some_fn(WithoutAs a, WithAs b); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| #include <cstdarg> | ||
| #include <cstdint> | ||
| #include <cstdlib> | ||
| #include <ostream> | ||
| #include <new> | ||
| constexpr static const intptr_t SIZE = 4; | ||
| struct WithoutAs { | ||
| uint32_t items[SIZE]; | ||
| }; | ||
| struct WithAs { | ||
| uint32_t items[SIZE]; | ||
| }; | ||
| extern "C" { | ||
| void some_fn(WithoutAs a, WithAs b); | ||
| } // extern "C" |
| from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
| from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
| cdef extern from *: | ||
| ctypedef bint bool | ||
| ctypedef struct va_list | ||
| cdef extern from *: | ||
| const intptr_t SIZE # = 4 | ||
| ctypedef struct WithoutAs: | ||
| uint32_t items[SIZE]; | ||
| ctypedef struct WithAs: | ||
| uint32_t items[SIZE]; | ||
| void some_fn(WithoutAs a, WithAs b); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct DummyStruct { | ||
| int32_t dummy_field; | ||
| } DummyStruct; | ||
| struct DummyStruct new_dummy(void); | ||
| struct DummyStruct new_dummy_param(int32_t dummy_field); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct DummyStruct { | ||
| int32_t dummy_field; | ||
| } DummyStruct; | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| struct DummyStruct new_dummy(void); | ||
| struct DummyStruct new_dummy_param(int32_t dummy_field); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| struct DummyStruct { | ||
| int32_t dummy_field; | ||
| }; | ||
| struct DummyStruct new_dummy(void); | ||
| struct DummyStruct new_dummy_param(int32_t dummy_field); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| struct DummyStruct { | ||
| int32_t dummy_field; | ||
| }; | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| struct DummyStruct new_dummy(void); | ||
| struct DummyStruct new_dummy_param(int32_t dummy_field); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
| from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
| cdef extern from *: | ||
| ctypedef bint bool | ||
| ctypedef struct va_list | ||
| cdef extern from *: | ||
| cdef struct DummyStruct: | ||
| int32_t dummy_field; | ||
| DummyStruct new_dummy(); | ||
| DummyStruct new_dummy_param(int32_t dummy_field); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct { | ||
| int32_t dummy_field; | ||
| } DummyStruct; | ||
| DummyStruct new_dummy(void); | ||
| DummyStruct new_dummy_param(int32_t dummy_field); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct { | ||
| int32_t dummy_field; | ||
| } DummyStruct; | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| DummyStruct new_dummy(void); | ||
| DummyStruct new_dummy_param(int32_t dummy_field); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| #include <cstdarg> | ||
| #include <cstdint> | ||
| #include <cstdlib> | ||
| #include <ostream> | ||
| #include <new> | ||
| struct DummyStruct { | ||
| int32_t dummy_field; | ||
| }; | ||
| extern "C" { | ||
| DummyStruct new_dummy(); | ||
| DummyStruct new_dummy_param(int32_t dummy_field); | ||
| } // extern "C" |
| from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
| from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
| cdef extern from *: | ||
| ctypedef bint bool | ||
| ctypedef struct va_list | ||
| cdef extern from *: | ||
| ctypedef struct DummyStruct: | ||
| int32_t dummy_field; | ||
| DummyStruct new_dummy(); | ||
| DummyStruct new_dummy_param(int32_t dummy_field); |
| #ifdef __clang__ | ||
| #define CBINDGEN_NULLABLE _Nullable | ||
| #else | ||
| #define CBINDGEN_NULLABLE | ||
| #endif | ||
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct Opaque Opaque; | ||
| typedef struct References { | ||
| const struct Opaque *a; | ||
| struct Opaque *b; | ||
| const struct Opaque *CBINDGEN_NULLABLE c; | ||
| struct Opaque *CBINDGEN_NULLABLE d; | ||
| } References; | ||
| typedef struct Pointers_u64 { | ||
| float *a; | ||
| uint64_t *b; | ||
| struct Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| struct Opaque **f; | ||
| uint64_t *CBINDGEN_NULLABLE g; | ||
| int32_t *CBINDGEN_NULLABLE h; | ||
| int32_t **CBINDGEN_NULLABLE i; | ||
| const uint64_t *CBINDGEN_NULLABLE j; | ||
| uint64_t *CBINDGEN_NULLABLE k; | ||
| } Pointers_u64; | ||
| void value_arg(struct References arg); | ||
| void mutltiple_args(int32_t *arg, struct Pointers_u64 *CBINDGEN_NULLABLE foo, struct Opaque **d); | ||
| void ref_arg(const struct Pointers_u64 *arg); | ||
| void mut_ref_arg(struct Pointers_u64 *arg); | ||
| void optional_ref_arg(const struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void optional_mut_ref_arg(struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void nullable_const_ptr(const struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void nullable_mut_ptr(struct Pointers_u64 *CBINDGEN_NULLABLE arg); |
| #ifdef __clang__ | ||
| #define CBINDGEN_NULLABLE _Nullable | ||
| #else | ||
| #define CBINDGEN_NULLABLE | ||
| #endif | ||
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct Opaque Opaque; | ||
| typedef struct References { | ||
| const struct Opaque *a; | ||
| struct Opaque *b; | ||
| const struct Opaque *CBINDGEN_NULLABLE c; | ||
| struct Opaque *CBINDGEN_NULLABLE d; | ||
| } References; | ||
| typedef struct Pointers_u64 { | ||
| float *a; | ||
| uint64_t *b; | ||
| struct Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| struct Opaque **f; | ||
| uint64_t *CBINDGEN_NULLABLE g; | ||
| int32_t *CBINDGEN_NULLABLE h; | ||
| int32_t **CBINDGEN_NULLABLE i; | ||
| const uint64_t *CBINDGEN_NULLABLE j; | ||
| uint64_t *CBINDGEN_NULLABLE k; | ||
| } Pointers_u64; | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| void value_arg(struct References arg); | ||
| void mutltiple_args(int32_t *arg, struct Pointers_u64 *CBINDGEN_NULLABLE foo, struct Opaque **d); | ||
| void ref_arg(const struct Pointers_u64 *arg); | ||
| void mut_ref_arg(struct Pointers_u64 *arg); | ||
| void optional_ref_arg(const struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void optional_mut_ref_arg(struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void nullable_const_ptr(const struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void nullable_mut_ptr(struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| #ifdef __clang__ | ||
| #define CBINDGEN_NULLABLE _Nullable | ||
| #else | ||
| #define CBINDGEN_NULLABLE | ||
| #endif | ||
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| struct Opaque; | ||
| struct References { | ||
| const struct Opaque *a; | ||
| struct Opaque *b; | ||
| const struct Opaque *CBINDGEN_NULLABLE c; | ||
| struct Opaque *CBINDGEN_NULLABLE d; | ||
| }; | ||
| struct Pointers_u64 { | ||
| float *a; | ||
| uint64_t *b; | ||
| struct Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| struct Opaque **f; | ||
| uint64_t *CBINDGEN_NULLABLE g; | ||
| int32_t *CBINDGEN_NULLABLE h; | ||
| int32_t **CBINDGEN_NULLABLE i; | ||
| const uint64_t *CBINDGEN_NULLABLE j; | ||
| uint64_t *CBINDGEN_NULLABLE k; | ||
| }; | ||
| void value_arg(struct References arg); | ||
| void mutltiple_args(int32_t *arg, struct Pointers_u64 *CBINDGEN_NULLABLE foo, struct Opaque **d); | ||
| void ref_arg(const struct Pointers_u64 *arg); | ||
| void mut_ref_arg(struct Pointers_u64 *arg); | ||
| void optional_ref_arg(const struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void optional_mut_ref_arg(struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void nullable_const_ptr(const struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void nullable_mut_ptr(struct Pointers_u64 *CBINDGEN_NULLABLE arg); |
| #ifdef __clang__ | ||
| #define CBINDGEN_NULLABLE _Nullable | ||
| #else | ||
| #define CBINDGEN_NULLABLE | ||
| #endif | ||
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| struct Opaque; | ||
| struct References { | ||
| const struct Opaque *a; | ||
| struct Opaque *b; | ||
| const struct Opaque *CBINDGEN_NULLABLE c; | ||
| struct Opaque *CBINDGEN_NULLABLE d; | ||
| }; | ||
| struct Pointers_u64 { | ||
| float *a; | ||
| uint64_t *b; | ||
| struct Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| struct Opaque **f; | ||
| uint64_t *CBINDGEN_NULLABLE g; | ||
| int32_t *CBINDGEN_NULLABLE h; | ||
| int32_t **CBINDGEN_NULLABLE i; | ||
| const uint64_t *CBINDGEN_NULLABLE j; | ||
| uint64_t *CBINDGEN_NULLABLE k; | ||
| }; | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| void value_arg(struct References arg); | ||
| void mutltiple_args(int32_t *arg, struct Pointers_u64 *CBINDGEN_NULLABLE foo, struct Opaque **d); | ||
| void ref_arg(const struct Pointers_u64 *arg); | ||
| void mut_ref_arg(struct Pointers_u64 *arg); | ||
| void optional_ref_arg(const struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void optional_mut_ref_arg(struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void nullable_const_ptr(const struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void nullable_mut_ptr(struct Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| #ifdef __clang__ | ||
| #define CBINDGEN_NULLABLE _Nullable | ||
| #else | ||
| #define CBINDGEN_NULLABLE | ||
| #endif | ||
| from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
| from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
| cdef extern from *: | ||
| ctypedef bint bool | ||
| ctypedef struct va_list | ||
| cdef extern from *: | ||
| cdef struct Opaque: | ||
| pass | ||
| cdef struct References: | ||
| const Opaque *a; | ||
| Opaque *b; | ||
| const Opaque *c; | ||
| Opaque *d; | ||
| cdef struct Pointers_u64: | ||
| float *a; | ||
| uint64_t *b; | ||
| Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| Opaque **f; | ||
| uint64_t *g; | ||
| int32_t *h; | ||
| int32_t **i; | ||
| const uint64_t *j; | ||
| uint64_t *k; | ||
| void value_arg(References arg); | ||
| void mutltiple_args(int32_t *arg, Pointers_u64 *foo, Opaque **d); | ||
| void ref_arg(const Pointers_u64 *arg); | ||
| void mut_ref_arg(Pointers_u64 *arg); | ||
| void optional_ref_arg(const Pointers_u64 *arg); | ||
| void optional_mut_ref_arg(Pointers_u64 *arg); | ||
| void nullable_const_ptr(const Pointers_u64 *arg); | ||
| void nullable_mut_ptr(Pointers_u64 *arg); |
| #ifdef __clang__ | ||
| #define CBINDGEN_NULLABLE _Nullable | ||
| #else | ||
| #define CBINDGEN_NULLABLE | ||
| #endif | ||
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct Opaque Opaque; | ||
| typedef struct { | ||
| const Opaque *a; | ||
| Opaque *b; | ||
| const Opaque *CBINDGEN_NULLABLE c; | ||
| Opaque *CBINDGEN_NULLABLE d; | ||
| } References; | ||
| typedef struct { | ||
| float *a; | ||
| uint64_t *b; | ||
| Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| Opaque **f; | ||
| uint64_t *CBINDGEN_NULLABLE g; | ||
| int32_t *CBINDGEN_NULLABLE h; | ||
| int32_t **CBINDGEN_NULLABLE i; | ||
| const uint64_t *CBINDGEN_NULLABLE j; | ||
| uint64_t *CBINDGEN_NULLABLE k; | ||
| } Pointers_u64; | ||
| void value_arg(References arg); | ||
| void mutltiple_args(int32_t *arg, Pointers_u64 *CBINDGEN_NULLABLE foo, Opaque **d); | ||
| void ref_arg(const Pointers_u64 *arg); | ||
| void mut_ref_arg(Pointers_u64 *arg); | ||
| void optional_ref_arg(const Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void optional_mut_ref_arg(Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void nullable_const_ptr(const Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void nullable_mut_ptr(Pointers_u64 *CBINDGEN_NULLABLE arg); |
| #ifdef __clang__ | ||
| #define CBINDGEN_NULLABLE _Nullable | ||
| #else | ||
| #define CBINDGEN_NULLABLE | ||
| #endif | ||
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct Opaque Opaque; | ||
| typedef struct { | ||
| const Opaque *a; | ||
| Opaque *b; | ||
| const Opaque *CBINDGEN_NULLABLE c; | ||
| Opaque *CBINDGEN_NULLABLE d; | ||
| } References; | ||
| typedef struct { | ||
| float *a; | ||
| uint64_t *b; | ||
| Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| Opaque **f; | ||
| uint64_t *CBINDGEN_NULLABLE g; | ||
| int32_t *CBINDGEN_NULLABLE h; | ||
| int32_t **CBINDGEN_NULLABLE i; | ||
| const uint64_t *CBINDGEN_NULLABLE j; | ||
| uint64_t *CBINDGEN_NULLABLE k; | ||
| } Pointers_u64; | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| void value_arg(References arg); | ||
| void mutltiple_args(int32_t *arg, Pointers_u64 *CBINDGEN_NULLABLE foo, Opaque **d); | ||
| void ref_arg(const Pointers_u64 *arg); | ||
| void mut_ref_arg(Pointers_u64 *arg); | ||
| void optional_ref_arg(const Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void optional_mut_ref_arg(Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void nullable_const_ptr(const Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| void nullable_mut_ptr(Pointers_u64 *CBINDGEN_NULLABLE arg); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| #ifdef __clang__ | ||
| #define CBINDGEN_NULLABLE _Nullable | ||
| #else | ||
| #define CBINDGEN_NULLABLE | ||
| #endif | ||
| #include <cstdarg> | ||
| #include <cstdint> | ||
| #include <cstdlib> | ||
| #include <ostream> | ||
| #include <new> | ||
| struct Opaque; | ||
| struct References { | ||
| const Opaque *a; | ||
| Opaque *b; | ||
| const Opaque *CBINDGEN_NULLABLE c; | ||
| Opaque *CBINDGEN_NULLABLE d; | ||
| }; | ||
| template<typename T> | ||
| struct Pointers { | ||
| float *a; | ||
| T *b; | ||
| Opaque *c; | ||
| T **d; | ||
| float **e; | ||
| Opaque **f; | ||
| T *CBINDGEN_NULLABLE g; | ||
| int32_t *CBINDGEN_NULLABLE h; | ||
| int32_t **CBINDGEN_NULLABLE i; | ||
| const T *CBINDGEN_NULLABLE j; | ||
| T *CBINDGEN_NULLABLE k; | ||
| }; | ||
| extern "C" { | ||
| void value_arg(References arg); | ||
| void mutltiple_args(int32_t *arg, Pointers<uint64_t> *CBINDGEN_NULLABLE foo, Opaque **d); | ||
| void ref_arg(const Pointers<uint64_t> *arg); | ||
| void mut_ref_arg(Pointers<uint64_t> *arg); | ||
| void optional_ref_arg(const Pointers<uint64_t> *CBINDGEN_NULLABLE arg); | ||
| void optional_mut_ref_arg(Pointers<uint64_t> *CBINDGEN_NULLABLE arg); | ||
| void nullable_const_ptr(const Pointers<uint64_t> *CBINDGEN_NULLABLE arg); | ||
| void nullable_mut_ptr(Pointers<uint64_t> *CBINDGEN_NULLABLE arg); | ||
| } // extern "C" |
| #ifdef __clang__ | ||
| #define CBINDGEN_NULLABLE _Nullable | ||
| #else | ||
| #define CBINDGEN_NULLABLE | ||
| #endif | ||
| from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
| from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
| cdef extern from *: | ||
| ctypedef bint bool | ||
| ctypedef struct va_list | ||
| cdef extern from *: | ||
| ctypedef struct Opaque: | ||
| pass | ||
| ctypedef struct References: | ||
| const Opaque *a; | ||
| Opaque *b; | ||
| const Opaque *c; | ||
| Opaque *d; | ||
| ctypedef struct Pointers_u64: | ||
| float *a; | ||
| uint64_t *b; | ||
| Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| Opaque **f; | ||
| uint64_t *g; | ||
| int32_t *h; | ||
| int32_t **i; | ||
| const uint64_t *j; | ||
| uint64_t *k; | ||
| void value_arg(References arg); | ||
| void mutltiple_args(int32_t *arg, Pointers_u64 *foo, Opaque **d); | ||
| void ref_arg(const Pointers_u64 *arg); | ||
| void mut_ref_arg(Pointers_u64 *arg); | ||
| void optional_ref_arg(const Pointers_u64 *arg); | ||
| void optional_mut_ref_arg(Pointers_u64 *arg); | ||
| void nullable_const_ptr(const Pointers_u64 *arg); | ||
| void nullable_mut_ptr(Pointers_u64 *arg); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct Opaque Opaque; | ||
| typedef struct Foo_u64 { | ||
| float *a; | ||
| uint64_t *b; | ||
| struct Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| struct Opaque **f; | ||
| uint64_t *g; | ||
| int32_t *h; | ||
| int32_t **i; | ||
| } Foo_u64; | ||
| void root(int32_t *arg, struct Foo_u64 *foo, struct Opaque **d); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct Opaque Opaque; | ||
| typedef struct Foo_u64 { | ||
| float *a; | ||
| uint64_t *b; | ||
| struct Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| struct Opaque **f; | ||
| uint64_t *g; | ||
| int32_t *h; | ||
| int32_t **i; | ||
| } Foo_u64; | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| void root(int32_t *arg, struct Foo_u64 *foo, struct Opaque **d); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| struct Opaque; | ||
| struct Foo_u64 { | ||
| float *a; | ||
| uint64_t *b; | ||
| struct Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| struct Opaque **f; | ||
| uint64_t *g; | ||
| int32_t *h; | ||
| int32_t **i; | ||
| }; | ||
| void root(int32_t *arg, struct Foo_u64 *foo, struct Opaque **d); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| struct Opaque; | ||
| struct Foo_u64 { | ||
| float *a; | ||
| uint64_t *b; | ||
| struct Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| struct Opaque **f; | ||
| uint64_t *g; | ||
| int32_t *h; | ||
| int32_t **i; | ||
| }; | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| void root(int32_t *arg, struct Foo_u64 *foo, struct Opaque **d); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
| from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
| cdef extern from *: | ||
| ctypedef bint bool | ||
| ctypedef struct va_list | ||
| cdef extern from *: | ||
| cdef struct Opaque: | ||
| pass | ||
| cdef struct Foo_u64: | ||
| float *a; | ||
| uint64_t *b; | ||
| Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| Opaque **f; | ||
| uint64_t *g; | ||
| int32_t *h; | ||
| int32_t **i; | ||
| void root(int32_t *arg, Foo_u64 *foo, Opaque **d); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct Opaque Opaque; | ||
| typedef struct { | ||
| float *a; | ||
| uint64_t *b; | ||
| Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| Opaque **f; | ||
| uint64_t *g; | ||
| int32_t *h; | ||
| int32_t **i; | ||
| } Foo_u64; | ||
| void root(int32_t *arg, Foo_u64 *foo, Opaque **d); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct Opaque Opaque; | ||
| typedef struct { | ||
| float *a; | ||
| uint64_t *b; | ||
| Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| Opaque **f; | ||
| uint64_t *g; | ||
| int32_t *h; | ||
| int32_t **i; | ||
| } Foo_u64; | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| void root(int32_t *arg, Foo_u64 *foo, Opaque **d); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| #include <cstdarg> | ||
| #include <cstdint> | ||
| #include <cstdlib> | ||
| #include <ostream> | ||
| #include <new> | ||
| struct Opaque; | ||
| template<typename T> | ||
| struct Foo { | ||
| float *a; | ||
| T *b; | ||
| Opaque *c; | ||
| T **d; | ||
| float **e; | ||
| Opaque **f; | ||
| T *g; | ||
| int32_t *h; | ||
| int32_t **i; | ||
| }; | ||
| extern "C" { | ||
| void root(int32_t *arg, Foo<uint64_t> *foo, Opaque **d); | ||
| } // extern "C" |
| from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
| from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
| cdef extern from *: | ||
| ctypedef bint bool | ||
| ctypedef struct va_list | ||
| cdef extern from *: | ||
| ctypedef struct Opaque: | ||
| pass | ||
| ctypedef struct Foo_u64: | ||
| float *a; | ||
| uint64_t *b; | ||
| Opaque *c; | ||
| uint64_t **d; | ||
| float **e; | ||
| Opaque **f; | ||
| uint64_t *g; | ||
| int32_t *h; | ||
| int32_t **i; | ||
| void root(int32_t *arg, Foo_u64 *foo, Opaque **d); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct Foo { | ||
| } Foo; | ||
| #define FOO_GA 10 | ||
| #define FOO_ZO 3.14 | ||
| void root(struct Foo x); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct Foo { | ||
| } Foo; | ||
| #define FOO_GA 10 | ||
| #define FOO_ZO 3.14 | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| void root(struct Foo x); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| struct Foo { | ||
| }; | ||
| #define FOO_GA 10 | ||
| #define FOO_ZO 3.14 | ||
| void root(struct Foo x); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| struct Foo { | ||
| }; | ||
| #define FOO_GA 10 | ||
| #define FOO_ZO 3.14 | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| void root(struct Foo x); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
| from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
| cdef extern from *: | ||
| ctypedef bint bool | ||
| ctypedef struct va_list | ||
| cdef extern from *: | ||
| cdef struct Foo: | ||
| pass | ||
| const int32_t FOO_GA # = 10 | ||
| const float FOO_ZO # = 3.14 | ||
| void root(Foo x); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct { | ||
| } Foo; | ||
| #define FOO_GA 10 | ||
| #define FOO_ZO 3.14 | ||
| void root(Foo x); |
| #include <stdarg.h> | ||
| #include <stdbool.h> | ||
| #include <stdint.h> | ||
| #include <stdlib.h> | ||
| typedef struct { | ||
| } Foo; | ||
| #define FOO_GA 10 | ||
| #define FOO_ZO 3.14 | ||
| #ifdef __cplusplus | ||
| extern "C" { | ||
| #endif // __cplusplus | ||
| void root(Foo x); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
| #include <cstdarg> | ||
| #include <cstdint> | ||
| #include <cstdlib> | ||
| #include <ostream> | ||
| #include <new> | ||
| struct Foo { | ||
| }; | ||
| constexpr static const int32_t FOO_GA = 10; | ||
| constexpr static const float FOO_ZO = 3.14; | ||
| extern "C" { | ||
| void root(Foo x); | ||
| } // extern "C" |
| from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
| from libc.stdint cimport uint8_t, uint16_t, uint32_t, uint64_t, uintptr_t | ||
| cdef extern from *: | ||
| ctypedef bint bool | ||
| ctypedef struct va_list | ||
| cdef extern from *: | ||
| ctypedef struct Foo: | ||
| pass | ||
| const int32_t FOO_GA # = 10 | ||
| const float FOO_ZO # = 3.14 | ||
| void root(Foo x); |
| pub const SIZE: isize = 4; | ||
| #[repr(C)] | ||
| pub struct WithoutAs { | ||
| items: [char; SIZE as usize], | ||
| } | ||
| #[repr(C)] | ||
| pub struct WithAs { | ||
| items: [char; SIZE as usize], | ||
| } | ||
| // dummy function to make `WithoutAs` and `WithAs` part of the public api | ||
| #[no_mangle] | ||
| pub extern fn some_fn(a: WithoutAs, b: WithAs) { | ||
| } |
| #[repr(C)] | ||
| pub struct DummyStruct { | ||
| dummy_field: i32, | ||
| } | ||
| impl DummyStruct { | ||
| #[unsafe(export_name = "new_dummy")] | ||
| pub const extern "C" fn new() -> Self { | ||
| Self { | ||
| dummy_field: 0, | ||
| } | ||
| } | ||
| #[unsafe(no_mangle)] | ||
| pub extern "C" fn new_dummy_param(dummy_field: i32) -> Self { | ||
| Self { | ||
| dummy_field, | ||
| } | ||
| } | ||
| } |
| use std::ptr::NonNull; | ||
| struct Opaque; | ||
| #[repr(C)] | ||
| pub struct Pointers<T> { | ||
| a: NonNull<f32>, | ||
| b: NonNull<T>, | ||
| c: NonNull<Opaque>, | ||
| d: NonNull<NonNull<T>>, | ||
| e: NonNull<NonNull<f32>>, | ||
| f: NonNull<NonNull<Opaque>>, | ||
| g: Option<NonNull<T>>, | ||
| h: Option<NonNull<i32>>, | ||
| i: Option<NonNull<NonNull<i32>>>, | ||
| j: *const T, | ||
| k: *mut T, | ||
| } | ||
| #[repr(C)] | ||
| pub struct References<'a> { | ||
| a: &'a Opaque, | ||
| b: &'a mut Opaque, | ||
| c: Option<&'a Opaque>, | ||
| d: Option<&'a mut Opaque>, | ||
| } | ||
| #[no_mangle] | ||
| pub extern "C" fn value_arg(arg: References<'static>) {} | ||
| #[no_mangle] | ||
| pub extern "C" fn mutltiple_args( | ||
| arg: NonNull<i32>, | ||
| foo: *mut Pointers<u64>, | ||
| d: NonNull<NonNull<Opaque>>, | ||
| ) { | ||
| } | ||
| #[no_mangle] | ||
| pub extern "C" fn ref_arg(arg: &Pointers<u64>) {} | ||
| #[no_mangle] | ||
| pub extern "C" fn mut_ref_arg(arg: &mut Pointers<u64>) {} | ||
| #[no_mangle] | ||
| pub extern "C" fn optional_ref_arg(arg: Option<&Pointers<u64>>) {} | ||
| #[no_mangle] | ||
| pub extern "C" fn optional_mut_ref_arg(arg: Option<&mut Pointers<u64>>) {} | ||
| #[no_mangle] | ||
| pub extern "C" fn nullable_const_ptr(arg: *const Pointers<u64>) {} | ||
| #[no_mangle] | ||
| pub extern "C" fn nullable_mut_ptr(arg: *mut Pointers<u64>) {} |
| header = """ | ||
| #ifdef __clang__ | ||
| #define CBINDGEN_NULLABLE _Nullable | ||
| #else | ||
| #define CBINDGEN_NULLABLE | ||
| #endif | ||
| """ | ||
| [ptr] | ||
| nullable_attribute = "CBINDGEN_NULLABLE" |
| use std::ptr::NonNull; | ||
| struct Opaque; | ||
| #[repr(C)] | ||
| pub struct Foo<T> { | ||
| a: NonNull<f32>, | ||
| b: NonNull<T>, | ||
| c: NonNull<Opaque>, | ||
| d: NonNull<NonNull<T>>, | ||
| e: NonNull<NonNull<f32>>, | ||
| f: NonNull<NonNull<Opaque>>, | ||
| g: Option<NonNull<T>>, | ||
| h: Option<NonNull<i32>>, | ||
| i: Option<NonNull<NonNull<i32>>>, | ||
| } | ||
| #[no_mangle] | ||
| pub extern "C" fn root(arg: NonNull<i32>, foo: *mut Foo<u64>, d: NonNull<NonNull<Opaque>>) { } |
| /// cbindgen:rename-associated-constant=UpperCase | ||
| #[repr(C)] | ||
| struct Foo {} | ||
| impl Foo { | ||
| pub const GA: i32 = 10; | ||
| pub const ZO: f32 = 3.14; | ||
| } | ||
| #[no_mangle] | ||
| pub extern "C" fn root(x: Foo) { } |
| [struct] | ||
| rename_associated_constant = "UpperCase" |
| { | ||
| "git": { | ||
| "sha1": "bd78bbe59b10eda6ef1255e4acda95c56c6d0279" | ||
| "sha1": "802154245edebe6bd031e473737da4c2fbdea8a3" | ||
| }, | ||
| "path_in_vcs": "" | ||
| } |
@@ -17,3 +17,3 @@ name: deploy | ||
| runs-on: ubuntu-20.04 | ||
| runs-on: ubuntu-22.04 | ||
@@ -25,3 +25,10 @@ steps: | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: aarch64-unknown-linux-gnu | ||
| - name: Install cross libc | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y libc6-arm64-cross gcc-11-aarch64-linux-gnu | ||
| - name: semver | ||
@@ -35,2 +42,3 @@ run: | | ||
| cargo +stable build --release | ||
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc-11 cargo +stable build --target aarch64-unknown-linux-gnu --release | ||
@@ -40,2 +48,3 @@ - name: Strip cbindgen | ||
| strip target/release/cbindgen | ||
| aarch64-linux-gnu-strip target/aarch64-unknown-linux-gnu/release/cbindgen | ||
@@ -58,4 +67,6 @@ - name: Handle release data and files | ||
| TAG=${{ steps.tagName.outputs.version }} | ||
| gh release create ${TAG} --title "${TAG}" --notes-file "CHANGES.txt" --draft 'target/release/cbindgen#cbindgen-ubuntu20.04' | ||
| cp target/release/cbindgen cbindgen-ubuntu22.04 | ||
| cp target/aarch64-unknown-linux-gnu/release/cbindgen cbindgen-ubuntu22.04-aarch64 | ||
| gh release create ${TAG} --title "${TAG}" --notes-file "CHANGES.txt" --draft cbindgen-ubuntu22.04 cbindgen-ubuntu22.04-aarch64 | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
+3
-3
@@ -68,3 +68,3 @@ # This file is automatically @generated by Cargo. | ||
| name = "cbindgen" | ||
| version = "0.28.0" | ||
| version = "0.29.0" | ||
| dependencies = [ | ||
@@ -174,5 +174,5 @@ "clap", | ||
| name = "heck" | ||
| version = "0.4.1" | ||
| version = "0.5.0" | ||
| source = "registry+https://github.com/rust-lang/crates.io-index" | ||
| checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" | ||
| checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" | ||
@@ -179,0 +179,0 @@ [[package]] |
+2
-2
@@ -16,3 +16,3 @@ # THIS FILE IS AUTOMATICALLY GENERATED BY CARGO | ||
| name = "cbindgen" | ||
| version = "0.28.0" | ||
| version = "0.29.0" | ||
| authors = [ | ||
@@ -72,3 +72,3 @@ "Emilio Cobos Álvarez <emilio@crisal.io>", | ||
| [dependencies.heck] | ||
| version = "0.4" | ||
| version = "0.5" | ||
@@ -75,0 +75,0 @@ [dependencies.indexmap] |
+14
-0
| # unreleased | ||
| # 0.29.0 | ||
| * Support no-export annotation for statics and functions. | ||
| * Fixed conditional fields of constexpr literal structs | ||
| * Add rename rule for generated associated constant | ||
| * Upgrade heck to 0.5 | ||
| * Add support for an optional nullable attribute | ||
| * docs.md: Fix deprecated_with_note and deprecated_variant_with_note being spelled as 'notes' | ||
| * Fix generic with "void" default | ||
| * Fixed error generation of structures using the keyword as inside arrays | ||
| * Added test for unsafe(no_mangle) attribute | ||
| * Fixed handling of trait methods containing the unsafe attribute | ||
| * Rename -Zparse-only | ||
| # 0.28.0 | ||
@@ -4,0 +18,0 @@ |
+10
-4
@@ -741,3 +741,3 @@ # cbindgen User Guide | ||
| # default: nothing is emitted for deprecated functions | ||
| deprecated_with_notes = "DEPRECATED_FUNC_WITH_NOTE" | ||
| deprecated_with_note = "DEPRECATED_FUNC_WITH_NOTE" | ||
@@ -831,3 +831,3 @@ # An optional string that will be used in the attribute position for functions | ||
| # default: nothing is emitted for deprecated structs | ||
| deprecated_with_notes = "DEPRECATED_STRUCT_WITH_NOTE" | ||
| deprecated_with_note = "DEPRECATED_STRUCT_WITH_NOTE" | ||
@@ -842,2 +842,8 @@ # Whether a Rust type with associated consts should emit those consts inside the | ||
| # The rename rule to apply to the struct name used for prefixing associated | ||
| # constants. | ||
| # | ||
| # default: "None" | ||
| rename_associated_constant = "None" | ||
| # Whether to derive a simple constructor that takes a value for every field. | ||
@@ -963,3 +969,3 @@ # default: false | ||
| # default: nothing is emitted for deprecated enums | ||
| deprecated_with_notes = "DEPRECATED_ENUM_WITH_NOTE" | ||
| deprecated_with_note = "DEPRECATED_ENUM_WITH_NOTE" | ||
@@ -981,3 +987,3 @@ # An optional string that should come after the name of any enum variant which has been | ||
| # default: nothing is emitted for deprecated enum variants | ||
| deprecated_variant_with_notes = "DEPRECATED_ENUM_VARIANT_WITH_NOTE({})" | ||
| deprecated_variant_with_note = "DEPRECATED_ENUM_VARIANT_WITH_NOTE({})" | ||
@@ -984,0 +990,0 @@ # Whether enums with fields should generate destructors. This exists so that generic |
@@ -136,4 +136,12 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| let function_names = self.functions.iter().map(|f| f.path().name()); | ||
| let global_names = self.globals.iter().map(|g| g.export_name()); | ||
| let function_names = self | ||
| .functions | ||
| .iter() | ||
| .filter(|f| f.annotations.should_export()) | ||
| .map(|f| f.path().name()); | ||
| let global_names = self | ||
| .globals | ||
| .iter() | ||
| .filter(|s| s.annotations.should_export()) | ||
| .map(|g| g.export_name()); | ||
| function_names.chain(global_names) | ||
@@ -140,0 +148,0 @@ } |
@@ -250,5 +250,11 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| } | ||
| if !is_nullable && !is_ref && config.language != Language::Cython { | ||
| if let Some(attr) = &config.pointer.non_null_attribute { | ||
| write!(out, "{} ", attr); | ||
| if config.language != Language::Cython { | ||
| if !is_nullable && !is_ref { | ||
| if let Some(attr) = &config.pointer.non_null_attribute { | ||
| write!(out, "{} ", attr); | ||
| } | ||
| } else if is_nullable { | ||
| if let Some(attr) = &config.pointer.nullable_attribute { | ||
| write!(out, "{} ", attr); | ||
| } | ||
| } | ||
@@ -255,0 +261,0 @@ } |
@@ -496,2 +496,5 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| pub associated_constants_in_body: bool, | ||
| /// The rename rule to apply to the struct name used for prefixing associated | ||
| /// constants | ||
| pub rename_associated_constant: RenameRule, | ||
| /// The way to annotate this struct as #[must_use]. | ||
@@ -883,2 +886,4 @@ pub must_use: Option<String>, | ||
| pub non_null_attribute: Option<String>, | ||
| /// Optional attribute to apply to pointers that may be null | ||
| pub nullable_attribute: Option<String>, | ||
| } | ||
@@ -885,0 +890,0 @@ |
@@ -60,3 +60,3 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| f, | ||
| "\nTry running `rustc -Z parse-only {}` to see a nicer error message", | ||
| "\nTry running `rustc -Z parse-crate-root-only {}` to see a nicer error message", | ||
| src_path, | ||
@@ -63,0 +63,0 @@ )? |
@@ -66,2 +66,6 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| pub(crate) fn should_export(&self) -> bool { | ||
| !self.bool("no-export").unwrap_or(false) | ||
| } | ||
| pub(crate) fn deprecated_note<'c>( | ||
@@ -68,0 +72,0 @@ &self, |
@@ -21,2 +21,3 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| use crate::bindgen::library::Library; | ||
| use crate::bindgen::rename::{IdentifierType, RenameRule}; | ||
| use crate::bindgen::writer::SourceWriter; | ||
@@ -83,2 +84,8 @@ use crate::bindgen::Bindings; | ||
| #[derive(Debug, Clone)] | ||
| pub struct LiteralStructField { | ||
| pub value: Literal, | ||
| pub cfg: Option<Cfg>, | ||
| } | ||
| #[derive(Debug, Clone)] | ||
| pub enum Literal { | ||
@@ -106,3 +113,3 @@ Expr(String), | ||
| export_name: String, | ||
| fields: HashMap<String, Literal>, | ||
| fields: HashMap<String, LiteralStructField>, | ||
| }, | ||
@@ -141,3 +148,3 @@ Cast { | ||
| for ref mut expr in fields.values_mut() { | ||
| expr.replace_self_with(self_ty); | ||
| expr.value.replace_self_with(self_ty); | ||
| } | ||
@@ -210,3 +217,3 @@ } | ||
| for (_name, field) in fields.iter() { | ||
| if !field.visit(visitor) { | ||
| if !field.value.visit(visitor) { | ||
| return false; | ||
@@ -258,3 +265,3 @@ } | ||
| for lit in fields.values_mut() { | ||
| lit.rename_for_config(config); | ||
| lit.value.rename_for_config(config); | ||
| } | ||
@@ -397,3 +404,3 @@ } | ||
| }; | ||
| let mut fields = HashMap::<String, Literal>::default(); | ||
| let mut fields = HashMap::<String, LiteralStructField>::default(); | ||
| for (index, arg) in args.iter().enumerate() { | ||
@@ -403,3 +410,4 @@ let ident = | ||
| let value = Literal::load(arg)?; | ||
| fields.insert(ident, value); | ||
| let field = LiteralStructField { value, cfg: None }; | ||
| fields.insert(ident, field); | ||
| } | ||
@@ -419,7 +427,9 @@ Ok(Literal::Struct { | ||
| let struct_name = path.segments[0].ident.unraw().to_string(); | ||
| let mut field_map = HashMap::<String, Literal>::default(); | ||
| let mut field_map = HashMap::<String, LiteralStructField>::default(); | ||
| for field in fields { | ||
| let ident = member_to_ident(&field.member).to_string(); | ||
| let cfg = Cfg::load(&field.attrs); | ||
| let value = Literal::load(&field.expr)?; | ||
| field_map.insert(ident, value); | ||
| let field = LiteralStructField { value, cfg }; | ||
| field_map.insert(ident, field); | ||
| } | ||
@@ -678,3 +688,17 @@ Ok(Literal::Struct { | ||
| let associated_name = match associated_to_struct { | ||
| Some(s) => Cow::Borrowed(s.export_name()), | ||
| Some(s) => { | ||
| let name = s.export_name(); | ||
| let rules = s | ||
| .annotations | ||
| .parse_atom::<RenameRule>("rename-associated-constant"); | ||
| let rules = rules | ||
| .as_ref() | ||
| .unwrap_or(&config.structure.rename_associated_constant); | ||
| if let Some(r) = rules.not_none() { | ||
| r.apply(name, IdentifierType::Type) | ||
| } else { | ||
| Cow::Borrowed(name) | ||
| } | ||
| } | ||
| None => { | ||
@@ -695,3 +719,3 @@ let mut name = self.associated_to.as_ref().unwrap().name().to_owned(); | ||
| } | ||
| value = fields.iter().next().unwrap().1 | ||
| value = &fields.iter().next().unwrap().1.value | ||
| } | ||
@@ -698,0 +722,0 @@ |
@@ -9,3 +9,3 @@ use std::io::Write; | ||
| use crate::bindgen::declarationtyperesolver::{DeclarationType, DeclarationTypeResolver}; | ||
| use crate::bindgen::ir::{ConstExpr, Path, Type}; | ||
| use crate::bindgen::ir::{ConstExpr, Path, PrimitiveType, Type}; | ||
| use crate::bindgen::language_backend::LanguageBackend; | ||
@@ -46,3 +46,3 @@ use crate::bindgen::utilities::IterHelpers; | ||
| None => None, | ||
| Some(None) => Err(format!("unsupported generic type default: {:?}", default))?, | ||
| Some(None) => Some(GenericArgument::Type(Type::Primitive(PrimitiveType::Void))), | ||
| Some(Some(ty)) => Some(GenericArgument::Type(ty)), | ||
@@ -49,0 +49,0 @@ }; |
@@ -273,2 +273,3 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| } | ||
| syn::Expr::Cast(ref cast) => Ok(ConstExpr::load(&cast.expr)?), | ||
| _ => Err(format!("can't handle const expression {:?}", expr)), | ||
@@ -275,0 +276,0 @@ } |
@@ -915,15 +915,15 @@ use crate::bindgen::ir::{ | ||
| if let Some(lit) = fields.get(ordered_key) { | ||
| let condition = lit.cfg.to_condition(self.config); | ||
| if is_constexpr { | ||
| out.new_line(); | ||
| condition.write_before(self.config, out); | ||
| // TODO: Some C++ versions (c++20?) now support designated | ||
| // initializers, consider generating them. | ||
| write!(out, "/* .{} = */ ", ordered_key); | ||
| self.write_literal(out, lit); | ||
| self.write_literal(out, &lit.value); | ||
| if i + 1 != ordered_fields.len() { | ||
| write!(out, ","); | ||
| if !is_constexpr { | ||
| write!(out, " "); | ||
| } | ||
| } | ||
| condition.write_after(self.config, out); | ||
| } else { | ||
@@ -941,3 +941,3 @@ if i > 0 { | ||
| } | ||
| self.write_literal(out, lit); | ||
| self.write_literal(out, &lit.value); | ||
| } | ||
@@ -944,0 +944,0 @@ } |
@@ -402,3 +402,3 @@ use crate::bindgen::ir::{ | ||
| } | ||
| self.write_literal(out, lit); | ||
| self.write_literal(out, &lit.value); | ||
| } | ||
@@ -405,0 +405,0 @@ } |
@@ -162,8 +162,3 @@ use crate::bindgen::ir::{ | ||
| for item in &b.items { | ||
| if item | ||
| .deref() | ||
| .annotations() | ||
| .bool("no-export") | ||
| .unwrap_or(false) | ||
| { | ||
| if !item.deref().annotations().should_export() { | ||
| continue; | ||
@@ -202,2 +197,5 @@ } | ||
| for global in &b.globals { | ||
| if !global.annotations.should_export() { | ||
| continue; | ||
| } | ||
| out.new_line_if_not_start(); | ||
@@ -215,2 +213,5 @@ self.write_static(out, global); | ||
| for function in &b.functions { | ||
| if !function.annotations.should_export() { | ||
| continue; | ||
| } | ||
| out.new_line_if_not_start(); | ||
@@ -217,0 +218,0 @@ self.write_function(&b.config, out, function); |
@@ -53,2 +53,3 @@ /* This Source Code Form is subject to the terms of the Mozilla Public | ||
| .attr_name_value_lookup("export_name") | ||
| .or_else(|| self.unsafe_attr_name_value_lookup("export_name")) | ||
| .or_else(|| { | ||
@@ -55,0 +56,0 @@ if self.is_no_mangle() { |
+1
-0
@@ -98,2 +98,3 @@ # This is a template cbindgen.toml file with all of the default values. | ||
| # deprecated_with_note = "DEPRECATED_STRUCT_WITH_NOTE" | ||
| rename_associated_constant = "None" | ||
| derive_constructor = false | ||
@@ -100,0 +101,0 @@ derive_eq = false |
@@ -80,2 +80,4 @@ #if 0 | ||
| } ConditionalField; | ||
| #define ConditionalField_ZERO (ConditionalField){ .field = 0 } | ||
| #define ConditionalField_ONE (ConditionalField){ .field = 1 } | ||
@@ -82,0 +84,0 @@ typedef struct Normal { |
@@ -98,2 +98,4 @@ #if 0 | ||
| } ConditionalField; | ||
| #define ConditionalField_ZERO (ConditionalField){ .field = 0 } | ||
| #define ConditionalField_ONE (ConditionalField){ .field = 1 } | ||
@@ -100,0 +102,0 @@ typedef struct Normal { |
@@ -80,2 +80,4 @@ #if 0 | ||
| }; | ||
| #define ConditionalField_ZERO (ConditionalField){ .field = 0 } | ||
| #define ConditionalField_ONE (ConditionalField){ .field = 1 } | ||
@@ -82,0 +84,0 @@ struct Normal { |
@@ -98,2 +98,4 @@ #if 0 | ||
| }; | ||
| #define ConditionalField_ZERO (ConditionalField){ .field = 0 } | ||
| #define ConditionalField_ONE (ConditionalField){ .field = 1 } | ||
@@ -100,0 +102,0 @@ struct Normal { |
@@ -60,2 +60,4 @@ #if 0 | ||
| int32_t field; | ||
| const ConditionalField ConditionalField_ZERO # = <ConditionalField>{ 0 } | ||
| const ConditionalField ConditionalField_ONE # = <ConditionalField>{ 1 } | ||
@@ -62,0 +64,0 @@ cdef struct Normal: |
@@ -80,2 +80,4 @@ #if 0 | ||
| } ConditionalField; | ||
| #define ConditionalField_ZERO (ConditionalField){ .field = 0 } | ||
| #define ConditionalField_ONE (ConditionalField){ .field = 1 } | ||
@@ -82,0 +84,0 @@ typedef struct { |
@@ -98,2 +98,4 @@ #if 0 | ||
| } ConditionalField; | ||
| #define ConditionalField_ZERO (ConditionalField){ .field = 0 } | ||
| #define ConditionalField_ONE (ConditionalField){ .field = 1 } | ||
@@ -100,0 +102,0 @@ typedef struct { |
@@ -204,2 +204,12 @@ #if 0 | ||
| }; | ||
| constexpr static const ConditionalField ConditionalField_ZERO = ConditionalField{ | ||
| #if defined(X11) | ||
| /* .field = */ 0 | ||
| #endif | ||
| }; | ||
| constexpr static const ConditionalField ConditionalField_ONE = ConditionalField{ | ||
| #if defined(X11) | ||
| /* .field = */ 1 | ||
| #endif | ||
| }; | ||
@@ -206,0 +216,0 @@ struct Normal { |
@@ -60,2 +60,4 @@ #if 0 | ||
| int32_t field; | ||
| const ConditionalField ConditionalField_ZERO # = <ConditionalField>{ 0 } | ||
| const ConditionalField ConditionalField_ONE # = <ConditionalField>{ 1 } | ||
@@ -62,0 +64,0 @@ ctypedef struct Normal: |
@@ -19,2 +19,8 @@ #include <stdarg.h> | ||
| typedef struct NeverUsedWithDefault_i32 { | ||
| int32_t field; | ||
| } NeverUsedWithDefault_i32; | ||
| void foo_root(Foo_i16 f, struct Bar_i32__u32 b, Baz_i64 z); | ||
| void with_i32(struct NeverUsedWithDefault_i32 x); |
@@ -19,2 +19,6 @@ #include <stdarg.h> | ||
| typedef struct NeverUsedWithDefault_i32 { | ||
| int32_t field; | ||
| } NeverUsedWithDefault_i32; | ||
| #ifdef __cplusplus | ||
@@ -26,4 +30,6 @@ extern "C" { | ||
| void with_i32(struct NeverUsedWithDefault_i32 x); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
@@ -19,2 +19,8 @@ #include <stdarg.h> | ||
| struct NeverUsedWithDefault_i32 { | ||
| int32_t field; | ||
| }; | ||
| void foo_root(Foo_i16 f, struct Bar_i32__u32 b, Baz_i64 z); | ||
| void with_i32(struct NeverUsedWithDefault_i32 x); |
@@ -19,2 +19,6 @@ #include <stdarg.h> | ||
| struct NeverUsedWithDefault_i32 { | ||
| int32_t field; | ||
| }; | ||
| #ifdef __cplusplus | ||
@@ -26,4 +30,6 @@ extern "C" { | ||
| void with_i32(struct NeverUsedWithDefault_i32 x); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
@@ -21,2 +21,7 @@ from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
| cdef struct NeverUsedWithDefault_i32: | ||
| int32_t field; | ||
| void foo_root(Foo_i16 f, Bar_i32__u32 b, Baz_i64 z); | ||
| void with_i32(NeverUsedWithDefault_i32 x); |
@@ -19,2 +19,8 @@ #include <stdarg.h> | ||
| typedef struct { | ||
| int32_t field; | ||
| } NeverUsedWithDefault_i32; | ||
| void foo_root(Foo_i16 f, Bar_i32__u32 b, Baz_i64 z); | ||
| void with_i32(NeverUsedWithDefault_i32 x); |
@@ -19,2 +19,6 @@ #include <stdarg.h> | ||
| typedef struct { | ||
| int32_t field; | ||
| } NeverUsedWithDefault_i32; | ||
| #ifdef __cplusplus | ||
@@ -26,4 +30,6 @@ extern "C" { | ||
| void with_i32(NeverUsedWithDefault_i32 x); | ||
| #ifdef __cplusplus | ||
| } // extern "C" | ||
| #endif // __cplusplus |
@@ -19,2 +19,7 @@ #include <cstdarg> | ||
| template<typename T = void> | ||
| struct NeverUsedWithDefault { | ||
| T field; | ||
| }; | ||
| extern "C" { | ||
@@ -24,2 +29,4 @@ | ||
| void with_i32(NeverUsedWithDefault<int32_t> x); | ||
| } // extern "C" |
@@ -21,2 +21,7 @@ from libc.stdint cimport int8_t, int16_t, int32_t, int64_t, intptr_t | ||
| ctypedef struct NeverUsedWithDefault_i32: | ||
| int32_t field; | ||
| void foo_root(Foo_i16 f, Bar_i32__u32 b, Baz_i64 z); | ||
| void with_i32(NeverUsedWithDefault_i32 x); |
@@ -35,3 +35,11 @@ /// cbindgen:derive-lt=true | ||
| /// cbindgen:no-export | ||
| #[no_mangle] | ||
| pub extern "C" fn no_export_fn() {} | ||
| /// cbindgen:no-export | ||
| #[no_mangle] | ||
| pub static NO_EXPORT_NUMBER: i32 = 10; | ||
| #[no_mangle] | ||
| pub extern "C" fn root( | ||
@@ -38,0 +46,0 @@ x: A, |
+11
-0
@@ -52,2 +52,13 @@ #[cfg(all(unix, x11))] | ||
| impl ConditionalField { | ||
| pub const ZERO: Self = Self { | ||
| #[cfg(x11)] | ||
| field: 0, | ||
| }; | ||
| pub const ONE: Self = Self { | ||
| #[cfg(x11)] | ||
| field: 1, | ||
| }; | ||
| } | ||
| #[cfg(all(unix, x11))] | ||
@@ -54,0 +65,0 @@ #[no_mangle] |
@@ -17,1 +17,10 @@ #[repr(transparent)] | ||
| pub extern "C" fn foo_root(f: Foo<i16>, b: Bar<i32, u32>, z: Baz<i64>) {} | ||
| // Issue #993 | ||
| #[repr(C)] | ||
| pub struct NeverUsedWithDefault<T = ()> { | ||
| field: T, | ||
| } | ||
| #[no_mangle] | ||
| pub extern "C" fn with_i32(x: NeverUsedWithDefault<i32>) {} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet