From aeb69bcc6941b37a0d0acfa1ed77d4ccdf1cccc9 Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 5 Oct 2020 19:43:15 +0300 Subject: [PATCH] Switch default sorting order for items to "None" --- docs.md | 8 +- src/bindgen/config.rs | 2 +- tests/expectations/both/box.c | 4 +- tests/expectations/both/box.compat.c | 4 +- tests/expectations/both/constant.c | 34 ++++----- tests/expectations/both/constant.compat.c | 34 ++++----- tests/expectations/both/constant_big.c | 8 +- tests/expectations/both/constant_big.compat.c | 8 +- tests/expectations/both/constant_constexpr.c | 4 +- .../both/constant_constexpr.compat.c | 4 +- tests/expectations/both/expand_features.c | 4 +- .../both/expand_features.compat.c | 4 +- tests/expectations/both/extern.c | 4 +- tests/expectations/both/extern.compat.c | 4 +- tests/expectations/both/fns.c | 4 +- tests/expectations/both/fns.compat.c | 4 +- tests/expectations/both/function_args.c | 4 +- .../expectations/both/function_args.compat.c | 4 +- tests/expectations/both/global_variable.c | 4 +- .../both/global_variable.compat.c | 4 +- tests/expectations/both/mod_attr.c | 16 ++-- tests/expectations/both/mod_attr.compat.c | 22 +++--- tests/expectations/both/monomorph-2.c | 12 +-- tests/expectations/both/monomorph-2.compat.c | 14 ++-- tests/expectations/both/nonnull_attribute.c | 28 +++---- .../both/nonnull_attribute.compat.c | 32 ++++---- tests/expectations/both/ptrs_as_arrays.c | 4 +- .../expectations/both/ptrs_as_arrays.compat.c | 4 +- tests/expectations/both/rename-crate.c | 20 ++--- tests/expectations/both/rename-crate.compat.c | 20 ++--- tests/expectations/both/static.c | 4 +- tests/expectations/both/static.compat.c | 4 +- tests/expectations/both/swift_name.c | 46 +++++------ tests/expectations/both/swift_name.compat.c | 76 +++++++++---------- tests/expectations/box.c | 4 +- tests/expectations/box.compat.c | 4 +- tests/expectations/box.cpp | 4 +- tests/expectations/constant.c | 34 ++++----- tests/expectations/constant.compat.c | 34 ++++----- tests/expectations/constant.cpp | 30 ++++---- tests/expectations/constant_big.c | 8 +- tests/expectations/constant_big.compat.c | 8 +- tests/expectations/constant_big.cpp | 8 +- tests/expectations/constant_constexpr.c | 4 +- .../expectations/constant_constexpr.compat.c | 4 +- tests/expectations/constant_constexpr.cpp | 4 +- tests/expectations/expand_features.c | 4 +- tests/expectations/expand_features.compat.c | 4 +- tests/expectations/expand_features.cpp | 4 +- tests/expectations/extern.c | 4 +- tests/expectations/extern.compat.c | 4 +- tests/expectations/extern.cpp | 4 +- tests/expectations/fns.c | 4 +- tests/expectations/fns.compat.c | 4 +- tests/expectations/fns.cpp | 4 +- tests/expectations/function_args.c | 4 +- tests/expectations/function_args.compat.c | 4 +- tests/expectations/function_args.cpp | 4 +- tests/expectations/global_variable.c | 4 +- tests/expectations/global_variable.compat.c | 4 +- tests/expectations/global_variable.cpp | 4 +- tests/expectations/mod_attr.c | 16 ++-- tests/expectations/mod_attr.compat.c | 22 +++--- tests/expectations/mod_attr.cpp | 20 ++--- tests/expectations/monomorph-2.c | 12 +-- tests/expectations/monomorph-2.compat.c | 14 ++-- tests/expectations/monomorph-2.cpp | 4 +- tests/expectations/nonnull_attribute.c | 28 +++---- tests/expectations/nonnull_attribute.compat.c | 32 ++++---- tests/expectations/nonnull_attribute.cpp | 32 ++++---- tests/expectations/ptrs_as_arrays.c | 4 +- tests/expectations/ptrs_as_arrays.compat.c | 4 +- tests/expectations/ptrs_as_arrays.cpp | 4 +- tests/expectations/rename-crate.c | 20 ++--- tests/expectations/rename-crate.compat.c | 20 ++--- tests/expectations/rename-crate.cpp | 24 +++--- tests/expectations/static.c | 4 +- tests/expectations/static.compat.c | 4 +- tests/expectations/static.cpp | 4 +- tests/expectations/swift_name.c | 46 +++++------ tests/expectations/swift_name.compat.c | 76 +++++++++---------- tests/expectations/swift_name.cpp | 76 +++++++++---------- tests/expectations/tag/box.c | 4 +- tests/expectations/tag/box.compat.c | 4 +- tests/expectations/tag/constant.c | 34 ++++----- tests/expectations/tag/constant.compat.c | 34 ++++----- tests/expectations/tag/constant_big.c | 8 +- tests/expectations/tag/constant_big.compat.c | 8 +- tests/expectations/tag/constant_constexpr.c | 4 +- .../tag/constant_constexpr.compat.c | 4 +- tests/expectations/tag/expand_features.c | 4 +- .../expectations/tag/expand_features.compat.c | 4 +- tests/expectations/tag/extern.c | 4 +- tests/expectations/tag/extern.compat.c | 4 +- tests/expectations/tag/fns.c | 4 +- tests/expectations/tag/fns.compat.c | 4 +- tests/expectations/tag/function_args.c | 4 +- tests/expectations/tag/function_args.compat.c | 4 +- tests/expectations/tag/global_variable.c | 4 +- .../expectations/tag/global_variable.compat.c | 4 +- tests/expectations/tag/mod_attr.c | 16 ++-- tests/expectations/tag/mod_attr.compat.c | 22 +++--- tests/expectations/tag/monomorph-2.c | 12 +-- tests/expectations/tag/monomorph-2.compat.c | 12 +-- tests/expectations/tag/nonnull_attribute.c | 28 +++---- .../tag/nonnull_attribute.compat.c | 32 ++++---- tests/expectations/tag/ptrs_as_arrays.c | 4 +- .../expectations/tag/ptrs_as_arrays.compat.c | 4 +- tests/expectations/tag/rename-crate.c | 20 ++--- tests/expectations/tag/rename-crate.compat.c | 20 ++--- tests/expectations/tag/static.c | 4 +- tests/expectations/tag/static.compat.c | 4 +- tests/expectations/tag/swift_name.c | 46 +++++------ tests/expectations/tag/swift_name.compat.c | 48 ++++++------ tests/rust/constant_sort_name.toml | 2 + tests/rust/constant_sort_none.toml | 2 - tests/rust/function_sort_name.toml | 2 + tests/rust/function_sort_none.toml | 2 - 118 files changed, 772 insertions(+), 772 deletions(-) create mode 100644 tests/rust/constant_sort_name.toml delete mode 100644 tests/rust/constant_sort_none.toml create mode 100644 tests/rust/function_sort_name.toml delete mode 100644 tests/rust/function_sort_none.toml diff --git a/docs.md b/docs.md index 4636768..ef817ce 100644 --- a/docs.md +++ b/docs.md @@ -688,8 +688,8 @@ rename_args = "PascalCase" # "Name": sort by the name of the function # "None": keep order in which the functions have been parsed # -# default: "Name" -sort_by = "None" +# default: "None" +sort_by = "Name" [struct] # A rule to use to rename struct field names. The renaming assumes the input is @@ -890,8 +890,8 @@ allow_constexpr = false # "Name": sort by the name of the constant # "None": keep order in which the constants have been parsed # -# default: "Name" -sort_by = "None" +# default: "None" +sort_by = "Name" diff --git a/src/bindgen/config.rs b/src/bindgen/config.rs index a17e207..9fa762c 100644 --- a/src/bindgen/config.rs +++ b/src/bindgen/config.rs @@ -894,7 +894,7 @@ impl Default for Config { language: Language::Cxx, cpp_compat: false, style: Style::Type, - sort_by: SortKey::Name, + sort_by: SortKey::None, macro_expansion: Default::default(), parse: ParseConfig::default(), export: ExportConfig::default(), diff --git a/tests/expectations/both/box.c b/tests/expectations/both/box.c index 2995f0a..e7f0edb 100644 --- a/tests/expectations/both/box.c +++ b/tests/expectations/both/box.c @@ -17,8 +17,8 @@ typedef struct MyStruct { int32_t *number; } MyStruct; +void root(const Foo *a, const MyStruct *with_box); + void drop_box(int32_t *x); void drop_box_opt(int32_t *x); - -void root(const Foo *a, const MyStruct *with_box); diff --git a/tests/expectations/both/box.compat.c b/tests/expectations/both/box.compat.c index c9479f8..024af3e 100644 --- a/tests/expectations/both/box.compat.c +++ b/tests/expectations/both/box.compat.c @@ -21,12 +21,12 @@ typedef struct MyStruct { extern "C" { #endif // __cplusplus +void root(const Foo *a, const MyStruct *with_box); + void drop_box(int32_t *x); void drop_box_opt(int32_t *x); -void root(const Foo *a, const MyStruct *with_box); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/both/constant.c b/tests/expectations/both/constant.c index fdc7a81..5528f4f 100644 --- a/tests/expectations/both/constant.c +++ b/tests/expectations/both/constant.c @@ -3,19 +3,28 @@ #include #include -#define CAST (uint8_t)'A' +#define FOO 10 #define DELIMITER ':' -#define DOUBLE_CAST (uint32_t)(float)1 +#define LEFTCURLY '{' -#define EQUID U'\U00010083' +#define QUOTE '\'' -#define FOO 10 +#define TAB '\t' + +#define NEWLINE '\n' #define HEART U'\U00002764' -#define LEFTCURLY '{' +#define EQUID U'\U00010083' + +#define ZOM 3.14 + +/** + * A single-line doc comment. + */ +#define POS_ONE 1 /** * A @@ -25,26 +34,17 @@ */ #define NEG_ONE -1 -#define NEWLINE '\n' - -/** - * A single-line doc comment. - */ -#define POS_ONE 1 - -#define QUOTE '\'' - #define SHIFT 3 -#define TAB '\t' - #define XBOOL 1 #define XFALSE ((0 << SHIFT) | XBOOL) #define XTRUE (1 << (SHIFT | XBOOL)) -#define ZOM 3.14 +#define CAST (uint8_t)'A' + +#define DOUBLE_CAST (uint32_t)(float)1 typedef struct Foo { int32_t x[FOO]; diff --git a/tests/expectations/both/constant.compat.c b/tests/expectations/both/constant.compat.c index c2074c1..941b77b 100644 --- a/tests/expectations/both/constant.compat.c +++ b/tests/expectations/both/constant.compat.c @@ -3,19 +3,28 @@ #include #include -#define CAST (uint8_t)'A' +#define FOO 10 #define DELIMITER ':' -#define DOUBLE_CAST (uint32_t)(float)1 +#define LEFTCURLY '{' -#define EQUID U'\U00010083' +#define QUOTE '\'' -#define FOO 10 +#define TAB '\t' + +#define NEWLINE '\n' #define HEART U'\U00002764' -#define LEFTCURLY '{' +#define EQUID U'\U00010083' + +#define ZOM 3.14 + +/** + * A single-line doc comment. + */ +#define POS_ONE 1 /** * A @@ -25,26 +34,17 @@ */ #define NEG_ONE -1 -#define NEWLINE '\n' - -/** - * A single-line doc comment. - */ -#define POS_ONE 1 - -#define QUOTE '\'' - #define SHIFT 3 -#define TAB '\t' - #define XBOOL 1 #define XFALSE ((0 << SHIFT) | XBOOL) #define XTRUE (1 << (SHIFT | XBOOL)) -#define ZOM 3.14 +#define CAST (uint8_t)'A' + +#define DOUBLE_CAST (uint32_t)(float)1 typedef struct Foo { int32_t x[FOO]; diff --git a/tests/expectations/both/constant_big.c b/tests/expectations/both/constant_big.c index 469bf31..86867df 100644 --- a/tests/expectations/both/constant_big.c +++ b/tests/expectations/both/constant_big.c @@ -3,10 +3,10 @@ #include #include -#define SIGNED_DOESNT_NEED_ULL_SUFFIX -9223372036854775807 - -#define SIGNED_NEEDS_ULL_SUFFIX -9223372036854775808ULL +#define UNSIGNED_NEEDS_ULL_SUFFIX 9223372036854775808ULL #define UNSIGNED_DOESNT_NEED_ULL_SUFFIX 8070450532247928832 -#define UNSIGNED_NEEDS_ULL_SUFFIX 9223372036854775808ULL +#define SIGNED_NEEDS_ULL_SUFFIX -9223372036854775808ULL + +#define SIGNED_DOESNT_NEED_ULL_SUFFIX -9223372036854775807 diff --git a/tests/expectations/both/constant_big.compat.c b/tests/expectations/both/constant_big.compat.c index 469bf31..86867df 100644 --- a/tests/expectations/both/constant_big.compat.c +++ b/tests/expectations/both/constant_big.compat.c @@ -3,10 +3,10 @@ #include #include -#define SIGNED_DOESNT_NEED_ULL_SUFFIX -9223372036854775807 - -#define SIGNED_NEEDS_ULL_SUFFIX -9223372036854775808ULL +#define UNSIGNED_NEEDS_ULL_SUFFIX 9223372036854775808ULL #define UNSIGNED_DOESNT_NEED_ULL_SUFFIX 8070450532247928832 -#define UNSIGNED_NEEDS_ULL_SUFFIX 9223372036854775808ULL +#define SIGNED_NEEDS_ULL_SUFFIX -9223372036854775808ULL + +#define SIGNED_DOESNT_NEED_ULL_SUFFIX -9223372036854775807 diff --git a/tests/expectations/both/constant_constexpr.c b/tests/expectations/both/constant_constexpr.c index 980e1b5..77e9b48 100644 --- a/tests/expectations/both/constant_constexpr.c +++ b/tests/expectations/both/constant_constexpr.c @@ -3,10 +3,10 @@ #include #include -#define CONSTANT_FLOAT32 312.292 - #define CONSTANT_I64 216 +#define CONSTANT_FLOAT32 312.292 + #define DELIMITER ':' #define LEFTCURLY '{' diff --git a/tests/expectations/both/constant_constexpr.compat.c b/tests/expectations/both/constant_constexpr.compat.c index 980e1b5..77e9b48 100644 --- a/tests/expectations/both/constant_constexpr.compat.c +++ b/tests/expectations/both/constant_constexpr.compat.c @@ -3,10 +3,10 @@ #include #include -#define CONSTANT_FLOAT32 312.292 - #define CONSTANT_I64 216 +#define CONSTANT_FLOAT32 312.292 + #define DELIMITER ':' #define LEFTCURLY '{' diff --git a/tests/expectations/both/expand_features.c b/tests/expectations/both/expand_features.c index dda28f5..04118cb 100644 --- a/tests/expectations/both/expand_features.c +++ b/tests/expectations/both/expand_features.c @@ -7,8 +7,8 @@ typedef struct Foo { } Foo; -void cbindgen(void); - void extra_debug_fn(void); +void cbindgen(void); + void root(Foo a); diff --git a/tests/expectations/both/expand_features.compat.c b/tests/expectations/both/expand_features.compat.c index 9a2d123..8d5a336 100644 --- a/tests/expectations/both/expand_features.compat.c +++ b/tests/expectations/both/expand_features.compat.c @@ -11,10 +11,10 @@ typedef struct Foo { extern "C" { #endif // __cplusplus -void cbindgen(void); - void extra_debug_fn(void); +void cbindgen(void); + void root(Foo a); #ifdef __cplusplus diff --git a/tests/expectations/both/extern.c b/tests/expectations/both/extern.c index 045f0bd..d80d656 100644 --- a/tests/expectations/both/extern.c +++ b/tests/expectations/both/extern.c @@ -8,6 +8,6 @@ typedef struct Normal { float y; } Normal; -extern void bar(Normal a); - extern int32_t foo(void); + +extern void bar(Normal a); diff --git a/tests/expectations/both/extern.compat.c b/tests/expectations/both/extern.compat.c index 1aa5e70..5f772bc 100644 --- a/tests/expectations/both/extern.compat.c +++ b/tests/expectations/both/extern.compat.c @@ -12,10 +12,10 @@ typedef struct Normal { extern "C" { #endif // __cplusplus -extern void bar(Normal a); - extern int32_t foo(void); +extern void bar(Normal a); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/both/fns.c b/tests/expectations/both/fns.c index 715cc49..747fadd 100644 --- a/tests/expectations/both/fns.c +++ b/tests/expectations/both/fns.c @@ -11,6 +11,6 @@ typedef struct Fns { int8_t (*namedArgsWildcards)(int32_t _, int16_t named, int64_t _1); } Fns; -void no_return(void); - void root(Fns _fns); + +void no_return(void); diff --git a/tests/expectations/both/fns.compat.c b/tests/expectations/both/fns.compat.c index d203651..5a94182 100644 --- a/tests/expectations/both/fns.compat.c +++ b/tests/expectations/both/fns.compat.c @@ -15,10 +15,10 @@ typedef struct Fns { extern "C" { #endif // __cplusplus -void no_return(void); - void root(Fns _fns); +void no_return(void); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/both/function_args.c b/tests/expectations/both/function_args.c index 811a1d3..ce46f98 100644 --- a/tests/expectations/both/function_args.c +++ b/tests/expectations/both/function_args.c @@ -3,8 +3,8 @@ #include #include +void unnamed(const uint64_t*); + void pointer_test(const uint64_t *a); void print_from_rust(void); - -void unnamed(const uint64_t*); diff --git a/tests/expectations/both/function_args.compat.c b/tests/expectations/both/function_args.compat.c index c3a2aef..7f9f24b 100644 --- a/tests/expectations/both/function_args.compat.c +++ b/tests/expectations/both/function_args.compat.c @@ -7,12 +7,12 @@ extern "C" { #endif // __cplusplus +void unnamed(const uint64_t*); + void pointer_test(const uint64_t *a); void print_from_rust(void); -void unnamed(const uint64_t*); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/both/global_variable.c b/tests/expectations/both/global_variable.c index e6cdb4c..2c165e3 100644 --- a/tests/expectations/both/global_variable.c +++ b/tests/expectations/both/global_variable.c @@ -3,6 +3,6 @@ #include #include -extern const char CONST_GLOBAL_ARRAY[128]; - extern char MUT_GLOBAL_ARRAY[128]; + +extern const char CONST_GLOBAL_ARRAY[128]; diff --git a/tests/expectations/both/global_variable.compat.c b/tests/expectations/both/global_variable.compat.c index e0bc032..ee7b9d1 100644 --- a/tests/expectations/both/global_variable.compat.c +++ b/tests/expectations/both/global_variable.compat.c @@ -7,10 +7,10 @@ extern "C" { #endif // __cplusplus -extern const char CONST_GLOBAL_ARRAY[128]; - extern char MUT_GLOBAL_ARRAY[128]; +extern const char CONST_GLOBAL_ARRAY[128]; + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/both/mod_attr.c b/tests/expectations/both/mod_attr.c index 9937efa..c9815c0 100644 --- a/tests/expectations/both/mod_attr.c +++ b/tests/expectations/both/mod_attr.c @@ -3,18 +3,12 @@ #include #include -#if defined(BAR) -#define BAR 2 -#endif - #if defined(FOO) #define FOO 1 #endif #if defined(BAR) -typedef struct Bar { - -} Bar; +#define BAR 2 #endif #if defined(FOO) @@ -24,9 +18,15 @@ typedef struct Foo { #endif #if defined(BAR) -void bar(const Bar *bar); +typedef struct Bar { + +} Bar; #endif #if defined(FOO) void foo(const Foo *foo); #endif + +#if defined(BAR) +void bar(const Bar *bar); +#endif diff --git a/tests/expectations/both/mod_attr.compat.c b/tests/expectations/both/mod_attr.compat.c index 3ba1e75..fcf178f 100644 --- a/tests/expectations/both/mod_attr.compat.c +++ b/tests/expectations/both/mod_attr.compat.c @@ -3,18 +3,12 @@ #include #include -#if defined(BAR) -#define BAR 2 -#endif - #if defined(FOO) #define FOO 1 #endif #if defined(BAR) -typedef struct Bar { - -} Bar; +#define BAR 2 #endif #if defined(FOO) @@ -23,18 +17,24 @@ typedef struct Foo { } Foo; #endif +#if defined(BAR) +typedef struct Bar { + +} Bar; +#endif + #ifdef __cplusplus extern "C" { #endif // __cplusplus -#if defined(BAR) -void bar(const Bar *bar); -#endif - #if defined(FOO) void foo(const Foo *foo); #endif +#if defined(BAR) +void bar(const Bar *bar); +#endif + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/both/monomorph-2.c b/tests/expectations/both/monomorph-2.c index 813cf06..4803e9b 100644 --- a/tests/expectations/both/monomorph-2.c +++ b/tests/expectations/both/monomorph-2.c @@ -7,16 +7,16 @@ typedef struct A A; typedef struct B B; -typedef struct List_B { - B *members; - uintptr_t count; -} List_B; - typedef struct List_A { A *members; uintptr_t count; } List_A; -void bar(List_B b); +typedef struct List_B { + B *members; + uintptr_t count; +} List_B; void foo(List_A a); + +void bar(List_B b); diff --git a/tests/expectations/both/monomorph-2.compat.c b/tests/expectations/both/monomorph-2.compat.c index 3269d44..1a8e5ea 100644 --- a/tests/expectations/both/monomorph-2.compat.c +++ b/tests/expectations/both/monomorph-2.compat.c @@ -7,24 +7,24 @@ typedef struct A A; typedef struct B B; -typedef struct List_B { - B *members; - uintptr_t count; -} List_B; - typedef struct List_A { A *members; uintptr_t count; } List_A; +typedef struct List_B { + B *members; + uintptr_t count; +} List_B; + #ifdef __cplusplus extern "C" { #endif // __cplusplus -void bar(List_B b); - void foo(List_A a); +void bar(List_B b); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/both/nonnull_attribute.c b/tests/expectations/both/nonnull_attribute.c index ffd8063..34409c0 100644 --- a/tests/expectations/both/nonnull_attribute.c +++ b/tests/expectations/both/nonnull_attribute.c @@ -12,6 +12,13 @@ typedef struct Opaque Opaque; +typedef struct References { + const Opaque *CBINDGEN_NONNULL a; + Opaque *CBINDGEN_NONNULL b; + const Opaque *c; + Opaque *d; +} References; + typedef struct Pointers_u64 { float *CBINDGEN_NONNULL a; uint64_t *CBINDGEN_NONNULL b; @@ -26,27 +33,20 @@ typedef struct Pointers_u64 { uint64_t *k; } Pointers_u64; -typedef struct References { - const Opaque *CBINDGEN_NONNULL a; - Opaque *CBINDGEN_NONNULL b; - const Opaque *c; - Opaque *d; -} References; - -void mut_ref_arg(Pointers_u64 *CBINDGEN_NONNULL arg); +void value_arg(References arg); void mutltiple_args(int32_t *CBINDGEN_NONNULL arg, Pointers_u64 *foo, Opaque *CBINDGEN_NONNULL *CBINDGEN_NONNULL d); -void nullable_const_ptr(const Pointers_u64 *arg); +void ref_arg(const Pointers_u64 *CBINDGEN_NONNULL arg); -void nullable_mut_ptr(Pointers_u64 *arg); - -void optional_mut_ref_arg(Pointers_u64 *arg); +void mut_ref_arg(Pointers_u64 *CBINDGEN_NONNULL arg); void optional_ref_arg(const Pointers_u64 *arg); -void ref_arg(const Pointers_u64 *CBINDGEN_NONNULL arg); +void optional_mut_ref_arg(Pointers_u64 *arg); -void value_arg(References arg); +void nullable_const_ptr(const Pointers_u64 *arg); + +void nullable_mut_ptr(Pointers_u64 *arg); diff --git a/tests/expectations/both/nonnull_attribute.compat.c b/tests/expectations/both/nonnull_attribute.compat.c index 75d0c02..1eb452d 100644 --- a/tests/expectations/both/nonnull_attribute.compat.c +++ b/tests/expectations/both/nonnull_attribute.compat.c @@ -12,6 +12,13 @@ typedef struct Opaque Opaque; +typedef struct References { + const Opaque *CBINDGEN_NONNULL a; + Opaque *CBINDGEN_NONNULL b; + const Opaque *c; + Opaque *d; +} References; + typedef struct Pointers_u64 { float *CBINDGEN_NONNULL a; uint64_t *CBINDGEN_NONNULL b; @@ -26,35 +33,28 @@ typedef struct Pointers_u64 { uint64_t *k; } Pointers_u64; -typedef struct References { - const Opaque *CBINDGEN_NONNULL a; - Opaque *CBINDGEN_NONNULL b; - const Opaque *c; - Opaque *d; -} References; - #ifdef __cplusplus extern "C" { #endif // __cplusplus -void mut_ref_arg(Pointers_u64 *CBINDGEN_NONNULL arg); +void value_arg(References arg); void mutltiple_args(int32_t *CBINDGEN_NONNULL arg, Pointers_u64 *foo, Opaque *CBINDGEN_NONNULL *CBINDGEN_NONNULL d); +void ref_arg(const Pointers_u64 *CBINDGEN_NONNULL arg); + +void mut_ref_arg(Pointers_u64 *CBINDGEN_NONNULL 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); -void optional_mut_ref_arg(Pointers_u64 *arg); - -void optional_ref_arg(const Pointers_u64 *arg); - -void ref_arg(const Pointers_u64 *CBINDGEN_NONNULL arg); - -void value_arg(References arg); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/both/ptrs_as_arrays.c b/tests/expectations/both/ptrs_as_arrays.c index 75aca35..4c47d3e 100644 --- a/tests/expectations/both/ptrs_as_arrays.c +++ b/tests/expectations/both/ptrs_as_arrays.c @@ -9,6 +9,6 @@ void ptr_as_array1(uint32_t n, const uint32_t arg[3], uint64_t v[4]); void ptr_as_array2(uint32_t n, uint32_t arg[], const uint64_t v[]); -void ptr_as_array_unnamed(uint32_t*, const uint32_t*); - void ptr_as_array_wrong_syntax(uint32_t *arg, const uint32_t *v, const uint32_t*); + +void ptr_as_array_unnamed(uint32_t*, const uint32_t*); diff --git a/tests/expectations/both/ptrs_as_arrays.compat.c b/tests/expectations/both/ptrs_as_arrays.compat.c index 0ccf6cc..ec6b905 100644 --- a/tests/expectations/both/ptrs_as_arrays.compat.c +++ b/tests/expectations/both/ptrs_as_arrays.compat.c @@ -13,10 +13,10 @@ void ptr_as_array1(uint32_t n, const uint32_t arg[3], uint64_t v[4]); void ptr_as_array2(uint32_t n, uint32_t arg[], const uint64_t v[]); -void ptr_as_array_unnamed(uint32_t*, const uint32_t*); - void ptr_as_array_wrong_syntax(uint32_t *arg, const uint32_t *v, const uint32_t*); +void ptr_as_array_unnamed(uint32_t*, const uint32_t*); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/both/rename-crate.c b/tests/expectations/both/rename-crate.c index 9b35df8..0e23f84 100644 --- a/tests/expectations/both/rename-crate.c +++ b/tests/expectations/both/rename-crate.c @@ -3,6 +3,14 @@ #include #include +typedef struct Foo { + int32_t x; +} Foo; + +typedef struct RenamedTy { + uint64_t y; +} RenamedTy; + #if !defined(DEFINE_FREEBSD) typedef struct NoExternTy { uint8_t field; @@ -21,16 +29,8 @@ typedef struct ContainsNoExternTy { } ContainsNoExternTy; #endif -typedef struct RenamedTy { - uint64_t y; -} RenamedTy; - -typedef struct Foo { - int32_t x; -} Foo; - -void no_extern_func(ContainsNoExternTy a); +void root(Foo a); void renamed_func(RenamedTy a); -void root(Foo a); +void no_extern_func(ContainsNoExternTy a); diff --git a/tests/expectations/both/rename-crate.compat.c b/tests/expectations/both/rename-crate.compat.c index d0ae751..ba818bf 100644 --- a/tests/expectations/both/rename-crate.compat.c +++ b/tests/expectations/both/rename-crate.compat.c @@ -3,6 +3,14 @@ #include #include +typedef struct Foo { + int32_t x; +} Foo; + +typedef struct RenamedTy { + uint64_t y; +} RenamedTy; + #if !defined(DEFINE_FREEBSD) typedef struct NoExternTy { uint8_t field; @@ -21,23 +29,15 @@ typedef struct ContainsNoExternTy { } ContainsNoExternTy; #endif -typedef struct RenamedTy { - uint64_t y; -} RenamedTy; - -typedef struct Foo { - int32_t x; -} Foo; - #ifdef __cplusplus extern "C" { #endif // __cplusplus -void no_extern_func(ContainsNoExternTy a); +void root(Foo a); void renamed_func(RenamedTy a); -void root(Foo a); +void no_extern_func(ContainsNoExternTy a); #ifdef __cplusplus } // extern "C" diff --git a/tests/expectations/both/static.c b/tests/expectations/both/static.c index 6ca869c..98910fb 100644 --- a/tests/expectations/both/static.c +++ b/tests/expectations/both/static.c @@ -9,10 +9,10 @@ typedef struct Foo { } Foo; -extern const Bar BAR; +extern const int32_t NUMBER; extern Foo FOO; -extern const int32_t NUMBER; +extern const Bar BAR; void root(void); diff --git a/tests/expectations/both/static.compat.c b/tests/expectations/both/static.compat.c index debfe8f..d861cd3 100644 --- a/tests/expectations/both/static.compat.c +++ b/tests/expectations/both/static.compat.c @@ -13,11 +13,11 @@ typedef struct Foo { extern "C" { #endif // __cplusplus -extern const Bar BAR; +extern const int32_t NUMBER; extern Foo FOO; -extern const int32_t NUMBER; +extern const Bar BAR; void root(void); diff --git a/tests/expectations/both/swift_name.c b/tests/expectations/both/swift_name.c index f4c8e39..dca90ac 100644 --- a/tests/expectations/both/swift_name.c +++ b/tests/expectations/both/swift_name.c @@ -7,49 +7,49 @@ typedef struct Opaque Opaque; -typedef struct PointerToOpaque { - Opaque *ptr; -} PointerToOpaque; - typedef struct SelfTypeTestStruct { uint8_t times; } SelfTypeTestStruct; -PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); +typedef struct PointerToOpaque { + Opaque *ptr; +} PointerToOpaque; -void PointerToOpaque_sayHello(PointerToOpaque self) -/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); - -void SelfTypeTestStruct_should_exist_annotated_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); - -void SelfTypeTestStruct_should_exist_annotated_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); - -void SelfTypeTestStruct_should_exist_mut_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); +void rust_print_hello_world(void) CF_SWIFT_NAME(rust_print_hello_world()); void SelfTypeTestStruct_should_exist_ref(const SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref(self:)); void SelfTypeTestStruct_should_exist_ref_mut(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref_mut(self:)); -void SelfTypeTestStruct_should_exist_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); - void SelfTypeTestStruct_should_not_exist_box(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_box(self:)); SelfTypeTestStruct *SelfTypeTestStruct_should_not_exist_return_box(void) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_return_box()); -void free_function_should_exist_annotated_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); +void SelfTypeTestStruct_should_exist_annotated_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); -void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); +void SelfTypeTestStruct_should_exist_annotated_mut_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); + +void SelfTypeTestStruct_should_exist_annotated_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); + +void SelfTypeTestStruct_should_exist_annotated_mut_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); + +void SelfTypeTestStruct_should_exist_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); + +void SelfTypeTestStruct_should_exist_mut_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); void free_function_should_exist_ref(const SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref(test_struct:)); void free_function_should_exist_ref_mut(SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref_mut(test_struct:)); +void unnamed_argument(SelfTypeTestStruct*); + void free_function_should_not_exist_box(SelfTypeTestStruct *boxed) CF_SWIFT_NAME(free_function_should_not_exist_box(boxed:)); -void rust_print_hello_world(void) CF_SWIFT_NAME(rust_print_hello_world()); +void free_function_should_exist_annotated_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); -void unnamed_argument(SelfTypeTestStruct*); +void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); + +PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); + +void PointerToOpaque_sayHello(PointerToOpaque self) +/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); diff --git a/tests/expectations/both/swift_name.compat.c b/tests/expectations/both/swift_name.compat.c index bd3def4..99caec2 100644 --- a/tests/expectations/both/swift_name.compat.c +++ b/tests/expectations/both/swift_name.compat.c @@ -7,57 +7,57 @@ typedef struct Opaque Opaque; -typedef struct PointerToOpaque { - Opaque *ptr; -} PointerToOpaque; - typedef struct SelfTypeTestStruct { uint8_t times; } SelfTypeTestStruct; +typedef struct PointerToOpaque { + Opaque *ptr; +} PointerToOpaque; + #ifdef __cplusplus extern "C" { #endif // __cplusplus +void rust_print_hello_world(void) CF_SWIFT_NAME(rust_print_hello_world()); + +void SelfTypeTestStruct_should_exist_ref(const SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref(self:)); + +void SelfTypeTestStruct_should_exist_ref_mut(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref_mut(self:)); + +void SelfTypeTestStruct_should_not_exist_box(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_box(self:)); + +SelfTypeTestStruct *SelfTypeTestStruct_should_not_exist_return_box(void) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_return_box()); + +void SelfTypeTestStruct_should_exist_annotated_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); + +void SelfTypeTestStruct_should_exist_annotated_mut_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); + +void SelfTypeTestStruct_should_exist_annotated_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); + +void SelfTypeTestStruct_should_exist_annotated_mut_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); + +void SelfTypeTestStruct_should_exist_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); + +void SelfTypeTestStruct_should_exist_mut_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); + +void free_function_should_exist_ref(const SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref(test_struct:)); + +void free_function_should_exist_ref_mut(SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref_mut(test_struct:)); + +void unnamed_argument(SelfTypeTestStruct*); + +void free_function_should_not_exist_box(SelfTypeTestStruct *boxed) CF_SWIFT_NAME(free_function_should_not_exist_box(boxed:)); + +void free_function_should_exist_annotated_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); + +void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); + PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); void PointerToOpaque_sayHello(PointerToOpaque self) /*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); -void SelfTypeTestStruct_should_exist_annotated_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); - -void SelfTypeTestStruct_should_exist_annotated_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); - -void SelfTypeTestStruct_should_exist_mut_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); - -void SelfTypeTestStruct_should_exist_ref(const SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref(self:)); - -void SelfTypeTestStruct_should_exist_ref_mut(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref_mut(self:)); - -void SelfTypeTestStruct_should_exist_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); - -void SelfTypeTestStruct_should_not_exist_box(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_box(self:)); - -SelfTypeTestStruct *SelfTypeTestStruct_should_not_exist_return_box(void) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_return_box()); - -void free_function_should_exist_annotated_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); - -void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); - -void free_function_should_exist_ref(const SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref(test_struct:)); - -void free_function_should_exist_ref_mut(SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref_mut(test_struct:)); - -void free_function_should_not_exist_box(SelfTypeTestStruct *boxed) CF_SWIFT_NAME(free_function_should_not_exist_box(boxed:)); - -void rust_print_hello_world(void) CF_SWIFT_NAME(rust_print_hello_world()); - -void unnamed_argument(SelfTypeTestStruct*); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/box.c b/tests/expectations/box.c index 7f94f62..840bfae 100644 --- a/tests/expectations/box.c +++ b/tests/expectations/box.c @@ -17,8 +17,8 @@ typedef struct { int32_t *number; } MyStruct; +void root(const Foo *a, const MyStruct *with_box); + void drop_box(int32_t *x); void drop_box_opt(int32_t *x); - -void root(const Foo *a, const MyStruct *with_box); diff --git a/tests/expectations/box.compat.c b/tests/expectations/box.compat.c index dfce85a..70d62ac 100644 --- a/tests/expectations/box.compat.c +++ b/tests/expectations/box.compat.c @@ -21,12 +21,12 @@ typedef struct { extern "C" { #endif // __cplusplus +void root(const Foo *a, const MyStruct *with_box); + void drop_box(int32_t *x); void drop_box_opt(int32_t *x); -void root(const Foo *a, const MyStruct *with_box); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/box.cpp b/tests/expectations/box.cpp index 842b9ca..ac0bcbe 100644 --- a/tests/expectations/box.cpp +++ b/tests/expectations/box.cpp @@ -24,10 +24,10 @@ struct MyStruct { extern "C" { +void root(const Foo *a, const MyStruct *with_box); + void drop_box(Box x); void drop_box_opt(Option> x); -void root(const Foo *a, const MyStruct *with_box); - } // extern "C" diff --git a/tests/expectations/constant.c b/tests/expectations/constant.c index 8d68c87..3ae4680 100644 --- a/tests/expectations/constant.c +++ b/tests/expectations/constant.c @@ -3,19 +3,28 @@ #include #include -#define CAST (uint8_t)'A' +#define FOO 10 #define DELIMITER ':' -#define DOUBLE_CAST (uint32_t)(float)1 +#define LEFTCURLY '{' -#define EQUID U'\U00010083' +#define QUOTE '\'' -#define FOO 10 +#define TAB '\t' + +#define NEWLINE '\n' #define HEART U'\U00002764' -#define LEFTCURLY '{' +#define EQUID U'\U00010083' + +#define ZOM 3.14 + +/** + * A single-line doc comment. + */ +#define POS_ONE 1 /** * A @@ -25,26 +34,17 @@ */ #define NEG_ONE -1 -#define NEWLINE '\n' - -/** - * A single-line doc comment. - */ -#define POS_ONE 1 - -#define QUOTE '\'' - #define SHIFT 3 -#define TAB '\t' - #define XBOOL 1 #define XFALSE ((0 << SHIFT) | XBOOL) #define XTRUE (1 << (SHIFT | XBOOL)) -#define ZOM 3.14 +#define CAST (uint8_t)'A' + +#define DOUBLE_CAST (uint32_t)(float)1 typedef struct { int32_t x[FOO]; diff --git a/tests/expectations/constant.compat.c b/tests/expectations/constant.compat.c index 618ef4c..654a75e 100644 --- a/tests/expectations/constant.compat.c +++ b/tests/expectations/constant.compat.c @@ -3,19 +3,28 @@ #include #include -#define CAST (uint8_t)'A' +#define FOO 10 #define DELIMITER ':' -#define DOUBLE_CAST (uint32_t)(float)1 +#define LEFTCURLY '{' -#define EQUID U'\U00010083' +#define QUOTE '\'' -#define FOO 10 +#define TAB '\t' + +#define NEWLINE '\n' #define HEART U'\U00002764' -#define LEFTCURLY '{' +#define EQUID U'\U00010083' + +#define ZOM 3.14 + +/** + * A single-line doc comment. + */ +#define POS_ONE 1 /** * A @@ -25,26 +34,17 @@ */ #define NEG_ONE -1 -#define NEWLINE '\n' - -/** - * A single-line doc comment. - */ -#define POS_ONE 1 - -#define QUOTE '\'' - #define SHIFT 3 -#define TAB '\t' - #define XBOOL 1 #define XFALSE ((0 << SHIFT) | XBOOL) #define XTRUE (1 << (SHIFT | XBOOL)) -#define ZOM 3.14 +#define CAST (uint8_t)'A' + +#define DOUBLE_CAST (uint32_t)(float)1 typedef struct { int32_t x[FOO]; diff --git a/tests/expectations/constant.cpp b/tests/expectations/constant.cpp index c6f6691..c8196d3 100644 --- a/tests/expectations/constant.cpp +++ b/tests/expectations/constant.cpp @@ -4,19 +4,26 @@ #include #include -static const uint8_t CAST = (uint8_t)'A'; +static const int32_t FOO = 10; static const uint32_t DELIMITER = ':'; -static const uint32_t DOUBLE_CAST = (uint32_t)(float)1; +static const uint32_t LEFTCURLY = '{'; -static const uint32_t EQUID = U'\U00010083'; +static const uint32_t QUOTE = '\''; -static const int32_t FOO = 10; +static const uint32_t TAB = '\t'; + +static const uint32_t NEWLINE = '\n'; static const uint32_t HEART = U'\U00002764'; -static const uint32_t LEFTCURLY = '{'; +static const uint32_t EQUID = U'\U00010083'; + +static const float ZOM = 3.14; + +/// A single-line doc comment. +static const int8_t POS_ONE = 1; /// A /// multi-line @@ -24,24 +31,17 @@ static const uint32_t LEFTCURLY = '{'; /// comment. static const int8_t NEG_ONE = -1; -static const uint32_t NEWLINE = '\n'; - -/// A single-line doc comment. -static const int8_t POS_ONE = 1; - -static const uint32_t QUOTE = '\''; - static const int64_t SHIFT = 3; -static const uint32_t TAB = '\t'; - static const int64_t XBOOL = 1; static const int64_t XFALSE = ((0 << SHIFT) | XBOOL); static const int64_t XTRUE = (1 << (SHIFT | XBOOL)); -static const float ZOM = 3.14; +static const uint8_t CAST = (uint8_t)'A'; + +static const uint32_t DOUBLE_CAST = (uint32_t)(float)1; struct Foo { int32_t x[FOO]; diff --git a/tests/expectations/constant_big.c b/tests/expectations/constant_big.c index 469bf31..86867df 100644 --- a/tests/expectations/constant_big.c +++ b/tests/expectations/constant_big.c @@ -3,10 +3,10 @@ #include #include -#define SIGNED_DOESNT_NEED_ULL_SUFFIX -9223372036854775807 - -#define SIGNED_NEEDS_ULL_SUFFIX -9223372036854775808ULL +#define UNSIGNED_NEEDS_ULL_SUFFIX 9223372036854775808ULL #define UNSIGNED_DOESNT_NEED_ULL_SUFFIX 8070450532247928832 -#define UNSIGNED_NEEDS_ULL_SUFFIX 9223372036854775808ULL +#define SIGNED_NEEDS_ULL_SUFFIX -9223372036854775808ULL + +#define SIGNED_DOESNT_NEED_ULL_SUFFIX -9223372036854775807 diff --git a/tests/expectations/constant_big.compat.c b/tests/expectations/constant_big.compat.c index 469bf31..86867df 100644 --- a/tests/expectations/constant_big.compat.c +++ b/tests/expectations/constant_big.compat.c @@ -3,10 +3,10 @@ #include #include -#define SIGNED_DOESNT_NEED_ULL_SUFFIX -9223372036854775807 - -#define SIGNED_NEEDS_ULL_SUFFIX -9223372036854775808ULL +#define UNSIGNED_NEEDS_ULL_SUFFIX 9223372036854775808ULL #define UNSIGNED_DOESNT_NEED_ULL_SUFFIX 8070450532247928832 -#define UNSIGNED_NEEDS_ULL_SUFFIX 9223372036854775808ULL +#define SIGNED_NEEDS_ULL_SUFFIX -9223372036854775808ULL + +#define SIGNED_DOESNT_NEED_ULL_SUFFIX -9223372036854775807 diff --git a/tests/expectations/constant_big.cpp b/tests/expectations/constant_big.cpp index f4c7e20..2b5b87a 100644 --- a/tests/expectations/constant_big.cpp +++ b/tests/expectations/constant_big.cpp @@ -4,10 +4,10 @@ #include #include -static const int64_t SIGNED_DOESNT_NEED_ULL_SUFFIX = -9223372036854775807; - -static const int64_t SIGNED_NEEDS_ULL_SUFFIX = -9223372036854775808ULL; +static const uint64_t UNSIGNED_NEEDS_ULL_SUFFIX = 9223372036854775808ULL; static const uint64_t UNSIGNED_DOESNT_NEED_ULL_SUFFIX = 8070450532247928832; -static const uint64_t UNSIGNED_NEEDS_ULL_SUFFIX = 9223372036854775808ULL; +static const int64_t SIGNED_NEEDS_ULL_SUFFIX = -9223372036854775808ULL; + +static const int64_t SIGNED_DOESNT_NEED_ULL_SUFFIX = -9223372036854775807; diff --git a/tests/expectations/constant_constexpr.c b/tests/expectations/constant_constexpr.c index ba07c00..a389d06 100644 --- a/tests/expectations/constant_constexpr.c +++ b/tests/expectations/constant_constexpr.c @@ -3,10 +3,10 @@ #include #include -#define CONSTANT_FLOAT32 312.292 - #define CONSTANT_I64 216 +#define CONSTANT_FLOAT32 312.292 + #define DELIMITER ':' #define LEFTCURLY '{' diff --git a/tests/expectations/constant_constexpr.compat.c b/tests/expectations/constant_constexpr.compat.c index ba07c00..a389d06 100644 --- a/tests/expectations/constant_constexpr.compat.c +++ b/tests/expectations/constant_constexpr.compat.c @@ -3,10 +3,10 @@ #include #include -#define CONSTANT_FLOAT32 312.292 - #define CONSTANT_I64 216 +#define CONSTANT_FLOAT32 312.292 + #define DELIMITER ':' #define LEFTCURLY '{' diff --git a/tests/expectations/constant_constexpr.cpp b/tests/expectations/constant_constexpr.cpp index eba7267..9870a1e 100644 --- a/tests/expectations/constant_constexpr.cpp +++ b/tests/expectations/constant_constexpr.cpp @@ -4,10 +4,10 @@ #include #include -constexpr static const float CONSTANT_FLOAT32 = 312.292; - constexpr static const int64_t CONSTANT_I64 = 216; +constexpr static const float CONSTANT_FLOAT32 = 312.292; + constexpr static const uint32_t DELIMITER = ':'; constexpr static const uint32_t LEFTCURLY = '{'; diff --git a/tests/expectations/expand_features.c b/tests/expectations/expand_features.c index f092aa9..e0a440c 100644 --- a/tests/expectations/expand_features.c +++ b/tests/expectations/expand_features.c @@ -7,8 +7,8 @@ typedef struct { } Foo; -void cbindgen(void); - void extra_debug_fn(void); +void cbindgen(void); + void root(Foo a); diff --git a/tests/expectations/expand_features.compat.c b/tests/expectations/expand_features.compat.c index 3f91369..b65adc0 100644 --- a/tests/expectations/expand_features.compat.c +++ b/tests/expectations/expand_features.compat.c @@ -11,10 +11,10 @@ typedef struct { extern "C" { #endif // __cplusplus -void cbindgen(void); - void extra_debug_fn(void); +void cbindgen(void); + void root(Foo a); #ifdef __cplusplus diff --git a/tests/expectations/expand_features.cpp b/tests/expectations/expand_features.cpp index f0e5a99..9174b12 100644 --- a/tests/expectations/expand_features.cpp +++ b/tests/expectations/expand_features.cpp @@ -10,10 +10,10 @@ struct Foo { extern "C" { -void cbindgen(); - void extra_debug_fn(); +void cbindgen(); + void root(Foo a); } // extern "C" diff --git a/tests/expectations/extern.c b/tests/expectations/extern.c index 88b7dd0..6fe9f5b 100644 --- a/tests/expectations/extern.c +++ b/tests/expectations/extern.c @@ -8,6 +8,6 @@ typedef struct { float y; } Normal; -extern void bar(Normal a); - extern int32_t foo(void); + +extern void bar(Normal a); diff --git a/tests/expectations/extern.compat.c b/tests/expectations/extern.compat.c index 1aab3e9..4f4129a 100644 --- a/tests/expectations/extern.compat.c +++ b/tests/expectations/extern.compat.c @@ -12,10 +12,10 @@ typedef struct { extern "C" { #endif // __cplusplus -extern void bar(Normal a); - extern int32_t foo(void); +extern void bar(Normal a); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/extern.cpp b/tests/expectations/extern.cpp index f5403d4..15294c0 100644 --- a/tests/expectations/extern.cpp +++ b/tests/expectations/extern.cpp @@ -11,8 +11,8 @@ struct Normal { extern "C" { -extern void bar(Normal a); - extern int32_t foo(); +extern void bar(Normal a); + } // extern "C" diff --git a/tests/expectations/fns.c b/tests/expectations/fns.c index ad86f93..e1910f8 100644 --- a/tests/expectations/fns.c +++ b/tests/expectations/fns.c @@ -11,6 +11,6 @@ typedef struct { int8_t (*namedArgsWildcards)(int32_t _, int16_t named, int64_t _1); } Fns; -void no_return(void); - void root(Fns _fns); + +void no_return(void); diff --git a/tests/expectations/fns.compat.c b/tests/expectations/fns.compat.c index 4000b21..f61419c 100644 --- a/tests/expectations/fns.compat.c +++ b/tests/expectations/fns.compat.c @@ -15,10 +15,10 @@ typedef struct { extern "C" { #endif // __cplusplus -void no_return(void); - void root(Fns _fns); +void no_return(void); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/fns.cpp b/tests/expectations/fns.cpp index 81bd2f4..1e52496 100644 --- a/tests/expectations/fns.cpp +++ b/tests/expectations/fns.cpp @@ -14,8 +14,8 @@ struct Fns { extern "C" { -void no_return(); - void root(Fns _fns); +void no_return(); + } // extern "C" diff --git a/tests/expectations/function_args.c b/tests/expectations/function_args.c index 811a1d3..ce46f98 100644 --- a/tests/expectations/function_args.c +++ b/tests/expectations/function_args.c @@ -3,8 +3,8 @@ #include #include +void unnamed(const uint64_t*); + void pointer_test(const uint64_t *a); void print_from_rust(void); - -void unnamed(const uint64_t*); diff --git a/tests/expectations/function_args.compat.c b/tests/expectations/function_args.compat.c index c3a2aef..7f9f24b 100644 --- a/tests/expectations/function_args.compat.c +++ b/tests/expectations/function_args.compat.c @@ -7,12 +7,12 @@ extern "C" { #endif // __cplusplus +void unnamed(const uint64_t*); + void pointer_test(const uint64_t *a); void print_from_rust(void); -void unnamed(const uint64_t*); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/function_args.cpp b/tests/expectations/function_args.cpp index f991782..903f1bb 100644 --- a/tests/expectations/function_args.cpp +++ b/tests/expectations/function_args.cpp @@ -6,10 +6,10 @@ extern "C" { +void unnamed(const uint64_t*); + void pointer_test(const uint64_t *a); void print_from_rust(); -void unnamed(const uint64_t*); - } // extern "C" diff --git a/tests/expectations/global_variable.c b/tests/expectations/global_variable.c index e6cdb4c..2c165e3 100644 --- a/tests/expectations/global_variable.c +++ b/tests/expectations/global_variable.c @@ -3,6 +3,6 @@ #include #include -extern const char CONST_GLOBAL_ARRAY[128]; - extern char MUT_GLOBAL_ARRAY[128]; + +extern const char CONST_GLOBAL_ARRAY[128]; diff --git a/tests/expectations/global_variable.compat.c b/tests/expectations/global_variable.compat.c index e0bc032..ee7b9d1 100644 --- a/tests/expectations/global_variable.compat.c +++ b/tests/expectations/global_variable.compat.c @@ -7,10 +7,10 @@ extern "C" { #endif // __cplusplus -extern const char CONST_GLOBAL_ARRAY[128]; - extern char MUT_GLOBAL_ARRAY[128]; +extern const char CONST_GLOBAL_ARRAY[128]; + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/global_variable.cpp b/tests/expectations/global_variable.cpp index e397e23..727f28b 100644 --- a/tests/expectations/global_variable.cpp +++ b/tests/expectations/global_variable.cpp @@ -6,8 +6,8 @@ extern "C" { -extern const char CONST_GLOBAL_ARRAY[128]; - extern char MUT_GLOBAL_ARRAY[128]; +extern const char CONST_GLOBAL_ARRAY[128]; + } // extern "C" diff --git a/tests/expectations/mod_attr.c b/tests/expectations/mod_attr.c index 68eeafe..0f41156 100644 --- a/tests/expectations/mod_attr.c +++ b/tests/expectations/mod_attr.c @@ -3,18 +3,12 @@ #include #include -#if defined(BAR) -#define BAR 2 -#endif - #if defined(FOO) #define FOO 1 #endif #if defined(BAR) -typedef struct { - -} Bar; +#define BAR 2 #endif #if defined(FOO) @@ -24,9 +18,15 @@ typedef struct { #endif #if defined(BAR) -void bar(const Bar *bar); +typedef struct { + +} Bar; #endif #if defined(FOO) void foo(const Foo *foo); #endif + +#if defined(BAR) +void bar(const Bar *bar); +#endif diff --git a/tests/expectations/mod_attr.compat.c b/tests/expectations/mod_attr.compat.c index 43dfd66..fded9f0 100644 --- a/tests/expectations/mod_attr.compat.c +++ b/tests/expectations/mod_attr.compat.c @@ -3,18 +3,12 @@ #include #include -#if defined(BAR) -#define BAR 2 -#endif - #if defined(FOO) #define FOO 1 #endif #if defined(BAR) -typedef struct { - -} Bar; +#define BAR 2 #endif #if defined(FOO) @@ -23,18 +17,24 @@ typedef struct { } Foo; #endif +#if defined(BAR) +typedef struct { + +} Bar; +#endif + #ifdef __cplusplus extern "C" { #endif // __cplusplus -#if defined(BAR) -void bar(const Bar *bar); -#endif - #if defined(FOO) void foo(const Foo *foo); #endif +#if defined(BAR) +void bar(const Bar *bar); +#endif + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/mod_attr.cpp b/tests/expectations/mod_attr.cpp index ff91ff1..b49ce70 100644 --- a/tests/expectations/mod_attr.cpp +++ b/tests/expectations/mod_attr.cpp @@ -4,18 +4,12 @@ #include #include -#if defined(BAR) -static const int32_t BAR = 2; -#endif - #if defined(FOO) static const int32_t FOO = 1; #endif #if defined(BAR) -struct Bar { - -}; +static const int32_t BAR = 2; #endif #if defined(FOO) @@ -24,14 +18,20 @@ struct Foo { }; #endif -extern "C" { - #if defined(BAR) -void bar(const Bar *bar); +struct Bar { + +}; #endif +extern "C" { + #if defined(FOO) void foo(const Foo *foo); #endif +#if defined(BAR) +void bar(const Bar *bar); +#endif + } // extern "C" diff --git a/tests/expectations/monomorph-2.c b/tests/expectations/monomorph-2.c index f2ac54b..010a335 100644 --- a/tests/expectations/monomorph-2.c +++ b/tests/expectations/monomorph-2.c @@ -7,16 +7,16 @@ typedef struct A A; typedef struct B B; -typedef struct { - B *members; - uintptr_t count; -} List_B; - typedef struct { A *members; uintptr_t count; } List_A; -void bar(List_B b); +typedef struct { + B *members; + uintptr_t count; +} List_B; void foo(List_A a); + +void bar(List_B b); diff --git a/tests/expectations/monomorph-2.compat.c b/tests/expectations/monomorph-2.compat.c index 6a6aec9..30c66ab 100644 --- a/tests/expectations/monomorph-2.compat.c +++ b/tests/expectations/monomorph-2.compat.c @@ -7,24 +7,24 @@ typedef struct A A; typedef struct B B; -typedef struct { - B *members; - uintptr_t count; -} List_B; - typedef struct { A *members; uintptr_t count; } List_A; +typedef struct { + B *members; + uintptr_t count; +} List_B; + #ifdef __cplusplus extern "C" { #endif // __cplusplus -void bar(List_B b); - void foo(List_A a); +void bar(List_B b); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/monomorph-2.cpp b/tests/expectations/monomorph-2.cpp index a0b59fc..41dde1b 100644 --- a/tests/expectations/monomorph-2.cpp +++ b/tests/expectations/monomorph-2.cpp @@ -16,8 +16,8 @@ struct List { extern "C" { -void bar(List b); - void foo(List a); +void bar(List b); + } // extern "C" diff --git a/tests/expectations/nonnull_attribute.c b/tests/expectations/nonnull_attribute.c index 08488a2..b48a100 100644 --- a/tests/expectations/nonnull_attribute.c +++ b/tests/expectations/nonnull_attribute.c @@ -12,6 +12,13 @@ typedef struct Opaque Opaque; +typedef struct { + const Opaque *CBINDGEN_NONNULL a; + Opaque *CBINDGEN_NONNULL b; + const Opaque *c; + Opaque *d; +} References; + typedef struct { float *CBINDGEN_NONNULL a; uint64_t *CBINDGEN_NONNULL b; @@ -26,27 +33,20 @@ typedef struct { uint64_t *k; } Pointers_u64; -typedef struct { - const Opaque *CBINDGEN_NONNULL a; - Opaque *CBINDGEN_NONNULL b; - const Opaque *c; - Opaque *d; -} References; - -void mut_ref_arg(Pointers_u64 *CBINDGEN_NONNULL arg); +void value_arg(References arg); void mutltiple_args(int32_t *CBINDGEN_NONNULL arg, Pointers_u64 *foo, Opaque *CBINDGEN_NONNULL *CBINDGEN_NONNULL d); -void nullable_const_ptr(const Pointers_u64 *arg); +void ref_arg(const Pointers_u64 *CBINDGEN_NONNULL arg); -void nullable_mut_ptr(Pointers_u64 *arg); - -void optional_mut_ref_arg(Pointers_u64 *arg); +void mut_ref_arg(Pointers_u64 *CBINDGEN_NONNULL arg); void optional_ref_arg(const Pointers_u64 *arg); -void ref_arg(const Pointers_u64 *CBINDGEN_NONNULL arg); +void optional_mut_ref_arg(Pointers_u64 *arg); -void value_arg(References arg); +void nullable_const_ptr(const Pointers_u64 *arg); + +void nullable_mut_ptr(Pointers_u64 *arg); diff --git a/tests/expectations/nonnull_attribute.compat.c b/tests/expectations/nonnull_attribute.compat.c index a49fae5..726b179 100644 --- a/tests/expectations/nonnull_attribute.compat.c +++ b/tests/expectations/nonnull_attribute.compat.c @@ -12,6 +12,13 @@ typedef struct Opaque Opaque; +typedef struct { + const Opaque *CBINDGEN_NONNULL a; + Opaque *CBINDGEN_NONNULL b; + const Opaque *c; + Opaque *d; +} References; + typedef struct { float *CBINDGEN_NONNULL a; uint64_t *CBINDGEN_NONNULL b; @@ -26,35 +33,28 @@ typedef struct { uint64_t *k; } Pointers_u64; -typedef struct { - const Opaque *CBINDGEN_NONNULL a; - Opaque *CBINDGEN_NONNULL b; - const Opaque *c; - Opaque *d; -} References; - #ifdef __cplusplus extern "C" { #endif // __cplusplus -void mut_ref_arg(Pointers_u64 *CBINDGEN_NONNULL arg); +void value_arg(References arg); void mutltiple_args(int32_t *CBINDGEN_NONNULL arg, Pointers_u64 *foo, Opaque *CBINDGEN_NONNULL *CBINDGEN_NONNULL d); +void ref_arg(const Pointers_u64 *CBINDGEN_NONNULL arg); + +void mut_ref_arg(Pointers_u64 *CBINDGEN_NONNULL 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); -void optional_mut_ref_arg(Pointers_u64 *arg); - -void optional_ref_arg(const Pointers_u64 *arg); - -void ref_arg(const Pointers_u64 *CBINDGEN_NONNULL arg); - -void value_arg(References arg); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/nonnull_attribute.cpp b/tests/expectations/nonnull_attribute.cpp index 41861f5..b57592a 100644 --- a/tests/expectations/nonnull_attribute.cpp +++ b/tests/expectations/nonnull_attribute.cpp @@ -13,6 +13,13 @@ struct Opaque; +struct References { + const Opaque *CBINDGEN_NONNULL a; + Opaque *CBINDGEN_NONNULL b; + const Opaque *c; + Opaque *d; +}; + template struct Pointers { float *CBINDGEN_NONNULL a; @@ -28,31 +35,24 @@ struct Pointers { T *k; }; -struct References { - const Opaque *CBINDGEN_NONNULL a; - Opaque *CBINDGEN_NONNULL b; - const Opaque *c; - Opaque *d; -}; - extern "C" { -void mut_ref_arg(Pointers *CBINDGEN_NONNULL arg); +void value_arg(References arg); void mutltiple_args(int32_t *CBINDGEN_NONNULL arg, Pointers *foo, Opaque *CBINDGEN_NONNULL *CBINDGEN_NONNULL d); +void ref_arg(const Pointers *CBINDGEN_NONNULL arg); + +void mut_ref_arg(Pointers *CBINDGEN_NONNULL arg); + +void optional_ref_arg(const Pointers *arg); + +void optional_mut_ref_arg(Pointers *arg); + void nullable_const_ptr(const Pointers *arg); void nullable_mut_ptr(Pointers *arg); -void optional_mut_ref_arg(Pointers *arg); - -void optional_ref_arg(const Pointers *arg); - -void ref_arg(const Pointers *CBINDGEN_NONNULL arg); - -void value_arg(References arg); - } // extern "C" diff --git a/tests/expectations/ptrs_as_arrays.c b/tests/expectations/ptrs_as_arrays.c index 75aca35..4c47d3e 100644 --- a/tests/expectations/ptrs_as_arrays.c +++ b/tests/expectations/ptrs_as_arrays.c @@ -9,6 +9,6 @@ void ptr_as_array1(uint32_t n, const uint32_t arg[3], uint64_t v[4]); void ptr_as_array2(uint32_t n, uint32_t arg[], const uint64_t v[]); -void ptr_as_array_unnamed(uint32_t*, const uint32_t*); - void ptr_as_array_wrong_syntax(uint32_t *arg, const uint32_t *v, const uint32_t*); + +void ptr_as_array_unnamed(uint32_t*, const uint32_t*); diff --git a/tests/expectations/ptrs_as_arrays.compat.c b/tests/expectations/ptrs_as_arrays.compat.c index 0ccf6cc..ec6b905 100644 --- a/tests/expectations/ptrs_as_arrays.compat.c +++ b/tests/expectations/ptrs_as_arrays.compat.c @@ -13,10 +13,10 @@ void ptr_as_array1(uint32_t n, const uint32_t arg[3], uint64_t v[4]); void ptr_as_array2(uint32_t n, uint32_t arg[], const uint64_t v[]); -void ptr_as_array_unnamed(uint32_t*, const uint32_t*); - void ptr_as_array_wrong_syntax(uint32_t *arg, const uint32_t *v, const uint32_t*); +void ptr_as_array_unnamed(uint32_t*, const uint32_t*); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/ptrs_as_arrays.cpp b/tests/expectations/ptrs_as_arrays.cpp index 9cc9817..a4731a0 100644 --- a/tests/expectations/ptrs_as_arrays.cpp +++ b/tests/expectations/ptrs_as_arrays.cpp @@ -12,8 +12,8 @@ void ptr_as_array1(uint32_t n, const uint32_t arg[3], uint64_t v[4]); void ptr_as_array2(uint32_t n, uint32_t arg[], const uint64_t v[]); -void ptr_as_array_unnamed(uint32_t*, const uint32_t*); - void ptr_as_array_wrong_syntax(uint32_t *arg, const uint32_t *v, const uint32_t*); +void ptr_as_array_unnamed(uint32_t*, const uint32_t*); + } // extern "C" diff --git a/tests/expectations/rename-crate.c b/tests/expectations/rename-crate.c index dff0e57..1d37b25 100644 --- a/tests/expectations/rename-crate.c +++ b/tests/expectations/rename-crate.c @@ -3,6 +3,14 @@ #include #include +typedef struct { + int32_t x; +} Foo; + +typedef struct { + uint64_t y; +} RenamedTy; + #if !defined(DEFINE_FREEBSD) typedef struct { uint8_t field; @@ -21,16 +29,8 @@ typedef struct { } ContainsNoExternTy; #endif -typedef struct { - uint64_t y; -} RenamedTy; - -typedef struct { - int32_t x; -} Foo; - -void no_extern_func(ContainsNoExternTy a); +void root(Foo a); void renamed_func(RenamedTy a); -void root(Foo a); +void no_extern_func(ContainsNoExternTy a); diff --git a/tests/expectations/rename-crate.compat.c b/tests/expectations/rename-crate.compat.c index 9958ebb..905dffd 100644 --- a/tests/expectations/rename-crate.compat.c +++ b/tests/expectations/rename-crate.compat.c @@ -3,6 +3,14 @@ #include #include +typedef struct { + int32_t x; +} Foo; + +typedef struct { + uint64_t y; +} RenamedTy; + #if !defined(DEFINE_FREEBSD) typedef struct { uint8_t field; @@ -21,23 +29,15 @@ typedef struct { } ContainsNoExternTy; #endif -typedef struct { - uint64_t y; -} RenamedTy; - -typedef struct { - int32_t x; -} Foo; - #ifdef __cplusplus extern "C" { #endif // __cplusplus -void no_extern_func(ContainsNoExternTy a); +void root(Foo a); void renamed_func(RenamedTy a); -void root(Foo a); +void no_extern_func(ContainsNoExternTy a); #ifdef __cplusplus } // extern "C" diff --git a/tests/expectations/rename-crate.cpp b/tests/expectations/rename-crate.cpp index 167ab38..f93d502 100644 --- a/tests/expectations/rename-crate.cpp +++ b/tests/expectations/rename-crate.cpp @@ -4,6 +4,14 @@ #include #include +struct Foo { + int32_t x; +}; + +struct RenamedTy { + uint64_t y; +}; + #if !defined(DEFINE_FREEBSD) struct NoExternTy { uint8_t field; @@ -22,20 +30,12 @@ struct ContainsNoExternTy { }; #endif -struct RenamedTy { - uint64_t y; -}; - -struct Foo { - int32_t x; -}; - extern "C" { -void no_extern_func(ContainsNoExternTy a); - -void renamed_func(RenamedTy a); - void root(Foo a); +void renamed_func(RenamedTy a); + +void no_extern_func(ContainsNoExternTy a); + } // extern "C" diff --git a/tests/expectations/static.c b/tests/expectations/static.c index c9b3020..43a0db6 100644 --- a/tests/expectations/static.c +++ b/tests/expectations/static.c @@ -9,10 +9,10 @@ typedef struct { } Foo; -extern const Bar BAR; +extern const int32_t NUMBER; extern Foo FOO; -extern const int32_t NUMBER; +extern const Bar BAR; void root(void); diff --git a/tests/expectations/static.compat.c b/tests/expectations/static.compat.c index 82431f6..e25d2f0 100644 --- a/tests/expectations/static.compat.c +++ b/tests/expectations/static.compat.c @@ -13,11 +13,11 @@ typedef struct { extern "C" { #endif // __cplusplus -extern const Bar BAR; +extern const int32_t NUMBER; extern Foo FOO; -extern const int32_t NUMBER; +extern const Bar BAR; void root(void); diff --git a/tests/expectations/static.cpp b/tests/expectations/static.cpp index 65afa07..4695d3c 100644 --- a/tests/expectations/static.cpp +++ b/tests/expectations/static.cpp @@ -12,11 +12,11 @@ struct Foo { extern "C" { -extern const Bar BAR; +extern const int32_t NUMBER; extern Foo FOO; -extern const int32_t NUMBER; +extern const Bar BAR; void root(); diff --git a/tests/expectations/swift_name.c b/tests/expectations/swift_name.c index 10e1bd1..e02e326 100644 --- a/tests/expectations/swift_name.c +++ b/tests/expectations/swift_name.c @@ -7,49 +7,49 @@ typedef struct Opaque Opaque; -typedef struct { - Opaque *ptr; -} PointerToOpaque; - typedef struct { uint8_t times; } SelfTypeTestStruct; -PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); +typedef struct { + Opaque *ptr; +} PointerToOpaque; -void PointerToOpaque_sayHello(PointerToOpaque self) -/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); - -void SelfTypeTestStruct_should_exist_annotated_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); - -void SelfTypeTestStruct_should_exist_annotated_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); - -void SelfTypeTestStruct_should_exist_mut_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); +void rust_print_hello_world(void) CF_SWIFT_NAME(rust_print_hello_world()); void SelfTypeTestStruct_should_exist_ref(const SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref(self:)); void SelfTypeTestStruct_should_exist_ref_mut(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref_mut(self:)); -void SelfTypeTestStruct_should_exist_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); - void SelfTypeTestStruct_should_not_exist_box(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_box(self:)); SelfTypeTestStruct *SelfTypeTestStruct_should_not_exist_return_box(void) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_return_box()); -void free_function_should_exist_annotated_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); +void SelfTypeTestStruct_should_exist_annotated_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); -void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); +void SelfTypeTestStruct_should_exist_annotated_mut_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); + +void SelfTypeTestStruct_should_exist_annotated_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); + +void SelfTypeTestStruct_should_exist_annotated_mut_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); + +void SelfTypeTestStruct_should_exist_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); + +void SelfTypeTestStruct_should_exist_mut_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); void free_function_should_exist_ref(const SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref(test_struct:)); void free_function_should_exist_ref_mut(SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref_mut(test_struct:)); +void unnamed_argument(SelfTypeTestStruct*); + void free_function_should_not_exist_box(SelfTypeTestStruct *boxed) CF_SWIFT_NAME(free_function_should_not_exist_box(boxed:)); -void rust_print_hello_world(void) CF_SWIFT_NAME(rust_print_hello_world()); +void free_function_should_exist_annotated_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); -void unnamed_argument(SelfTypeTestStruct*); +void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); + +PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); + +void PointerToOpaque_sayHello(PointerToOpaque self) +/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); diff --git a/tests/expectations/swift_name.compat.c b/tests/expectations/swift_name.compat.c index a164d13..3fecd4f 100644 --- a/tests/expectations/swift_name.compat.c +++ b/tests/expectations/swift_name.compat.c @@ -7,57 +7,57 @@ typedef struct Opaque Opaque; -typedef struct { - Opaque *ptr; -} PointerToOpaque; - typedef struct { uint8_t times; } SelfTypeTestStruct; +typedef struct { + Opaque *ptr; +} PointerToOpaque; + #ifdef __cplusplus extern "C" { #endif // __cplusplus +void rust_print_hello_world(void) CF_SWIFT_NAME(rust_print_hello_world()); + +void SelfTypeTestStruct_should_exist_ref(const SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref(self:)); + +void SelfTypeTestStruct_should_exist_ref_mut(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref_mut(self:)); + +void SelfTypeTestStruct_should_not_exist_box(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_box(self:)); + +SelfTypeTestStruct *SelfTypeTestStruct_should_not_exist_return_box(void) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_return_box()); + +void SelfTypeTestStruct_should_exist_annotated_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); + +void SelfTypeTestStruct_should_exist_annotated_mut_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); + +void SelfTypeTestStruct_should_exist_annotated_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); + +void SelfTypeTestStruct_should_exist_annotated_mut_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); + +void SelfTypeTestStruct_should_exist_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); + +void SelfTypeTestStruct_should_exist_mut_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); + +void free_function_should_exist_ref(const SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref(test_struct:)); + +void free_function_should_exist_ref_mut(SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref_mut(test_struct:)); + +void unnamed_argument(SelfTypeTestStruct*); + +void free_function_should_not_exist_box(SelfTypeTestStruct *boxed) CF_SWIFT_NAME(free_function_should_not_exist_box(boxed:)); + +void free_function_should_exist_annotated_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); + +void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); + PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); void PointerToOpaque_sayHello(PointerToOpaque self) /*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); -void SelfTypeTestStruct_should_exist_annotated_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); - -void SelfTypeTestStruct_should_exist_annotated_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); - -void SelfTypeTestStruct_should_exist_mut_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); - -void SelfTypeTestStruct_should_exist_ref(const SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref(self:)); - -void SelfTypeTestStruct_should_exist_ref_mut(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref_mut(self:)); - -void SelfTypeTestStruct_should_exist_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); - -void SelfTypeTestStruct_should_not_exist_box(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_box(self:)); - -SelfTypeTestStruct *SelfTypeTestStruct_should_not_exist_return_box(void) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_return_box()); - -void free_function_should_exist_annotated_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); - -void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); - -void free_function_should_exist_ref(const SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref(test_struct:)); - -void free_function_should_exist_ref_mut(SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref_mut(test_struct:)); - -void free_function_should_not_exist_box(SelfTypeTestStruct *boxed) CF_SWIFT_NAME(free_function_should_not_exist_box(boxed:)); - -void rust_print_hello_world(void) CF_SWIFT_NAME(rust_print_hello_world()); - -void unnamed_argument(SelfTypeTestStruct*); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/swift_name.cpp b/tests/expectations/swift_name.cpp index 22d5b5d..1d30b94 100644 --- a/tests/expectations/swift_name.cpp +++ b/tests/expectations/swift_name.cpp @@ -11,53 +11,53 @@ struct Box; struct Opaque; -struct PointerToOpaque { - Opaque *ptr; -}; - struct SelfTypeTestStruct { uint8_t times; }; +struct PointerToOpaque { + Opaque *ptr; +}; + extern "C" { +void rust_print_hello_world() CF_SWIFT_NAME(rust_print_hello_world()); + +void SelfTypeTestStruct_should_exist_ref(const SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref(self:)); + +void SelfTypeTestStruct_should_exist_ref_mut(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref_mut(self:)); + +void SelfTypeTestStruct_should_not_exist_box(Box self) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_box(self:)); + +Box SelfTypeTestStruct_should_not_exist_return_box() CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_return_box()); + +void SelfTypeTestStruct_should_exist_annotated_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); + +void SelfTypeTestStruct_should_exist_annotated_mut_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); + +void SelfTypeTestStruct_should_exist_annotated_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); + +void SelfTypeTestStruct_should_exist_annotated_mut_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); + +void SelfTypeTestStruct_should_exist_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); + +void SelfTypeTestStruct_should_exist_mut_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); + +void free_function_should_exist_ref(const SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref(test_struct:)); + +void free_function_should_exist_ref_mut(SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref_mut(test_struct:)); + +void unnamed_argument(SelfTypeTestStruct*); + +void free_function_should_not_exist_box(Box boxed) CF_SWIFT_NAME(free_function_should_not_exist_box(boxed:)); + +void free_function_should_exist_annotated_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); + +void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); + PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); void PointerToOpaque_sayHello(PointerToOpaque self) /*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); -void SelfTypeTestStruct_should_exist_annotated_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_by_name(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); - -void SelfTypeTestStruct_should_exist_annotated_self(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); - -void SelfTypeTestStruct_should_exist_mut_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); - -void SelfTypeTestStruct_should_exist_ref(const SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref(self:)); - -void SelfTypeTestStruct_should_exist_ref_mut(SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref_mut(self:)); - -void SelfTypeTestStruct_should_exist_unannotated(SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); - -void SelfTypeTestStruct_should_not_exist_box(Box self) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_box(self:)); - -Box SelfTypeTestStruct_should_not_exist_return_box() CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_return_box()); - -void free_function_should_exist_annotated_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); - -void free_function_should_exist_annotated_mut_by_name(SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); - -void free_function_should_exist_ref(const SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref(test_struct:)); - -void free_function_should_exist_ref_mut(SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref_mut(test_struct:)); - -void free_function_should_not_exist_box(Box boxed) CF_SWIFT_NAME(free_function_should_not_exist_box(boxed:)); - -void rust_print_hello_world() CF_SWIFT_NAME(rust_print_hello_world()); - -void unnamed_argument(SelfTypeTestStruct*); - } // extern "C" diff --git a/tests/expectations/tag/box.c b/tests/expectations/tag/box.c index 6ea043b..e3a6aee 100644 --- a/tests/expectations/tag/box.c +++ b/tests/expectations/tag/box.c @@ -17,8 +17,8 @@ struct MyStruct { int32_t *number; }; +void root(const Foo *a, const struct MyStruct *with_box); + void drop_box(int32_t *x); void drop_box_opt(int32_t *x); - -void root(const Foo *a, const struct MyStruct *with_box); diff --git a/tests/expectations/tag/box.compat.c b/tests/expectations/tag/box.compat.c index abf9348..d8cbb1a 100644 --- a/tests/expectations/tag/box.compat.c +++ b/tests/expectations/tag/box.compat.c @@ -21,12 +21,12 @@ struct MyStruct { extern "C" { #endif // __cplusplus +void root(const Foo *a, const struct MyStruct *with_box); + void drop_box(int32_t *x); void drop_box_opt(int32_t *x); -void root(const Foo *a, const struct MyStruct *with_box); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/tag/constant.c b/tests/expectations/tag/constant.c index 4239b68..b5aa355 100644 --- a/tests/expectations/tag/constant.c +++ b/tests/expectations/tag/constant.c @@ -3,19 +3,28 @@ #include #include -#define CAST (uint8_t)'A' +#define FOO 10 #define DELIMITER ':' -#define DOUBLE_CAST (uint32_t)(float)1 +#define LEFTCURLY '{' -#define EQUID U'\U00010083' +#define QUOTE '\'' -#define FOO 10 +#define TAB '\t' + +#define NEWLINE '\n' #define HEART U'\U00002764' -#define LEFTCURLY '{' +#define EQUID U'\U00010083' + +#define ZOM 3.14 + +/** + * A single-line doc comment. + */ +#define POS_ONE 1 /** * A @@ -25,26 +34,17 @@ */ #define NEG_ONE -1 -#define NEWLINE '\n' - -/** - * A single-line doc comment. - */ -#define POS_ONE 1 - -#define QUOTE '\'' - #define SHIFT 3 -#define TAB '\t' - #define XBOOL 1 #define XFALSE ((0 << SHIFT) | XBOOL) #define XTRUE (1 << (SHIFT | XBOOL)) -#define ZOM 3.14 +#define CAST (uint8_t)'A' + +#define DOUBLE_CAST (uint32_t)(float)1 struct Foo { int32_t x[FOO]; diff --git a/tests/expectations/tag/constant.compat.c b/tests/expectations/tag/constant.compat.c index 71b811b..2154e49 100644 --- a/tests/expectations/tag/constant.compat.c +++ b/tests/expectations/tag/constant.compat.c @@ -3,19 +3,28 @@ #include #include -#define CAST (uint8_t)'A' +#define FOO 10 #define DELIMITER ':' -#define DOUBLE_CAST (uint32_t)(float)1 +#define LEFTCURLY '{' -#define EQUID U'\U00010083' +#define QUOTE '\'' -#define FOO 10 +#define TAB '\t' + +#define NEWLINE '\n' #define HEART U'\U00002764' -#define LEFTCURLY '{' +#define EQUID U'\U00010083' + +#define ZOM 3.14 + +/** + * A single-line doc comment. + */ +#define POS_ONE 1 /** * A @@ -25,26 +34,17 @@ */ #define NEG_ONE -1 -#define NEWLINE '\n' - -/** - * A single-line doc comment. - */ -#define POS_ONE 1 - -#define QUOTE '\'' - #define SHIFT 3 -#define TAB '\t' - #define XBOOL 1 #define XFALSE ((0 << SHIFT) | XBOOL) #define XTRUE (1 << (SHIFT | XBOOL)) -#define ZOM 3.14 +#define CAST (uint8_t)'A' + +#define DOUBLE_CAST (uint32_t)(float)1 struct Foo { int32_t x[FOO]; diff --git a/tests/expectations/tag/constant_big.c b/tests/expectations/tag/constant_big.c index 469bf31..86867df 100644 --- a/tests/expectations/tag/constant_big.c +++ b/tests/expectations/tag/constant_big.c @@ -3,10 +3,10 @@ #include #include -#define SIGNED_DOESNT_NEED_ULL_SUFFIX -9223372036854775807 - -#define SIGNED_NEEDS_ULL_SUFFIX -9223372036854775808ULL +#define UNSIGNED_NEEDS_ULL_SUFFIX 9223372036854775808ULL #define UNSIGNED_DOESNT_NEED_ULL_SUFFIX 8070450532247928832 -#define UNSIGNED_NEEDS_ULL_SUFFIX 9223372036854775808ULL +#define SIGNED_NEEDS_ULL_SUFFIX -9223372036854775808ULL + +#define SIGNED_DOESNT_NEED_ULL_SUFFIX -9223372036854775807 diff --git a/tests/expectations/tag/constant_big.compat.c b/tests/expectations/tag/constant_big.compat.c index 469bf31..86867df 100644 --- a/tests/expectations/tag/constant_big.compat.c +++ b/tests/expectations/tag/constant_big.compat.c @@ -3,10 +3,10 @@ #include #include -#define SIGNED_DOESNT_NEED_ULL_SUFFIX -9223372036854775807 - -#define SIGNED_NEEDS_ULL_SUFFIX -9223372036854775808ULL +#define UNSIGNED_NEEDS_ULL_SUFFIX 9223372036854775808ULL #define UNSIGNED_DOESNT_NEED_ULL_SUFFIX 8070450532247928832 -#define UNSIGNED_NEEDS_ULL_SUFFIX 9223372036854775808ULL +#define SIGNED_NEEDS_ULL_SUFFIX -9223372036854775808ULL + +#define SIGNED_DOESNT_NEED_ULL_SUFFIX -9223372036854775807 diff --git a/tests/expectations/tag/constant_constexpr.c b/tests/expectations/tag/constant_constexpr.c index 74d7e25..6f1fde2 100644 --- a/tests/expectations/tag/constant_constexpr.c +++ b/tests/expectations/tag/constant_constexpr.c @@ -3,10 +3,10 @@ #include #include -#define CONSTANT_FLOAT32 312.292 - #define CONSTANT_I64 216 +#define CONSTANT_FLOAT32 312.292 + #define DELIMITER ':' #define LEFTCURLY '{' diff --git a/tests/expectations/tag/constant_constexpr.compat.c b/tests/expectations/tag/constant_constexpr.compat.c index 74d7e25..6f1fde2 100644 --- a/tests/expectations/tag/constant_constexpr.compat.c +++ b/tests/expectations/tag/constant_constexpr.compat.c @@ -3,10 +3,10 @@ #include #include -#define CONSTANT_FLOAT32 312.292 - #define CONSTANT_I64 216 +#define CONSTANT_FLOAT32 312.292 + #define DELIMITER ':' #define LEFTCURLY '{' diff --git a/tests/expectations/tag/expand_features.c b/tests/expectations/tag/expand_features.c index 898d3e2..e04b151 100644 --- a/tests/expectations/tag/expand_features.c +++ b/tests/expectations/tag/expand_features.c @@ -7,8 +7,8 @@ struct Foo { }; -void cbindgen(void); - void extra_debug_fn(void); +void cbindgen(void); + void root(struct Foo a); diff --git a/tests/expectations/tag/expand_features.compat.c b/tests/expectations/tag/expand_features.compat.c index 627f370..ee9d430 100644 --- a/tests/expectations/tag/expand_features.compat.c +++ b/tests/expectations/tag/expand_features.compat.c @@ -11,10 +11,10 @@ struct Foo { extern "C" { #endif // __cplusplus -void cbindgen(void); - void extra_debug_fn(void); +void cbindgen(void); + void root(struct Foo a); #ifdef __cplusplus diff --git a/tests/expectations/tag/extern.c b/tests/expectations/tag/extern.c index 5b5001d..5a88d1a 100644 --- a/tests/expectations/tag/extern.c +++ b/tests/expectations/tag/extern.c @@ -8,6 +8,6 @@ struct Normal { float y; }; -extern void bar(struct Normal a); - extern int32_t foo(void); + +extern void bar(struct Normal a); diff --git a/tests/expectations/tag/extern.compat.c b/tests/expectations/tag/extern.compat.c index e3693f5..3ca1625 100644 --- a/tests/expectations/tag/extern.compat.c +++ b/tests/expectations/tag/extern.compat.c @@ -12,10 +12,10 @@ struct Normal { extern "C" { #endif // __cplusplus -extern void bar(struct Normal a); - extern int32_t foo(void); +extern void bar(struct Normal a); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/tag/fns.c b/tests/expectations/tag/fns.c index 63b2a5e..759080f 100644 --- a/tests/expectations/tag/fns.c +++ b/tests/expectations/tag/fns.c @@ -11,6 +11,6 @@ struct Fns { int8_t (*namedArgsWildcards)(int32_t _, int16_t named, int64_t _1); }; -void no_return(void); - void root(struct Fns _fns); + +void no_return(void); diff --git a/tests/expectations/tag/fns.compat.c b/tests/expectations/tag/fns.compat.c index ecf0cb0..84efce6 100644 --- a/tests/expectations/tag/fns.compat.c +++ b/tests/expectations/tag/fns.compat.c @@ -15,10 +15,10 @@ struct Fns { extern "C" { #endif // __cplusplus -void no_return(void); - void root(struct Fns _fns); +void no_return(void); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/tag/function_args.c b/tests/expectations/tag/function_args.c index 811a1d3..ce46f98 100644 --- a/tests/expectations/tag/function_args.c +++ b/tests/expectations/tag/function_args.c @@ -3,8 +3,8 @@ #include #include +void unnamed(const uint64_t*); + void pointer_test(const uint64_t *a); void print_from_rust(void); - -void unnamed(const uint64_t*); diff --git a/tests/expectations/tag/function_args.compat.c b/tests/expectations/tag/function_args.compat.c index c3a2aef..7f9f24b 100644 --- a/tests/expectations/tag/function_args.compat.c +++ b/tests/expectations/tag/function_args.compat.c @@ -7,12 +7,12 @@ extern "C" { #endif // __cplusplus +void unnamed(const uint64_t*); + void pointer_test(const uint64_t *a); void print_from_rust(void); -void unnamed(const uint64_t*); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/tag/global_variable.c b/tests/expectations/tag/global_variable.c index e6cdb4c..2c165e3 100644 --- a/tests/expectations/tag/global_variable.c +++ b/tests/expectations/tag/global_variable.c @@ -3,6 +3,6 @@ #include #include -extern const char CONST_GLOBAL_ARRAY[128]; - extern char MUT_GLOBAL_ARRAY[128]; + +extern const char CONST_GLOBAL_ARRAY[128]; diff --git a/tests/expectations/tag/global_variable.compat.c b/tests/expectations/tag/global_variable.compat.c index e0bc032..ee7b9d1 100644 --- a/tests/expectations/tag/global_variable.compat.c +++ b/tests/expectations/tag/global_variable.compat.c @@ -7,10 +7,10 @@ extern "C" { #endif // __cplusplus -extern const char CONST_GLOBAL_ARRAY[128]; - extern char MUT_GLOBAL_ARRAY[128]; +extern const char CONST_GLOBAL_ARRAY[128]; + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/tag/mod_attr.c b/tests/expectations/tag/mod_attr.c index 451ec10..c8fc689 100644 --- a/tests/expectations/tag/mod_attr.c +++ b/tests/expectations/tag/mod_attr.c @@ -3,18 +3,12 @@ #include #include -#if defined(BAR) -#define BAR 2 -#endif - #if defined(FOO) #define FOO 1 #endif #if defined(BAR) -struct Bar { - -}; +#define BAR 2 #endif #if defined(FOO) @@ -24,9 +18,15 @@ struct Foo { #endif #if defined(BAR) -void bar(const struct Bar *bar); +struct Bar { + +}; #endif #if defined(FOO) void foo(const struct Foo *foo); #endif + +#if defined(BAR) +void bar(const struct Bar *bar); +#endif diff --git a/tests/expectations/tag/mod_attr.compat.c b/tests/expectations/tag/mod_attr.compat.c index 4ce456c..1bdc9a7 100644 --- a/tests/expectations/tag/mod_attr.compat.c +++ b/tests/expectations/tag/mod_attr.compat.c @@ -3,18 +3,12 @@ #include #include -#if defined(BAR) -#define BAR 2 -#endif - #if defined(FOO) #define FOO 1 #endif #if defined(BAR) -struct Bar { - -}; +#define BAR 2 #endif #if defined(FOO) @@ -23,18 +17,24 @@ struct Foo { }; #endif +#if defined(BAR) +struct Bar { + +}; +#endif + #ifdef __cplusplus extern "C" { #endif // __cplusplus -#if defined(BAR) -void bar(const struct Bar *bar); -#endif - #if defined(FOO) void foo(const struct Foo *foo); #endif +#if defined(BAR) +void bar(const struct Bar *bar); +#endif + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/tag/monomorph-2.c b/tests/expectations/tag/monomorph-2.c index 25d127a..e5a212a 100644 --- a/tests/expectations/tag/monomorph-2.c +++ b/tests/expectations/tag/monomorph-2.c @@ -7,16 +7,16 @@ struct A; struct B; -struct List_B { - struct B *members; - uintptr_t count; -}; - struct List_A { struct A *members; uintptr_t count; }; -void bar(struct List_B b); +struct List_B { + struct B *members; + uintptr_t count; +}; void foo(struct List_A a); + +void bar(struct List_B b); diff --git a/tests/expectations/tag/monomorph-2.compat.c b/tests/expectations/tag/monomorph-2.compat.c index afe873a..4d5fb0d 100644 --- a/tests/expectations/tag/monomorph-2.compat.c +++ b/tests/expectations/tag/monomorph-2.compat.c @@ -7,13 +7,13 @@ struct A; struct B; -struct List_B { - struct B *members; +struct List_A { + struct A *members; uintptr_t count; }; -struct List_A { - struct A *members; +struct List_B { + struct B *members; uintptr_t count; }; @@ -21,10 +21,10 @@ struct List_A { extern "C" { #endif // __cplusplus -void bar(struct List_B b); - void foo(struct List_A a); +void bar(struct List_B b); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/tag/nonnull_attribute.c b/tests/expectations/tag/nonnull_attribute.c index 583c3df..21d1153 100644 --- a/tests/expectations/tag/nonnull_attribute.c +++ b/tests/expectations/tag/nonnull_attribute.c @@ -12,6 +12,13 @@ struct Opaque; +struct References { + const struct Opaque *CBINDGEN_NONNULL a; + struct Opaque *CBINDGEN_NONNULL b; + const struct Opaque *c; + struct Opaque *d; +}; + struct Pointers_u64 { float *CBINDGEN_NONNULL a; uint64_t *CBINDGEN_NONNULL b; @@ -26,27 +33,20 @@ struct Pointers_u64 { uint64_t *k; }; -struct References { - const struct Opaque *CBINDGEN_NONNULL a; - struct Opaque *CBINDGEN_NONNULL b; - const struct Opaque *c; - struct Opaque *d; -}; - -void mut_ref_arg(struct Pointers_u64 *CBINDGEN_NONNULL arg); +void value_arg(struct References arg); void mutltiple_args(int32_t *CBINDGEN_NONNULL arg, struct Pointers_u64 *foo, struct Opaque *CBINDGEN_NONNULL *CBINDGEN_NONNULL d); -void nullable_const_ptr(const struct Pointers_u64 *arg); +void ref_arg(const struct Pointers_u64 *CBINDGEN_NONNULL arg); -void nullable_mut_ptr(struct Pointers_u64 *arg); - -void optional_mut_ref_arg(struct Pointers_u64 *arg); +void mut_ref_arg(struct Pointers_u64 *CBINDGEN_NONNULL arg); void optional_ref_arg(const struct Pointers_u64 *arg); -void ref_arg(const struct Pointers_u64 *CBINDGEN_NONNULL arg); +void optional_mut_ref_arg(struct Pointers_u64 *arg); -void value_arg(struct References arg); +void nullable_const_ptr(const struct Pointers_u64 *arg); + +void nullable_mut_ptr(struct Pointers_u64 *arg); diff --git a/tests/expectations/tag/nonnull_attribute.compat.c b/tests/expectations/tag/nonnull_attribute.compat.c index 64e52ac..757f572 100644 --- a/tests/expectations/tag/nonnull_attribute.compat.c +++ b/tests/expectations/tag/nonnull_attribute.compat.c @@ -12,6 +12,13 @@ struct Opaque; +struct References { + const struct Opaque *CBINDGEN_NONNULL a; + struct Opaque *CBINDGEN_NONNULL b; + const struct Opaque *c; + struct Opaque *d; +}; + struct Pointers_u64 { float *CBINDGEN_NONNULL a; uint64_t *CBINDGEN_NONNULL b; @@ -26,35 +33,28 @@ struct Pointers_u64 { uint64_t *k; }; -struct References { - const struct Opaque *CBINDGEN_NONNULL a; - struct Opaque *CBINDGEN_NONNULL b; - const struct Opaque *c; - struct Opaque *d; -}; - #ifdef __cplusplus extern "C" { #endif // __cplusplus -void mut_ref_arg(struct Pointers_u64 *CBINDGEN_NONNULL arg); +void value_arg(struct References arg); void mutltiple_args(int32_t *CBINDGEN_NONNULL arg, struct Pointers_u64 *foo, struct Opaque *CBINDGEN_NONNULL *CBINDGEN_NONNULL d); +void ref_arg(const struct Pointers_u64 *CBINDGEN_NONNULL arg); + +void mut_ref_arg(struct Pointers_u64 *CBINDGEN_NONNULL arg); + +void optional_ref_arg(const struct Pointers_u64 *arg); + +void optional_mut_ref_arg(struct Pointers_u64 *arg); + void nullable_const_ptr(const struct Pointers_u64 *arg); void nullable_mut_ptr(struct Pointers_u64 *arg); -void optional_mut_ref_arg(struct Pointers_u64 *arg); - -void optional_ref_arg(const struct Pointers_u64 *arg); - -void ref_arg(const struct Pointers_u64 *CBINDGEN_NONNULL arg); - -void value_arg(struct References arg); - #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/tag/ptrs_as_arrays.c b/tests/expectations/tag/ptrs_as_arrays.c index 75aca35..4c47d3e 100644 --- a/tests/expectations/tag/ptrs_as_arrays.c +++ b/tests/expectations/tag/ptrs_as_arrays.c @@ -9,6 +9,6 @@ void ptr_as_array1(uint32_t n, const uint32_t arg[3], uint64_t v[4]); void ptr_as_array2(uint32_t n, uint32_t arg[], const uint64_t v[]); -void ptr_as_array_unnamed(uint32_t*, const uint32_t*); - void ptr_as_array_wrong_syntax(uint32_t *arg, const uint32_t *v, const uint32_t*); + +void ptr_as_array_unnamed(uint32_t*, const uint32_t*); diff --git a/tests/expectations/tag/ptrs_as_arrays.compat.c b/tests/expectations/tag/ptrs_as_arrays.compat.c index 0ccf6cc..ec6b905 100644 --- a/tests/expectations/tag/ptrs_as_arrays.compat.c +++ b/tests/expectations/tag/ptrs_as_arrays.compat.c @@ -13,10 +13,10 @@ void ptr_as_array1(uint32_t n, const uint32_t arg[3], uint64_t v[4]); void ptr_as_array2(uint32_t n, uint32_t arg[], const uint64_t v[]); -void ptr_as_array_unnamed(uint32_t*, const uint32_t*); - void ptr_as_array_wrong_syntax(uint32_t *arg, const uint32_t *v, const uint32_t*); +void ptr_as_array_unnamed(uint32_t*, const uint32_t*); + #ifdef __cplusplus } // extern "C" #endif // __cplusplus diff --git a/tests/expectations/tag/rename-crate.c b/tests/expectations/tag/rename-crate.c index 7df9fff..b5629aa 100644 --- a/tests/expectations/tag/rename-crate.c +++ b/tests/expectations/tag/rename-crate.c @@ -3,6 +3,14 @@ #include #include +struct Foo { + int32_t x; +}; + +struct RenamedTy { + uint64_t y; +}; + #if !defined(DEFINE_FREEBSD) struct NoExternTy { uint8_t field; @@ -21,16 +29,8 @@ struct ContainsNoExternTy { }; #endif -struct RenamedTy { - uint64_t y; -}; - -struct Foo { - int32_t x; -}; - -void no_extern_func(struct ContainsNoExternTy a); +void root(struct Foo a); void renamed_func(struct RenamedTy a); -void root(struct Foo a); +void no_extern_func(struct ContainsNoExternTy a); diff --git a/tests/expectations/tag/rename-crate.compat.c b/tests/expectations/tag/rename-crate.compat.c index 503ecae..daba119 100644 --- a/tests/expectations/tag/rename-crate.compat.c +++ b/tests/expectations/tag/rename-crate.compat.c @@ -3,6 +3,14 @@ #include #include +struct Foo { + int32_t x; +}; + +struct RenamedTy { + uint64_t y; +}; + #if !defined(DEFINE_FREEBSD) struct NoExternTy { uint8_t field; @@ -21,23 +29,15 @@ struct ContainsNoExternTy { }; #endif -struct RenamedTy { - uint64_t y; -}; - -struct Foo { - int32_t x; -}; - #ifdef __cplusplus extern "C" { #endif // __cplusplus -void no_extern_func(struct ContainsNoExternTy a); +void root(struct Foo a); void renamed_func(struct RenamedTy a); -void root(struct Foo a); +void no_extern_func(struct ContainsNoExternTy a); #ifdef __cplusplus } // extern "C" diff --git a/tests/expectations/tag/static.c b/tests/expectations/tag/static.c index b68e34c..28f948a 100644 --- a/tests/expectations/tag/static.c +++ b/tests/expectations/tag/static.c @@ -9,10 +9,10 @@ struct Foo { }; -extern const struct Bar BAR; +extern const int32_t NUMBER; extern struct Foo FOO; -extern const int32_t NUMBER; +extern const struct Bar BAR; void root(void); diff --git a/tests/expectations/tag/static.compat.c b/tests/expectations/tag/static.compat.c index 113d9df..4afafee 100644 --- a/tests/expectations/tag/static.compat.c +++ b/tests/expectations/tag/static.compat.c @@ -13,11 +13,11 @@ struct Foo { extern "C" { #endif // __cplusplus -extern const struct Bar BAR; +extern const int32_t NUMBER; extern struct Foo FOO; -extern const int32_t NUMBER; +extern const struct Bar BAR; void root(void); diff --git a/tests/expectations/tag/swift_name.c b/tests/expectations/tag/swift_name.c index d20fbb8..60eb7b4 100644 --- a/tests/expectations/tag/swift_name.c +++ b/tests/expectations/tag/swift_name.c @@ -7,49 +7,49 @@ struct Opaque; -struct PointerToOpaque { - struct Opaque *ptr; -}; - struct SelfTypeTestStruct { uint8_t times; }; -struct PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); +struct PointerToOpaque { + struct Opaque *ptr; +}; -void PointerToOpaque_sayHello(struct PointerToOpaque self) -/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); - -void SelfTypeTestStruct_should_exist_annotated_by_name(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_by_name(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_self(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); - -void SelfTypeTestStruct_should_exist_annotated_self(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); - -void SelfTypeTestStruct_should_exist_mut_unannotated(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); +void rust_print_hello_world(void) CF_SWIFT_NAME(rust_print_hello_world()); void SelfTypeTestStruct_should_exist_ref(const struct SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref(self:)); void SelfTypeTestStruct_should_exist_ref_mut(struct SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref_mut(self:)); -void SelfTypeTestStruct_should_exist_unannotated(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); - void SelfTypeTestStruct_should_not_exist_box(struct SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_box(self:)); struct SelfTypeTestStruct *SelfTypeTestStruct_should_not_exist_return_box(void) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_return_box()); -void free_function_should_exist_annotated_by_name(struct SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); +void SelfTypeTestStruct_should_exist_annotated_self(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); -void free_function_should_exist_annotated_mut_by_name(struct SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); +void SelfTypeTestStruct_should_exist_annotated_mut_self(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); + +void SelfTypeTestStruct_should_exist_annotated_by_name(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); + +void SelfTypeTestStruct_should_exist_annotated_mut_by_name(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); + +void SelfTypeTestStruct_should_exist_unannotated(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); + +void SelfTypeTestStruct_should_exist_mut_unannotated(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); void free_function_should_exist_ref(const struct SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref(test_struct:)); void free_function_should_exist_ref_mut(struct SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref_mut(test_struct:)); +void unnamed_argument(struct SelfTypeTestStruct*); + void free_function_should_not_exist_box(struct SelfTypeTestStruct *boxed) CF_SWIFT_NAME(free_function_should_not_exist_box(boxed:)); -void rust_print_hello_world(void) CF_SWIFT_NAME(rust_print_hello_world()); +void free_function_should_exist_annotated_by_name(struct SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); -void unnamed_argument(struct SelfTypeTestStruct*); +void free_function_should_exist_annotated_mut_by_name(struct SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); + +struct PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); + +void PointerToOpaque_sayHello(struct PointerToOpaque self) +/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); diff --git a/tests/expectations/tag/swift_name.compat.c b/tests/expectations/tag/swift_name.compat.c index 5abe0e5..2b96cd2 100644 --- a/tests/expectations/tag/swift_name.compat.c +++ b/tests/expectations/tag/swift_name.compat.c @@ -7,56 +7,56 @@ struct Opaque; -struct PointerToOpaque { - struct Opaque *ptr; -}; - struct SelfTypeTestStruct { uint8_t times; }; +struct PointerToOpaque { + struct Opaque *ptr; +}; + #ifdef __cplusplus extern "C" { #endif // __cplusplus -struct PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); - -void PointerToOpaque_sayHello(struct PointerToOpaque self) -/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); - -void SelfTypeTestStruct_should_exist_annotated_by_name(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_by_name(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); - -void SelfTypeTestStruct_should_exist_annotated_mut_self(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); - -void SelfTypeTestStruct_should_exist_annotated_self(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); - -void SelfTypeTestStruct_should_exist_mut_unannotated(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); +void rust_print_hello_world(void) CF_SWIFT_NAME(rust_print_hello_world()); void SelfTypeTestStruct_should_exist_ref(const struct SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref(self:)); void SelfTypeTestStruct_should_exist_ref_mut(struct SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_ref_mut(self:)); -void SelfTypeTestStruct_should_exist_unannotated(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); - void SelfTypeTestStruct_should_not_exist_box(struct SelfTypeTestStruct *self) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_box(self:)); struct SelfTypeTestStruct *SelfTypeTestStruct_should_not_exist_return_box(void) CF_SWIFT_NAME(SelfTypeTestStruct.should_not_exist_return_box()); -void free_function_should_exist_annotated_by_name(struct SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); +void SelfTypeTestStruct_should_exist_annotated_self(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_self(self:)); -void free_function_should_exist_annotated_mut_by_name(struct SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); +void SelfTypeTestStruct_should_exist_annotated_mut_self(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_self(self:)); + +void SelfTypeTestStruct_should_exist_annotated_by_name(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_by_name(self:)); + +void SelfTypeTestStruct_should_exist_annotated_mut_by_name(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_annotated_mut_by_name(self:)); + +void SelfTypeTestStruct_should_exist_unannotated(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_unannotated(self:)); + +void SelfTypeTestStruct_should_exist_mut_unannotated(struct SelfTypeTestStruct self) CF_SWIFT_NAME(SelfTypeTestStruct.should_exist_mut_unannotated(self:)); void free_function_should_exist_ref(const struct SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref(test_struct:)); void free_function_should_exist_ref_mut(struct SelfTypeTestStruct *test_struct) CF_SWIFT_NAME(free_function_should_exist_ref_mut(test_struct:)); +void unnamed_argument(struct SelfTypeTestStruct*); + void free_function_should_not_exist_box(struct SelfTypeTestStruct *boxed) CF_SWIFT_NAME(free_function_should_not_exist_box(boxed:)); -void rust_print_hello_world(void) CF_SWIFT_NAME(rust_print_hello_world()); +void free_function_should_exist_annotated_by_name(struct SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_by_name(test_struct:)); -void unnamed_argument(struct SelfTypeTestStruct*); +void free_function_should_exist_annotated_mut_by_name(struct SelfTypeTestStruct test_struct) CF_SWIFT_NAME(free_function_should_exist_annotated_mut_by_name(test_struct:)); + +struct PointerToOpaque PointerToOpaque_create(uint8_t times) CF_SWIFT_NAME(PointerToOpaque.create(times:)); + +void PointerToOpaque_sayHello(struct PointerToOpaque self) +/*a comment!*/ CF_SWIFT_NAME(PointerToOpaque.sayHello(self:)); #ifdef __cplusplus } // extern "C" diff --git a/tests/rust/constant_sort_name.toml b/tests/rust/constant_sort_name.toml new file mode 100644 index 0000000..41e26d8 --- /dev/null +++ b/tests/rust/constant_sort_name.toml @@ -0,0 +1,2 @@ +[const] +sort_by = "Name" diff --git a/tests/rust/constant_sort_none.toml b/tests/rust/constant_sort_none.toml deleted file mode 100644 index 182d0d4..0000000 --- a/tests/rust/constant_sort_none.toml +++ /dev/null @@ -1,2 +0,0 @@ -[const] -sort_by = "None" diff --git a/tests/rust/function_sort_name.toml b/tests/rust/function_sort_name.toml new file mode 100644 index 0000000..8607792 --- /dev/null +++ b/tests/rust/function_sort_name.toml @@ -0,0 +1,2 @@ +[fn] +sort_by = "Name" diff --git a/tests/rust/function_sort_none.toml b/tests/rust/function_sort_none.toml deleted file mode 100644 index 27c7839..0000000 --- a/tests/rust/function_sort_none.toml +++ /dev/null @@ -1,2 +0,0 @@ -[fn] -sort_by = "None"