tests: Add tests for attribute annotations.
This commit is contained in:
@@ -1,15 +1,20 @@
|
||||
/// cbindgen:prefix-with-name
|
||||
#[repr(C, u8)]
|
||||
pub enum H {
|
||||
/// cbindgen:variant-mut-cast-attributes=MY_ATTRS
|
||||
Foo(i16),
|
||||
/// cbindgen:variant-const-cast-attributes=MY_ATTRS
|
||||
Bar { x: u8, y: i16 },
|
||||
/// cbindgen:variant-is-attributes=MY_ATTRS
|
||||
Baz
|
||||
}
|
||||
|
||||
/// cbindgen:prefix-with-name
|
||||
#[repr(C, u8, u16)]
|
||||
pub enum I {
|
||||
/// cbindgen:variant-constructor-attributes=MY_ATTRS
|
||||
Foo(i16),
|
||||
/// cbindgen:eq-attributes=MY_ATTRS
|
||||
Bar { x: u8, y: i16 },
|
||||
Baz
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# This is a bit of an abuse of the warning config...
|
||||
autogen_warning = """
|
||||
header = """
|
||||
#define MY_ASSERT(...) do { } while (0)
|
||||
#define MY_ATTRS __attribute((noinline))
|
||||
"""
|
||||
|
||||
[enum]
|
||||
|
||||
@@ -77,6 +77,21 @@ pub enum Tazzzz {
|
||||
Taz7(u32),
|
||||
}
|
||||
|
||||
/// cbindgen:derive-eq=true
|
||||
/// cbindgen:derive-neq=true
|
||||
/// cbindgen:neq-attributes=NODISCARD
|
||||
/// cbindgen:eq-attributes=NODISCARD
|
||||
/// cbindgen:destructor-attributes=NOINLINE
|
||||
/// cbindgen:copy-constructor-attributes=NOINLINE
|
||||
/// cbindgen:copy-assignment-attributes=NOINLINE
|
||||
#[repr(u8)]
|
||||
pub enum Qux {
|
||||
/// cbindgen:derive-eq=true
|
||||
Qux1(i32),
|
||||
/// cbindgen:derive-eq=true
|
||||
Qux2(u32),
|
||||
}
|
||||
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn root(a: &Foo<u32>, b: &Baz<i32>, c: &Taz, d: Tazz, e: &Tazzz, f: &Tazzzz) {}
|
||||
pub extern "C" fn root(a: &Foo<u32>, b: &Baz<i32>, c: &Taz, d: Tazz, e: &Tazzz, f: &Tazzzz, g: &Qux) {}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
header = """
|
||||
#define NOINLINE __attribute__((noinline))
|
||||
#define NODISCARD [[nodiscard]]
|
||||
"""
|
||||
|
||||
[enum]
|
||||
derive_tagged_enum_destructor = true
|
||||
derive_tagged_enum_copy_constructor = true
|
||||
|
||||
Reference in New Issue
Block a user