objc2_foundation/generated/
NSRange.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ptr::NonNull;
4use objc2::__framework_prelude::*;
5
6use crate::*;
7
8/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsrangepointer?language=objc)
9pub type NSRangePointer = *mut NSRange;
10
11// TODO: pub fn NSMakeRange(loc: NSUInteger,len: NSUInteger,) -> NSRange;
12
13// TODO: pub fn NSMaxRange(range: NSRange,) -> NSUInteger;
14
15// TODO: pub fn NSLocationInRange(loc: NSUInteger,range: NSRange,) -> Bool;
16
17// TODO: pub fn NSEqualRanges(range1: NSRange,range2: NSRange,) -> Bool;
18
19extern "C-unwind" {
20    pub fn NSUnionRange(range1: NSRange, range2: NSRange) -> NSRange;
21}
22
23extern "C-unwind" {
24    pub fn NSIntersectionRange(range1: NSRange, range2: NSRange) -> NSRange;
25}
26
27#[cfg(feature = "NSString")]
28impl NSString {
29    #[doc(alias = "NSStringFromRange")]
30    #[cfg(feature = "NSString")]
31    #[inline]
32    pub unsafe fn from_range(range: NSRange) -> Retained<NSString> {
33        extern "C-unwind" {
34            fn NSStringFromRange(range: NSRange) -> *mut NSString;
35        }
36        let ret = unsafe { NSStringFromRange(range) };
37        unsafe { Retained::retain_autoreleased(ret) }
38            .expect("function was marked as returning non-null, but actually returned NULL")
39    }
40}
41
42extern "C-unwind" {
43    #[cfg(feature = "NSString")]
44    pub fn NSRangeFromString(a_string: &NSString) -> NSRange;
45}
46
47/// NSValueRangeExtensions.
48#[cfg(feature = "NSValue")]
49impl NSValue {
50    extern_methods!(
51        #[unsafe(method(valueWithRange:))]
52        #[unsafe(method_family = none)]
53        pub unsafe fn valueWithRange(range: NSRange) -> Retained<NSValue>;
54
55        #[unsafe(method(rangeValue))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn rangeValue(&self) -> NSRange;
58    );
59}
60
61#[cfg(feature = "NSString")]
62#[deprecated = "renamed to `NSString::from_range`"]
63#[inline]
64pub unsafe extern "C-unwind" fn NSStringFromRange(range: NSRange) -> Retained<NSString> {
65    extern "C-unwind" {
66        fn NSStringFromRange(range: NSRange) -> *mut NSString;
67    }
68    let ret = unsafe { NSStringFromRange(range) };
69    unsafe { Retained::retain_autoreleased(ret) }
70        .expect("function was marked as returning non-null, but actually returned NULL")
71}