1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#![cfg_attr(rustfmt, rustfmt::skip)]
use_prelude!();

/// A `ReprC` _standalone_ type with the same layout and ABI as
/// [`::libc::c_char`][crate::libc::c_char].
///
/// By _standalone_, the idea is that this is defined as a (`transparent`) _newtype_ `struct`,
/// rather than as a _`type` alias_, which is error-prone and yields less-portable headers (since
/// the header generation will resolve the type alias and emit, for instance, `int8_t`, ⚠️).
///
/// By using this type, you guarantee that the C `char` type be used in the headers.
#[repr(transparent)]
#[derive(
    Debug,
    Clone, Copy,
    Default,
    PartialOrd, Ord,
    PartialEq, Eq,
    Hash,
)]
pub
struct c_char /* = */ (
    pub
    u8,
);

/// Assert that `crate::libc::c_char` is either `uint8_t` or `int8_t`.
const _: () = {
    trait IsU8OrI8
    {}

    impl IsU8OrI8
        for u8
    {}
    impl IsU8OrI8
        for i8
    {}

    const _: () = {
        fn is_u8_or_i8<T>() where
            T : IsU8OrI8,
        {}
        let _ = is_u8_or_i8::<crate::libc::c_char>;
    };
};

unsafe
impl LegacyCType
    for c_char
{ __cfg_headers__! {
    fn c_short_name_fmt (fmt: &'_ mut fmt::Formatter<'_>)
      -> fmt::Result
    {
        fmt.write_str("char")
    }

    fn c_var_fmt (
        fmt: &'_ mut fmt::Formatter<'_>,
        var_name: &'_ str,
    ) -> fmt::Result
    {
        write!(fmt,
            "char{sep}{}",
            var_name,
            sep = if var_name.is_empty() { "" } else { " " },
        )
    }

    fn c_define_self (
        _: &'_ mut dyn crate::headers::Definer,
    ) -> io::Result<()>
    {
        Ok(())
    }

    __cfg_csharp__! {
        fn csharp_define_self (
            _: &'_ mut dyn crate::headers::Definer,
        ) -> io::Result<()>
        {
            Ok(())
        }

        fn csharp_ty ()
          -> rust::String
        {
            "byte".into()
        }
    }
} type OPAQUE_KIND = crate::layout::OpaqueKind::Concrete; }

from_CType_impl_ReprC! {
    c_char
}