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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern_protocol!(
    pub unsafe trait NSWindowRestoration: NSObjectProtocol + IsMainThreadOnly {
        #[cfg(all(
            feature = "NSResponder",
            feature = "NSUserInterfaceItemIdentification",
            feature = "NSWindow",
            feature = "block2"
        ))]
        #[method(restoreWindowWithIdentifier:state:completionHandler:)]
        unsafe fn restoreWindowWithIdentifier_state_completionHandler(
            identifier: &NSUserInterfaceItemIdentifier,
            state: &NSCoder,
            completion_handler: &block2::Block<dyn Fn(*mut NSWindow, *mut NSError)>,
            mtm: MainThreadMarker,
        );
    }

    unsafe impl ProtocolType for dyn NSWindowRestoration {}
);

extern_methods!(
    /// NSWindowRestoration
    #[cfg(feature = "NSDocumentController")]
    unsafe impl NSDocumentController {}
);

#[cfg(feature = "NSDocumentController")]
unsafe impl NSWindowRestoration for NSDocumentController {}

extern_methods!(
    /// NSWindowRestoration
    #[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
    unsafe impl NSApplication {
        #[cfg(all(
            feature = "NSUserInterfaceItemIdentification",
            feature = "NSWindow",
            feature = "block2"
        ))]
        #[method(restoreWindowWithIdentifier:state:completionHandler:)]
        pub unsafe fn restoreWindowWithIdentifier_state_completionHandler(
            &self,
            identifier: &NSUserInterfaceItemIdentifier,
            state: &NSCoder,
            completion_handler: &block2::Block<dyn Fn(*mut NSWindow, *mut NSError)>,
        ) -> bool;
    }
);

extern "C" {
    pub static NSApplicationDidFinishRestoringWindowsNotification: &'static NSNotificationName;
}

extern_methods!(
    /// NSUserInterfaceRestoration
    #[cfg(all(feature = "NSResponder", feature = "NSWindow"))]
    unsafe impl NSWindow {
        #[method(isRestorable)]
        pub unsafe fn isRestorable(&self) -> bool;

        #[method(setRestorable:)]
        pub unsafe fn setRestorable(&self, restorable: bool);

        #[method(restorationClass)]
        pub unsafe fn restorationClass(&self) -> Option<&'static AnyClass>;

        #[method(setRestorationClass:)]
        pub unsafe fn setRestorationClass(&self, restoration_class: Option<&AnyClass>);

        #[method(disableSnapshotRestoration)]
        pub unsafe fn disableSnapshotRestoration(&self);

        #[method(enableSnapshotRestoration)]
        pub unsafe fn enableSnapshotRestoration(&self);
    }
);

extern_methods!(
    /// NSRestorableState
    #[cfg(feature = "NSResponder")]
    unsafe impl NSResponder {
        #[method(encodeRestorableStateWithCoder:)]
        pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder);

        #[method(encodeRestorableStateWithCoder:backgroundQueue:)]
        pub unsafe fn encodeRestorableStateWithCoder_backgroundQueue(
            &self,
            coder: &NSCoder,
            queue: &NSOperationQueue,
        );

        #[method(restoreStateWithCoder:)]
        pub unsafe fn restoreStateWithCoder(&self, coder: &NSCoder);

        #[method(invalidateRestorableState)]
        pub unsafe fn invalidateRestorableState(&self);

        #[method_id(@__retain_semantics Other restorableStateKeyPaths)]
        pub unsafe fn restorableStateKeyPaths(mtm: MainThreadMarker)
            -> Retained<NSArray<NSString>>;

        #[method_id(@__retain_semantics Other allowedClassesForRestorableStateKeyPath:)]
        pub unsafe fn allowedClassesForRestorableStateKeyPath(
            key_path: &NSString,
            mtm: MainThreadMarker,
        ) -> Retained<NSArray<TodoClass>>;
    }
);

extern_methods!(
    /// NSRestorableStateExtension
    #[cfg(all(feature = "NSApplication", feature = "NSResponder"))]
    unsafe impl NSApplication {
        #[method(extendStateRestoration)]
        pub unsafe fn extendStateRestoration(&self);

        #[method(completeStateRestoration)]
        pub unsafe fn completeStateRestoration(&self);
    }
);

extern_methods!(
    /// NSRestorableState
    #[cfg(feature = "NSDocument")]
    unsafe impl NSDocument {
        #[cfg(all(
            feature = "NSResponder",
            feature = "NSUserInterfaceItemIdentification",
            feature = "NSWindow",
            feature = "block2"
        ))]
        #[method(restoreDocumentWindowWithIdentifier:state:completionHandler:)]
        pub unsafe fn restoreDocumentWindowWithIdentifier_state_completionHandler(
            &self,
            identifier: &NSUserInterfaceItemIdentifier,
            state: &NSCoder,
            completion_handler: &block2::Block<dyn Fn(*mut NSWindow, *mut NSError)>,
        );

        #[method(encodeRestorableStateWithCoder:)]
        pub unsafe fn encodeRestorableStateWithCoder(&self, coder: &NSCoder);

        #[method(encodeRestorableStateWithCoder:backgroundQueue:)]
        pub unsafe fn encodeRestorableStateWithCoder_backgroundQueue(
            &self,
            coder: &NSCoder,
            queue: &NSOperationQueue,
        );

        #[method(restoreStateWithCoder:)]
        pub unsafe fn restoreStateWithCoder(&self, coder: &NSCoder);

        #[method(invalidateRestorableState)]
        pub unsafe fn invalidateRestorableState(&self);

        #[method_id(@__retain_semantics Other restorableStateKeyPaths)]
        pub unsafe fn restorableStateKeyPaths(mtm: MainThreadMarker)
            -> Retained<NSArray<NSString>>;

        #[method_id(@__retain_semantics Other allowedClassesForRestorableStateKeyPath:)]
        pub unsafe fn allowedClassesForRestorableStateKeyPath(
            key_path: &NSString,
            mtm: MainThreadMarker,
        ) -> Retained<NSArray<TodoClass>>;
    }
);