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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use objc2::__framework_prelude::*;

use crate::*;

pub type NSPointPointer = *mut NSPoint;

pub type NSPointArray = *mut NSPoint;

pub type NSSizePointer = *mut NSSize;

pub type NSSizeArray = *mut NSSize;

pub type NSRectPointer = *mut NSRect;

pub type NSRectArray = *mut NSRect;

#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct NSEdgeInsets {
    pub top: CGFloat,
    pub left: CGFloat,
    pub bottom: CGFloat,
    pub right: CGFloat,
}

unsafe impl Encode for NSEdgeInsets {
    const ENCODING: Encoding = Encoding::Struct(
        "NSEdgeInsets",
        &[
            <CGFloat>::ENCODING,
            <CGFloat>::ENCODING,
            <CGFloat>::ENCODING,
            <CGFloat>::ENCODING,
        ],
    );
}

unsafe impl RefEncode for NSEdgeInsets {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

unsafe impl Send for NSEdgeInsets {}

unsafe impl Sync for NSEdgeInsets {}

// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSAlignmentOptions(pub c_ulonglong);
bitflags::bitflags! {
    impl NSAlignmentOptions: c_ulonglong {
        const NSAlignMinXInward = 1<<0;
        const NSAlignMinYInward = 1<<1;
        const NSAlignMaxXInward = 1<<2;
        const NSAlignMaxYInward = 1<<3;
        const NSAlignWidthInward = 1<<4;
        const NSAlignHeightInward = 1<<5;
        const NSAlignMinXOutward = 1<<8;
        const NSAlignMinYOutward = 1<<9;
        const NSAlignMaxXOutward = 1<<10;
        const NSAlignMaxYOutward = 1<<11;
        const NSAlignWidthOutward = 1<<12;
        const NSAlignHeightOutward = 1<<13;
        const NSAlignMinXNearest = 1<<16;
        const NSAlignMinYNearest = 1<<17;
        const NSAlignMaxXNearest = 1<<18;
        const NSAlignMaxYNearest = 1<<19;
        const NSAlignWidthNearest = 1<<20;
        const NSAlignHeightNearest = 1<<21;
        const NSAlignRectFlipped = 1<<63;
        const NSAlignAllEdgesInward = NSAlignmentOptions::NSAlignMinXInward.0|NSAlignmentOptions::NSAlignMaxXInward.0|NSAlignmentOptions::NSAlignMinYInward.0|NSAlignmentOptions::NSAlignMaxYInward.0;
        const NSAlignAllEdgesOutward = NSAlignmentOptions::NSAlignMinXOutward.0|NSAlignmentOptions::NSAlignMaxXOutward.0|NSAlignmentOptions::NSAlignMinYOutward.0|NSAlignmentOptions::NSAlignMaxYOutward.0;
        const NSAlignAllEdgesNearest = NSAlignmentOptions::NSAlignMinXNearest.0|NSAlignmentOptions::NSAlignMaxXNearest.0|NSAlignmentOptions::NSAlignMinYNearest.0|NSAlignmentOptions::NSAlignMaxYNearest.0;
    }
}

unsafe impl Encode for NSAlignmentOptions {
    const ENCODING: Encoding = c_ulonglong::ENCODING;
}

unsafe impl RefEncode for NSAlignmentOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern "C" {
    pub static NSZeroPoint: NSPoint;
}

extern "C" {
    pub static NSZeroSize: NSSize;
}

extern "C" {
    pub static NSZeroRect: NSRect;
}

extern "C" {
    pub static NSEdgeInsetsZero: NSEdgeInsets;
}

// TODO: pub fn NSMakePoint(x: CGFloat,y: CGFloat,) -> NSPoint;

// TODO: pub fn NSMakeSize(w: CGFloat,h: CGFloat,) -> NSSize;

// TODO: pub fn NSMakeRect(x: CGFloat,y: CGFloat,w: CGFloat,h: CGFloat,) -> NSRect;

// TODO: pub fn NSMaxX(a_rect: NSRect,) -> CGFloat;

// TODO: pub fn NSMaxY(a_rect: NSRect,) -> CGFloat;

// TODO: pub fn NSMidX(a_rect: NSRect,) -> CGFloat;

// TODO: pub fn NSMidY(a_rect: NSRect,) -> CGFloat;

// TODO: pub fn NSMinX(a_rect: NSRect,) -> CGFloat;

// TODO: pub fn NSMinY(a_rect: NSRect,) -> CGFloat;

// TODO: pub fn NSWidth(a_rect: NSRect,) -> CGFloat;

// TODO: pub fn NSHeight(a_rect: NSRect,) -> CGFloat;

// TODO: pub fn NSRectFromCGRect(cgrect: CGRect,) -> NSRect;

// TODO: pub fn NSRectToCGRect(nsrect: NSRect,) -> CGRect;

// TODO: pub fn NSPointFromCGPoint(cgpoint: CGPoint,) -> NSPoint;

// TODO: pub fn NSPointToCGPoint(nspoint: NSPoint,) -> CGPoint;

// TODO: pub fn NSSizeFromCGSize(cgsize: CGSize,) -> NSSize;

// TODO: pub fn NSSizeToCGSize(nssize: NSSize,) -> CGSize;

// TODO: pub fn NSEdgeInsetsMake(top: CGFloat,left: CGFloat,bottom: CGFloat,right: CGFloat,) -> NSEdgeInsets;

extern "C" {
    pub fn NSEqualPoints(a_point: NSPoint, b_point: NSPoint) -> Bool;
}

extern "C" {
    pub fn NSEqualSizes(a_size: NSSize, b_size: NSSize) -> Bool;
}

extern "C" {
    pub fn NSEqualRects(a_rect: NSRect, b_rect: NSRect) -> Bool;
}

extern "C" {
    pub fn NSIsEmptyRect(a_rect: NSRect) -> Bool;
}

extern "C" {
    pub fn NSEdgeInsetsEqual(a_insets: NSEdgeInsets, b_insets: NSEdgeInsets) -> Bool;
}

extern "C" {
    pub fn NSInsetRect(a_rect: NSRect, d_x: CGFloat, d_y: CGFloat) -> NSRect;
}

extern "C" {
    pub fn NSIntegralRect(a_rect: NSRect) -> NSRect;
}

extern "C" {
    pub fn NSIntegralRectWithOptions(a_rect: NSRect, opts: NSAlignmentOptions) -> NSRect;
}

extern "C" {
    pub fn NSUnionRect(a_rect: NSRect, b_rect: NSRect) -> NSRect;
}

extern "C" {
    pub fn NSIntersectionRect(a_rect: NSRect, b_rect: NSRect) -> NSRect;
}

extern "C" {
    pub fn NSOffsetRect(a_rect: NSRect, d_x: CGFloat, d_y: CGFloat) -> NSRect;
}

extern "C" {
    pub fn NSDivideRect(
        in_rect: NSRect,
        slice: NonNull<NSRect>,
        rem: NonNull<NSRect>,
        amount: CGFloat,
        edge: NSRectEdge,
    );
}

extern "C" {
    pub fn NSPointInRect(a_point: NSPoint, a_rect: NSRect) -> Bool;
}

extern "C" {
    pub fn NSMouseInRect(a_point: NSPoint, a_rect: NSRect, flipped: Bool) -> Bool;
}

extern "C" {
    pub fn NSContainsRect(a_rect: NSRect, b_rect: NSRect) -> Bool;
}

extern "C" {
    pub fn NSIntersectsRect(a_rect: NSRect, b_rect: NSRect) -> Bool;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub fn NSStringFromPoint(a_point: NSPoint) -> NonNull<NSString>;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub fn NSStringFromSize(a_size: NSSize) -> NonNull<NSString>;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub fn NSStringFromRect(a_rect: NSRect) -> NonNull<NSString>;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub fn NSPointFromString(a_string: &NSString) -> NSPoint;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub fn NSSizeFromString(a_string: &NSString) -> NSSize;
}

extern "C" {
    #[cfg(feature = "NSString")]
    pub fn NSRectFromString(a_string: &NSString) -> NSRect;
}

extern_methods!(
    /// NSValueGeometryExtensions
    #[cfg(feature = "NSValue")]
    unsafe impl NSValue {
        #[method_id(@__retain_semantics Other valueWithPoint:)]
        pub unsafe fn valueWithPoint(point: NSPoint) -> Retained<NSValue>;

        #[method_id(@__retain_semantics Other valueWithSize:)]
        pub unsafe fn valueWithSize(size: NSSize) -> Retained<NSValue>;

        #[method_id(@__retain_semantics Other valueWithRect:)]
        pub unsafe fn valueWithRect(rect: NSRect) -> Retained<NSValue>;

        #[method_id(@__retain_semantics Other valueWithEdgeInsets:)]
        pub unsafe fn valueWithEdgeInsets(insets: NSEdgeInsets) -> Retained<NSValue>;

        #[method(pointValue)]
        pub unsafe fn pointValue(&self) -> NSPoint;

        #[method(sizeValue)]
        pub unsafe fn sizeValue(&self) -> NSSize;

        #[method(rectValue)]
        pub unsafe fn rectValue(&self) -> NSRect;

        #[method(edgeInsetsValue)]
        pub unsafe fn edgeInsetsValue(&self) -> NSEdgeInsets;
    }
);

extern_methods!(
    /// NSGeometryCoding
    #[cfg(feature = "NSCoder")]
    unsafe impl NSCoder {
        #[method(encodePoint:)]
        pub unsafe fn encodePoint(&self, point: NSPoint);

        #[method(decodePoint)]
        pub unsafe fn decodePoint(&self) -> NSPoint;

        #[method(encodeSize:)]
        pub unsafe fn encodeSize(&self, size: NSSize);

        #[method(decodeSize)]
        pub unsafe fn decodeSize(&self) -> NSSize;

        #[method(encodeRect:)]
        pub unsafe fn encodeRect(&self, rect: NSRect);

        #[method(decodeRect)]
        pub unsafe fn decodeRect(&self) -> NSRect;
    }
);

extern_methods!(
    /// NSGeometryKeyedCoding
    #[cfg(feature = "NSCoder")]
    unsafe impl NSCoder {
        #[cfg(feature = "NSString")]
        #[method(encodePoint:forKey:)]
        pub unsafe fn encodePoint_forKey(&self, point: NSPoint, key: &NSString);

        #[cfg(feature = "NSString")]
        #[method(encodeSize:forKey:)]
        pub unsafe fn encodeSize_forKey(&self, size: NSSize, key: &NSString);

        #[cfg(feature = "NSString")]
        #[method(encodeRect:forKey:)]
        pub unsafe fn encodeRect_forKey(&self, rect: NSRect, key: &NSString);

        #[cfg(feature = "NSString")]
        #[method(decodePointForKey:)]
        pub unsafe fn decodePointForKey(&self, key: &NSString) -> NSPoint;

        #[cfg(feature = "NSString")]
        #[method(decodeSizeForKey:)]
        pub unsafe fn decodeSizeForKey(&self, key: &NSString) -> NSSize;

        #[cfg(feature = "NSString")]
        #[method(decodeRectForKey:)]
        pub unsafe fn decodeRectForKey(&self, key: &NSString) -> NSRect;
    }
);