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
95
96
97
98
99
100
101
102
103
use core::fmt;
use core::hash;

use crate::mutability::Root;
use crate::runtime::{AnyClass, AnyObject, NSObject, NSObjectProtocol, ProtocolObject};
use crate::ClassType;

crate::__emit_struct! {
    (
        /// An abstract superclass defining an API for objects that act as
        /// stand-ins for other objects or for objects that don’t exist yet.
        ///
        /// See [Apple's documentation][apple-doc] for more information.
        ///
        /// [apple-doc]: https://developer.apple.com/documentation/foundation/nsproxy?language=objc
    )
    (pub)
    (NSProxy)
    (
        __inner: AnyObject,
    )
}

crate::__extern_class_impl_traits! {
    unsafe impl () for NSProxy {
        INHERITS = [AnyObject];

        fn as_super(&self) {
            &self.__inner
        }

        fn as_super_mut(&mut self) {
            &mut self.__inner
        }
    }
}

unsafe impl ClassType for NSProxy {
    type Super = AnyObject;
    type Mutability = Root;
    const NAME: &'static str = "NSProxy";

    #[inline]
    fn class() -> &'static AnyClass {
        #[cfg(feature = "apple")]
        {
            crate::__class_inner!("NSProxy", "NSProxy")
        }
        #[cfg(feature = "gnustep-1-7")]
        {
            extern "C" {
                // The linking changed in libobjc2 v2.0
                #[cfg_attr(feature = "gnustep-2-0", link_name = "._OBJC_CLASS_NSProxy")]
                #[cfg_attr(not(feature = "gnustep-2-0"), link_name = "_OBJC_CLASS_NSProxy")]
                static OBJC_CLASS_NSProxy: AnyClass;
                // Others:
                // __objc_class_name_NSProxy
                // _OBJC_CLASS_REF_NSProxy
            }

            unsafe { &OBJC_CLASS_NSProxy }
        }
    }

    #[inline]
    fn as_super(&self) -> &Self::Super {
        &self.__inner
    }

    #[inline]
    fn as_super_mut(&mut self) -> &mut Self::Super {
        &mut self.__inner
    }
}

unsafe impl NSObjectProtocol for NSProxy {}

impl PartialEq for NSProxy {
    #[inline]
    #[doc(alias = "isEqual:")]
    fn eq(&self, other: &Self) -> bool {
        self.__isEqual(other)
    }
}

impl Eq for NSProxy {}

impl hash::Hash for NSProxy {
    #[inline]
    fn hash<H: hash::Hasher>(&self, state: &mut H) {
        self.__hash().hash(state);
    }
}

impl fmt::Debug for NSProxy {
    #[inline]
    #[doc(alias = "description")]
    #[doc(alias = "debugDescription")]
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        let obj: &ProtocolObject<NSObject> = ProtocolObject::from_ref(self);
        obj.fmt(f)
    }
}