objc2_foundation/generated/
NSGeometry.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-foundation")]
7use objc2_core_foundation::*;
8
9use crate::*;
10
11#[cfg(feature = "objc2-core-foundation")]
13pub type NSPointPointer = *mut NSPoint;
14
15#[cfg(feature = "objc2-core-foundation")]
17pub type NSPointArray = *mut NSPoint;
18
19#[cfg(feature = "objc2-core-foundation")]
21pub type NSSizePointer = *mut NSSize;
22
23#[cfg(feature = "objc2-core-foundation")]
25pub type NSSizeArray = *mut NSSize;
26
27#[cfg(feature = "objc2-core-foundation")]
29pub type NSRectPointer = *mut NSRect;
30
31#[cfg(feature = "objc2-core-foundation")]
33pub type NSRectArray = *mut NSRect;
34
35#[cfg(feature = "objc2-core-foundation")]
37#[repr(C)]
38#[derive(Clone, Copy, Debug, PartialEq)]
39pub struct NSEdgeInsets {
40 pub top: CGFloat,
41 pub left: CGFloat,
42 pub bottom: CGFloat,
43 pub right: CGFloat,
44}
45
46#[cfg(feature = "objc2-core-foundation")]
47unsafe impl Encode for NSEdgeInsets {
48 const ENCODING: Encoding = Encoding::Struct(
49 "NSEdgeInsets",
50 &[
51 <CGFloat>::ENCODING,
52 <CGFloat>::ENCODING,
53 <CGFloat>::ENCODING,
54 <CGFloat>::ENCODING,
55 ],
56 );
57}
58
59#[cfg(feature = "objc2-core-foundation")]
60unsafe impl RefEncode for NSEdgeInsets {
61 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
62}
63
64#[cfg(feature = "objc2-core-foundation")]
65unsafe impl Send for NSEdgeInsets {}
66
67#[cfg(feature = "objc2-core-foundation")]
68unsafe impl Sync for NSEdgeInsets {}
69
70#[repr(transparent)]
73#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
74pub struct NSAlignmentOptions(pub c_ulonglong);
75bitflags::bitflags! {
76 impl NSAlignmentOptions: c_ulonglong {
77 #[doc(alias = "NSAlignMinXInward")]
78 const AlignMinXInward = 1<<0;
79 #[doc(alias = "NSAlignMinYInward")]
80 const AlignMinYInward = 1<<1;
81 #[doc(alias = "NSAlignMaxXInward")]
82 const AlignMaxXInward = 1<<2;
83 #[doc(alias = "NSAlignMaxYInward")]
84 const AlignMaxYInward = 1<<3;
85 #[doc(alias = "NSAlignWidthInward")]
86 const AlignWidthInward = 1<<4;
87 #[doc(alias = "NSAlignHeightInward")]
88 const AlignHeightInward = 1<<5;
89 #[doc(alias = "NSAlignMinXOutward")]
90 const AlignMinXOutward = 1<<8;
91 #[doc(alias = "NSAlignMinYOutward")]
92 const AlignMinYOutward = 1<<9;
93 #[doc(alias = "NSAlignMaxXOutward")]
94 const AlignMaxXOutward = 1<<10;
95 #[doc(alias = "NSAlignMaxYOutward")]
96 const AlignMaxYOutward = 1<<11;
97 #[doc(alias = "NSAlignWidthOutward")]
98 const AlignWidthOutward = 1<<12;
99 #[doc(alias = "NSAlignHeightOutward")]
100 const AlignHeightOutward = 1<<13;
101 #[doc(alias = "NSAlignMinXNearest")]
102 const AlignMinXNearest = 1<<16;
103 #[doc(alias = "NSAlignMinYNearest")]
104 const AlignMinYNearest = 1<<17;
105 #[doc(alias = "NSAlignMaxXNearest")]
106 const AlignMaxXNearest = 1<<18;
107 #[doc(alias = "NSAlignMaxYNearest")]
108 const AlignMaxYNearest = 1<<19;
109 #[doc(alias = "NSAlignWidthNearest")]
110 const AlignWidthNearest = 1<<20;
111 #[doc(alias = "NSAlignHeightNearest")]
112 const AlignHeightNearest = 1<<21;
113 #[doc(alias = "NSAlignRectFlipped")]
114 const AlignRectFlipped = 1<<63;
115 #[doc(alias = "NSAlignAllEdgesInward")]
116 const AlignAllEdgesInward = NSAlignmentOptions::AlignMinXInward.0|NSAlignmentOptions::AlignMaxXInward.0|NSAlignmentOptions::AlignMinYInward.0|NSAlignmentOptions::AlignMaxYInward.0;
117 #[doc(alias = "NSAlignAllEdgesOutward")]
118 const AlignAllEdgesOutward = NSAlignmentOptions::AlignMinXOutward.0|NSAlignmentOptions::AlignMaxXOutward.0|NSAlignmentOptions::AlignMinYOutward.0|NSAlignmentOptions::AlignMaxYOutward.0;
119 #[doc(alias = "NSAlignAllEdgesNearest")]
120 const AlignAllEdgesNearest = NSAlignmentOptions::AlignMinXNearest.0|NSAlignmentOptions::AlignMaxXNearest.0|NSAlignmentOptions::AlignMinYNearest.0|NSAlignmentOptions::AlignMaxYNearest.0;
121 }
122}
123
124unsafe impl Encode for NSAlignmentOptions {
125 const ENCODING: Encoding = c_ulonglong::ENCODING;
126}
127
128unsafe impl RefEncode for NSAlignmentOptions {
129 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
130}
131
132extern "C" {
133 #[cfg(feature = "objc2-core-foundation")]
135 pub static NSZeroPoint: NSPoint;
136}
137
138extern "C" {
139 #[cfg(feature = "objc2-core-foundation")]
141 pub static NSZeroSize: NSSize;
142}
143
144extern "C" {
145 #[cfg(feature = "objc2-core-foundation")]
147 pub static NSZeroRect: NSRect;
148}
149
150extern "C" {
151 #[cfg(feature = "objc2-core-foundation")]
153 pub static NSEdgeInsetsZero: NSEdgeInsets;
154}
155
156#[cfg(feature = "objc2-core-foundation")]
191impl NSEdgeInsets {
192 }
194
195#[cfg(feature = "objc2-core-foundation")]
196#[inline]
197pub extern "C-unwind" fn NSEqualPoints(a_point: NSPoint, b_point: NSPoint) -> bool {
198 extern "C-unwind" {
199 fn NSEqualPoints(a_point: NSPoint, b_point: NSPoint) -> Bool;
200 }
201 unsafe { NSEqualPoints(a_point, b_point) }.as_bool()
202}
203
204#[cfg(feature = "objc2-core-foundation")]
205#[inline]
206pub extern "C-unwind" fn NSEqualSizes(a_size: NSSize, b_size: NSSize) -> bool {
207 extern "C-unwind" {
208 fn NSEqualSizes(a_size: NSSize, b_size: NSSize) -> Bool;
209 }
210 unsafe { NSEqualSizes(a_size, b_size) }.as_bool()
211}
212
213#[cfg(feature = "objc2-core-foundation")]
214#[inline]
215pub extern "C-unwind" fn NSEqualRects(a_rect: NSRect, b_rect: NSRect) -> bool {
216 extern "C-unwind" {
217 fn NSEqualRects(a_rect: NSRect, b_rect: NSRect) -> Bool;
218 }
219 unsafe { NSEqualRects(a_rect, b_rect) }.as_bool()
220}
221
222#[cfg(feature = "objc2-core-foundation")]
223#[inline]
224pub extern "C-unwind" fn NSIsEmptyRect(a_rect: NSRect) -> bool {
225 extern "C-unwind" {
226 fn NSIsEmptyRect(a_rect: NSRect) -> Bool;
227 }
228 unsafe { NSIsEmptyRect(a_rect) }.as_bool()
229}
230
231#[cfg(feature = "objc2-core-foundation")]
232impl NSEdgeInsets {
233 #[doc(alias = "NSEdgeInsetsEqual")]
234 #[cfg(feature = "objc2-core-foundation")]
235 #[inline]
236 pub fn equal(self, b_insets: NSEdgeInsets) -> bool {
237 extern "C-unwind" {
238 fn NSEdgeInsetsEqual(a_insets: NSEdgeInsets, b_insets: NSEdgeInsets) -> Bool;
239 }
240 unsafe { NSEdgeInsetsEqual(self, b_insets) }.as_bool()
241 }
242}
243
244#[cfg(feature = "objc2-core-foundation")]
245#[inline]
246pub extern "C-unwind" fn NSInsetRect(a_rect: NSRect, d_x: CGFloat, d_y: CGFloat) -> NSRect {
247 extern "C-unwind" {
248 fn NSInsetRect(a_rect: NSRect, d_x: CGFloat, d_y: CGFloat) -> NSRect;
249 }
250 unsafe { NSInsetRect(a_rect, d_x, d_y) }
251}
252
253#[cfg(feature = "objc2-core-foundation")]
254#[inline]
255pub extern "C-unwind" fn NSIntegralRect(a_rect: NSRect) -> NSRect {
256 extern "C-unwind" {
257 fn NSIntegralRect(a_rect: NSRect) -> NSRect;
258 }
259 unsafe { NSIntegralRect(a_rect) }
260}
261
262#[cfg(feature = "objc2-core-foundation")]
263#[inline]
264pub extern "C-unwind" fn NSIntegralRectWithOptions(
265 a_rect: NSRect,
266 opts: NSAlignmentOptions,
267) -> NSRect {
268 extern "C-unwind" {
269 fn NSIntegralRectWithOptions(a_rect: NSRect, opts: NSAlignmentOptions) -> NSRect;
270 }
271 unsafe { NSIntegralRectWithOptions(a_rect, opts) }
272}
273
274#[cfg(feature = "objc2-core-foundation")]
275#[inline]
276pub extern "C-unwind" fn NSUnionRect(a_rect: NSRect, b_rect: NSRect) -> NSRect {
277 extern "C-unwind" {
278 fn NSUnionRect(a_rect: NSRect, b_rect: NSRect) -> NSRect;
279 }
280 unsafe { NSUnionRect(a_rect, b_rect) }
281}
282
283#[cfg(feature = "objc2-core-foundation")]
284#[inline]
285pub extern "C-unwind" fn NSIntersectionRect(a_rect: NSRect, b_rect: NSRect) -> NSRect {
286 extern "C-unwind" {
287 fn NSIntersectionRect(a_rect: NSRect, b_rect: NSRect) -> NSRect;
288 }
289 unsafe { NSIntersectionRect(a_rect, b_rect) }
290}
291
292#[cfg(feature = "objc2-core-foundation")]
293#[inline]
294pub extern "C-unwind" fn NSOffsetRect(a_rect: NSRect, d_x: CGFloat, d_y: CGFloat) -> NSRect {
295 extern "C-unwind" {
296 fn NSOffsetRect(a_rect: NSRect, d_x: CGFloat, d_y: CGFloat) -> NSRect;
297 }
298 unsafe { NSOffsetRect(a_rect, d_x, d_y) }
299}
300
301extern "C-unwind" {
302 #[cfg(feature = "objc2-core-foundation")]
307 pub fn NSDivideRect(
308 in_rect: NSRect,
309 slice: NonNull<NSRect>,
310 rem: NonNull<NSRect>,
311 amount: CGFloat,
312 edge: NSRectEdge,
313 );
314}
315
316#[cfg(feature = "objc2-core-foundation")]
317#[inline]
318pub extern "C-unwind" fn NSPointInRect(a_point: NSPoint, a_rect: NSRect) -> bool {
319 extern "C-unwind" {
320 fn NSPointInRect(a_point: NSPoint, a_rect: NSRect) -> Bool;
321 }
322 unsafe { NSPointInRect(a_point, a_rect) }.as_bool()
323}
324
325#[cfg(feature = "objc2-core-foundation")]
326#[inline]
327pub extern "C-unwind" fn NSMouseInRect(a_point: NSPoint, a_rect: NSRect, flipped: bool) -> bool {
328 extern "C-unwind" {
329 fn NSMouseInRect(a_point: NSPoint, a_rect: NSRect, flipped: Bool) -> Bool;
330 }
331 unsafe { NSMouseInRect(a_point, a_rect, Bool::new(flipped)) }.as_bool()
332}
333
334#[cfg(feature = "objc2-core-foundation")]
335#[inline]
336pub extern "C-unwind" fn NSContainsRect(a_rect: NSRect, b_rect: NSRect) -> bool {
337 extern "C-unwind" {
338 fn NSContainsRect(a_rect: NSRect, b_rect: NSRect) -> Bool;
339 }
340 unsafe { NSContainsRect(a_rect, b_rect) }.as_bool()
341}
342
343#[cfg(feature = "objc2-core-foundation")]
344#[inline]
345pub extern "C-unwind" fn NSIntersectsRect(a_rect: NSRect, b_rect: NSRect) -> bool {
346 extern "C-unwind" {
347 fn NSIntersectsRect(a_rect: NSRect, b_rect: NSRect) -> Bool;
348 }
349 unsafe { NSIntersectsRect(a_rect, b_rect) }.as_bool()
350}
351
352#[cfg(feature = "NSString")]
353impl NSString {
354 #[doc(alias = "NSStringFromPoint")]
355 #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
356 #[inline]
357 pub fn from_point(a_point: NSPoint) -> Retained<NSString> {
358 extern "C-unwind" {
359 fn NSStringFromPoint(a_point: NSPoint) -> *mut NSString;
360 }
361 let ret = unsafe { NSStringFromPoint(a_point) };
362 unsafe { Retained::retain_autoreleased(ret) }
363 .expect("function was marked as returning non-null, but actually returned NULL")
364 }
365
366 #[doc(alias = "NSStringFromSize")]
367 #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
368 #[inline]
369 pub fn from_size(a_size: NSSize) -> Retained<NSString> {
370 extern "C-unwind" {
371 fn NSStringFromSize(a_size: NSSize) -> *mut NSString;
372 }
373 let ret = unsafe { NSStringFromSize(a_size) };
374 unsafe { Retained::retain_autoreleased(ret) }
375 .expect("function was marked as returning non-null, but actually returned NULL")
376 }
377
378 #[doc(alias = "NSStringFromRect")]
379 #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
380 #[inline]
381 pub fn from_rect(a_rect: NSRect) -> Retained<NSString> {
382 extern "C-unwind" {
383 fn NSStringFromRect(a_rect: NSRect) -> *mut NSString;
384 }
385 let ret = unsafe { NSStringFromRect(a_rect) };
386 unsafe { Retained::retain_autoreleased(ret) }
387 .expect("function was marked as returning non-null, but actually returned NULL")
388 }
389}
390
391#[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
392#[inline]
393pub extern "C-unwind" fn NSPointFromString(a_string: &NSString) -> NSPoint {
394 extern "C-unwind" {
395 fn NSPointFromString(a_string: &NSString) -> NSPoint;
396 }
397 unsafe { NSPointFromString(a_string) }
398}
399
400#[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
401#[inline]
402pub extern "C-unwind" fn NSSizeFromString(a_string: &NSString) -> NSSize {
403 extern "C-unwind" {
404 fn NSSizeFromString(a_string: &NSString) -> NSSize;
405 }
406 unsafe { NSSizeFromString(a_string) }
407}
408
409#[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
410#[inline]
411pub extern "C-unwind" fn NSRectFromString(a_string: &NSString) -> NSRect {
412 extern "C-unwind" {
413 fn NSRectFromString(a_string: &NSString) -> NSRect;
414 }
415 unsafe { NSRectFromString(a_string) }
416}
417
418#[cfg(feature = "NSValue")]
420impl NSValue {
421 extern_methods!(
422 #[cfg(feature = "objc2-core-foundation")]
423 #[unsafe(method(valueWithPoint:))]
424 #[unsafe(method_family = none)]
425 pub unsafe fn valueWithPoint(point: NSPoint) -> Retained<NSValue>;
426
427 #[cfg(feature = "objc2-core-foundation")]
428 #[unsafe(method(valueWithSize:))]
429 #[unsafe(method_family = none)]
430 pub unsafe fn valueWithSize(size: NSSize) -> Retained<NSValue>;
431
432 #[cfg(feature = "objc2-core-foundation")]
433 #[unsafe(method(valueWithRect:))]
434 #[unsafe(method_family = none)]
435 pub unsafe fn valueWithRect(rect: NSRect) -> Retained<NSValue>;
436
437 #[cfg(feature = "objc2-core-foundation")]
438 #[unsafe(method(valueWithEdgeInsets:))]
439 #[unsafe(method_family = none)]
440 pub unsafe fn valueWithEdgeInsets(insets: NSEdgeInsets) -> Retained<NSValue>;
441
442 #[cfg(feature = "objc2-core-foundation")]
443 #[unsafe(method(pointValue))]
444 #[unsafe(method_family = none)]
445 pub unsafe fn pointValue(&self) -> NSPoint;
446
447 #[cfg(feature = "objc2-core-foundation")]
448 #[unsafe(method(sizeValue))]
449 #[unsafe(method_family = none)]
450 pub unsafe fn sizeValue(&self) -> NSSize;
451
452 #[cfg(feature = "objc2-core-foundation")]
453 #[unsafe(method(rectValue))]
454 #[unsafe(method_family = none)]
455 pub unsafe fn rectValue(&self) -> NSRect;
456
457 #[cfg(feature = "objc2-core-foundation")]
458 #[unsafe(method(edgeInsetsValue))]
459 #[unsafe(method_family = none)]
460 pub unsafe fn edgeInsetsValue(&self) -> NSEdgeInsets;
461 );
462}
463
464#[cfg(feature = "NSCoder")]
466impl NSCoder {
467 extern_methods!(
468 #[cfg(feature = "objc2-core-foundation")]
469 #[unsafe(method(encodePoint:))]
470 #[unsafe(method_family = none)]
471 pub unsafe fn encodePoint(&self, point: NSPoint);
472
473 #[cfg(feature = "objc2-core-foundation")]
474 #[unsafe(method(decodePoint))]
475 #[unsafe(method_family = none)]
476 pub unsafe fn decodePoint(&self) -> NSPoint;
477
478 #[cfg(feature = "objc2-core-foundation")]
479 #[unsafe(method(encodeSize:))]
480 #[unsafe(method_family = none)]
481 pub unsafe fn encodeSize(&self, size: NSSize);
482
483 #[cfg(feature = "objc2-core-foundation")]
484 #[unsafe(method(decodeSize))]
485 #[unsafe(method_family = none)]
486 pub unsafe fn decodeSize(&self) -> NSSize;
487
488 #[cfg(feature = "objc2-core-foundation")]
489 #[unsafe(method(encodeRect:))]
490 #[unsafe(method_family = none)]
491 pub unsafe fn encodeRect(&self, rect: NSRect);
492
493 #[cfg(feature = "objc2-core-foundation")]
494 #[unsafe(method(decodeRect))]
495 #[unsafe(method_family = none)]
496 pub unsafe fn decodeRect(&self) -> NSRect;
497 );
498}
499
500#[cfg(feature = "NSCoder")]
502impl NSCoder {
503 extern_methods!(
504 #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
505 #[unsafe(method(encodePoint:forKey:))]
506 #[unsafe(method_family = none)]
507 pub unsafe fn encodePoint_forKey(&self, point: NSPoint, key: &NSString);
508
509 #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
510 #[unsafe(method(encodeSize:forKey:))]
511 #[unsafe(method_family = none)]
512 pub unsafe fn encodeSize_forKey(&self, size: NSSize, key: &NSString);
513
514 #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
515 #[unsafe(method(encodeRect:forKey:))]
516 #[unsafe(method_family = none)]
517 pub unsafe fn encodeRect_forKey(&self, rect: NSRect, key: &NSString);
518
519 #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
520 #[unsafe(method(decodePointForKey:))]
521 #[unsafe(method_family = none)]
522 pub unsafe fn decodePointForKey(&self, key: &NSString) -> NSPoint;
523
524 #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
525 #[unsafe(method(decodeSizeForKey:))]
526 #[unsafe(method_family = none)]
527 pub unsafe fn decodeSizeForKey(&self, key: &NSString) -> NSSize;
528
529 #[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
530 #[unsafe(method(decodeRectForKey:))]
531 #[unsafe(method_family = none)]
532 pub unsafe fn decodeRectForKey(&self, key: &NSString) -> NSRect;
533 );
534}
535
536#[cfg(feature = "objc2-core-foundation")]
537#[deprecated = "renamed to `NSEdgeInsets::equal`"]
538#[inline]
539pub extern "C-unwind" fn NSEdgeInsetsEqual(a_insets: NSEdgeInsets, b_insets: NSEdgeInsets) -> bool {
540 extern "C-unwind" {
541 fn NSEdgeInsetsEqual(a_insets: NSEdgeInsets, b_insets: NSEdgeInsets) -> Bool;
542 }
543 unsafe { NSEdgeInsetsEqual(a_insets, b_insets) }.as_bool()
544}
545
546#[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
547#[deprecated = "renamed to `NSString::from_point`"]
548#[inline]
549pub extern "C-unwind" fn NSStringFromPoint(a_point: NSPoint) -> Retained<NSString> {
550 extern "C-unwind" {
551 fn NSStringFromPoint(a_point: NSPoint) -> *mut NSString;
552 }
553 let ret = unsafe { NSStringFromPoint(a_point) };
554 unsafe { Retained::retain_autoreleased(ret) }
555 .expect("function was marked as returning non-null, but actually returned NULL")
556}
557
558#[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
559#[deprecated = "renamed to `NSString::from_size`"]
560#[inline]
561pub extern "C-unwind" fn NSStringFromSize(a_size: NSSize) -> Retained<NSString> {
562 extern "C-unwind" {
563 fn NSStringFromSize(a_size: NSSize) -> *mut NSString;
564 }
565 let ret = unsafe { NSStringFromSize(a_size) };
566 unsafe { Retained::retain_autoreleased(ret) }
567 .expect("function was marked as returning non-null, but actually returned NULL")
568}
569
570#[cfg(all(feature = "NSString", feature = "objc2-core-foundation"))]
571#[deprecated = "renamed to `NSString::from_rect`"]
572#[inline]
573pub extern "C-unwind" fn NSStringFromRect(a_rect: NSRect) -> Retained<NSString> {
574 extern "C-unwind" {
575 fn NSStringFromRect(a_rect: NSRect) -> *mut NSString;
576 }
577 let ret = unsafe { NSStringFromRect(a_rect) };
578 unsafe { Retained::retain_autoreleased(ret) }
579 .expect("function was marked as returning non-null, but actually returned NULL")
580}