objc2_core_foundation/generated/
CFAttributedString.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9
10use crate::*;
11
12/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfattributedstring?language=objc)
13///
14/// This is toll-free bridged with `NSAttributedString`.
15#[doc(alias = "CFAttributedStringRef")]
16#[repr(C)]
17pub struct CFAttributedString {
18    inner: [u8; 0],
19    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
20}
21
22cf_type!(
23    unsafe impl CFAttributedString {}
24);
25#[cfg(feature = "objc2")]
26cf_objc2_type!(
27    unsafe impl RefEncode<"__CFAttributedString"> for CFAttributedString {}
28);
29
30/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfmutableattributedstring?language=objc)
31///
32/// This is toll-free bridged with `NSMutableAttributedString`.
33#[doc(alias = "CFMutableAttributedStringRef")]
34#[repr(C)]
35pub struct CFMutableAttributedString {
36    inner: [u8; 0],
37    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
38}
39
40cf_type!(
41    unsafe impl CFMutableAttributedString: CFAttributedString {}
42);
43#[cfg(feature = "objc2")]
44cf_objc2_type!(
45    unsafe impl RefEncode<"__CFAttributedString"> for CFMutableAttributedString {}
46);
47
48unsafe impl ConcreteType for CFAttributedString {
49    /// Returns the type identifier of all CFAttributedString instances.
50    #[doc(alias = "CFAttributedStringGetTypeID")]
51    #[inline]
52    fn type_id() -> CFTypeID {
53        extern "C-unwind" {
54            fn CFAttributedStringGetTypeID() -> CFTypeID;
55        }
56        unsafe { CFAttributedStringGetTypeID() }
57    }
58}
59
60impl CFAttributedString {
61    /// Creates an attributed string with the specified string and attributes (both copied).
62    ///
63    /// # Safety
64    ///
65    /// - `alloc` might not allow `None`.
66    /// - `str` might not allow `None`.
67    /// - `attributes` generics must be of the correct type.
68    /// - `attributes` might not allow `None`.
69    #[doc(alias = "CFAttributedStringCreate")]
70    #[cfg(feature = "CFDictionary")]
71    #[inline]
72    pub unsafe fn new(
73        alloc: Option<&CFAllocator>,
74        str: Option<&CFString>,
75        attributes: Option<&CFDictionary>,
76    ) -> Option<CFRetained<CFAttributedString>> {
77        extern "C-unwind" {
78            fn CFAttributedStringCreate(
79                alloc: Option<&CFAllocator>,
80                str: Option<&CFString>,
81                attributes: Option<&CFDictionary>,
82            ) -> Option<NonNull<CFAttributedString>>;
83        }
84        let ret = unsafe { CFAttributedStringCreate(alloc, str, attributes) };
85        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
86    }
87
88    /// Creates a sub-attributed string from the specified range. It's a programming error for range to specify characters outside the bounds of aStr.
89    ///
90    /// # Safety
91    ///
92    /// - `alloc` might not allow `None`.
93    /// - `a_str` might not allow `None`.
94    #[doc(alias = "CFAttributedStringCreateWithSubstring")]
95    #[inline]
96    pub unsafe fn with_substring(
97        alloc: Option<&CFAllocator>,
98        a_str: Option<&CFAttributedString>,
99        range: CFRange,
100    ) -> Option<CFRetained<CFAttributedString>> {
101        extern "C-unwind" {
102            fn CFAttributedStringCreateWithSubstring(
103                alloc: Option<&CFAllocator>,
104                a_str: Option<&CFAttributedString>,
105                range: CFRange,
106            ) -> Option<NonNull<CFAttributedString>>;
107        }
108        let ret = unsafe { CFAttributedStringCreateWithSubstring(alloc, a_str, range) };
109        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
110    }
111
112    /// Creates an immutable attributed string copy.
113    #[doc(alias = "CFAttributedStringCreateCopy")]
114    #[inline]
115    pub fn new_copy(
116        alloc: Option<&CFAllocator>,
117        a_str: Option<&CFAttributedString>,
118    ) -> Option<CFRetained<CFAttributedString>> {
119        extern "C-unwind" {
120            fn CFAttributedStringCreateCopy(
121                alloc: Option<&CFAllocator>,
122                a_str: Option<&CFAttributedString>,
123            ) -> Option<NonNull<CFAttributedString>>;
124        }
125        let ret = unsafe { CFAttributedStringCreateCopy(alloc, a_str) };
126        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
127    }
128
129    /// Returns the string for the attributed string. For performance reasons, this will often point at the backing store of the attributed string, and it might change if the attributed string is edited.  However, this is an implementation detail, and definitely not something that should be counted on.
130    #[doc(alias = "CFAttributedStringGetString")]
131    #[inline]
132    pub fn string(&self) -> Option<CFRetained<CFString>> {
133        extern "C-unwind" {
134            fn CFAttributedStringGetString(a_str: &CFAttributedString)
135                -> Option<NonNull<CFString>>;
136        }
137        let ret = unsafe { CFAttributedStringGetString(self) };
138        ret.map(|ret| unsafe { CFRetained::retain(ret) })
139    }
140
141    /// Returns the length of the attributed string in characters; same as CFStringGetLength(CFAttributedStringGetString(aStr))
142    #[doc(alias = "CFAttributedStringGetLength")]
143    #[inline]
144    pub fn length(&self) -> CFIndex {
145        extern "C-unwind" {
146            fn CFAttributedStringGetLength(a_str: &CFAttributedString) -> CFIndex;
147        }
148        unsafe { CFAttributedStringGetLength(self) }
149    }
150
151    /// Returns the attributes at the specified location. If effectiveRange is not NULL, upon return *effectiveRange contains a range over which the exact same set of attributes apply. Note that for performance reasons, the returned effectiveRange is not necessarily the maximal range - for that, use CFAttributedStringGetAttributesAndLongestEffectiveRange().  It's a programming error for loc to specify a location outside the bounds of the attributed string.
152    ///
153    /// Note that the returned attribute dictionary might change in unpredictable ways from under the caller if the attributed string is edited after this call. If you wish to hang on to the dictionary long-term, you should make an actual copy of it rather than just retaining it.  Also, no assumptions should be made about the relationship of the actual CFDictionaryRef returned by this call and the dictionary originally used to set the attributes, other than the fact that the values stored in the dictionary will be identical (that is, ==) to those originally specified.
154    ///
155    /// # Safety
156    ///
157    /// `effective_range` must be a valid pointer.
158    #[doc(alias = "CFAttributedStringGetAttributes")]
159    #[cfg(feature = "CFDictionary")]
160    #[inline]
161    pub unsafe fn attributes(
162        &self,
163        loc: CFIndex,
164        effective_range: *mut CFRange,
165    ) -> Option<CFRetained<CFDictionary>> {
166        extern "C-unwind" {
167            fn CFAttributedStringGetAttributes(
168                a_str: &CFAttributedString,
169                loc: CFIndex,
170                effective_range: *mut CFRange,
171            ) -> Option<NonNull<CFDictionary>>;
172        }
173        let ret = unsafe { CFAttributedStringGetAttributes(self, loc, effective_range) };
174        ret.map(|ret| unsafe { CFRetained::retain(ret) })
175    }
176
177    /// Returns the value of a single attribute at the specified location. If the specified attribute doesn't exist at the location, returns NULL. If effectiveRange is not NULL, upon return *effectiveRange contains a range over which the exact same attribute value applies. Note that for performance reasons, the returned effectiveRange is not necessarily the maximal range - for that, use CFAttributedStringGetAttributeAndLongestEffectiveRange(). It's a programming error for loc to specify a location outside the bounds of the attributed string.
178    ///
179    /// # Safety
180    ///
181    /// - `attr_name` might not allow `None`.
182    /// - `effective_range` must be a valid pointer.
183    #[doc(alias = "CFAttributedStringGetAttribute")]
184    #[inline]
185    pub unsafe fn attribute(
186        &self,
187        loc: CFIndex,
188        attr_name: Option<&CFString>,
189        effective_range: *mut CFRange,
190    ) -> Option<CFRetained<CFType>> {
191        extern "C-unwind" {
192            fn CFAttributedStringGetAttribute(
193                a_str: &CFAttributedString,
194                loc: CFIndex,
195                attr_name: Option<&CFString>,
196                effective_range: *mut CFRange,
197            ) -> Option<NonNull<CFType>>;
198        }
199        let ret = unsafe { CFAttributedStringGetAttribute(self, loc, attr_name, effective_range) };
200        ret.map(|ret| unsafe { CFRetained::retain(ret) })
201    }
202
203    /// Returns the attributes at the specified location. If longestEffectiveRange is not NULL, upon return *longestEffectiveRange contains the maximal range within inRange over which the exact same set of attributes apply. The returned range is clipped to inRange. It's a programming error for loc or inRange to specify locations outside the bounds of the attributed string.
204    ///
205    /// # Safety
206    ///
207    /// `longest_effective_range` must be a valid pointer.
208    #[doc(alias = "CFAttributedStringGetAttributesAndLongestEffectiveRange")]
209    #[cfg(feature = "CFDictionary")]
210    #[inline]
211    pub unsafe fn attributes_and_longest_effective_range(
212        &self,
213        loc: CFIndex,
214        in_range: CFRange,
215        longest_effective_range: *mut CFRange,
216    ) -> Option<CFRetained<CFDictionary>> {
217        extern "C-unwind" {
218            fn CFAttributedStringGetAttributesAndLongestEffectiveRange(
219                a_str: &CFAttributedString,
220                loc: CFIndex,
221                in_range: CFRange,
222                longest_effective_range: *mut CFRange,
223            ) -> Option<NonNull<CFDictionary>>;
224        }
225        let ret = unsafe {
226            CFAttributedStringGetAttributesAndLongestEffectiveRange(
227                self,
228                loc,
229                in_range,
230                longest_effective_range,
231            )
232        };
233        ret.map(|ret| unsafe { CFRetained::retain(ret) })
234    }
235
236    /// Returns the value of a single attribute at the specified location. If longestEffectiveRange is not NULL, upon return *longestEffectiveRange contains the maximal range within inRange over which the exact same attribute value applies. The returned range is clipped to inRange. It's a programming error for loc or inRange to specify locations outside the bounds of the attributed string.
237    ///
238    /// # Safety
239    ///
240    /// - `attr_name` might not allow `None`.
241    /// - `longest_effective_range` must be a valid pointer.
242    #[doc(alias = "CFAttributedStringGetAttributeAndLongestEffectiveRange")]
243    #[inline]
244    pub unsafe fn attribute_and_longest_effective_range(
245        &self,
246        loc: CFIndex,
247        attr_name: Option<&CFString>,
248        in_range: CFRange,
249        longest_effective_range: *mut CFRange,
250    ) -> Option<CFRetained<CFType>> {
251        extern "C-unwind" {
252            fn CFAttributedStringGetAttributeAndLongestEffectiveRange(
253                a_str: &CFAttributedString,
254                loc: CFIndex,
255                attr_name: Option<&CFString>,
256                in_range: CFRange,
257                longest_effective_range: *mut CFRange,
258            ) -> Option<NonNull<CFType>>;
259        }
260        let ret = unsafe {
261            CFAttributedStringGetAttributeAndLongestEffectiveRange(
262                self,
263                loc,
264                attr_name,
265                in_range,
266                longest_effective_range,
267            )
268        };
269        ret.map(|ret| unsafe { CFRetained::retain(ret) })
270    }
271}
272
273impl CFMutableAttributedString {
274    /// Creates a mutable attributed string copy. maxLength, if not 0, is a hard bound on the length of the attributed string; exceeding this size limit during any editing operation is a programming error. If 0, there is no limit on the length.
275    #[doc(alias = "CFAttributedStringCreateMutableCopy")]
276    #[inline]
277    pub fn new_copy(
278        alloc: Option<&CFAllocator>,
279        max_length: CFIndex,
280        a_str: Option<&CFAttributedString>,
281    ) -> Option<CFRetained<CFMutableAttributedString>> {
282        extern "C-unwind" {
283            fn CFAttributedStringCreateMutableCopy(
284                alloc: Option<&CFAllocator>,
285                max_length: CFIndex,
286                a_str: Option<&CFAttributedString>,
287            ) -> Option<NonNull<CFMutableAttributedString>>;
288        }
289        let ret = unsafe { CFAttributedStringCreateMutableCopy(alloc, max_length, a_str) };
290        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
291    }
292
293    /// Creates a mutable empty attributed string. maxLength, if not 0, is a hard bound on the length of the attributed string; exceeding this size limit during any editing operation is a programming error. If 0, there is no limit on the length.
294    #[doc(alias = "CFAttributedStringCreateMutable")]
295    #[inline]
296    pub fn new(
297        alloc: Option<&CFAllocator>,
298        max_length: CFIndex,
299    ) -> Option<CFRetained<CFMutableAttributedString>> {
300        extern "C-unwind" {
301            fn CFAttributedStringCreateMutable(
302                alloc: Option<&CFAllocator>,
303                max_length: CFIndex,
304            ) -> Option<NonNull<CFMutableAttributedString>>;
305        }
306        let ret = unsafe { CFAttributedStringCreateMutable(alloc, max_length) };
307        ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
308    }
309
310    /// Modifies the string for the attributed string, much like CFStringReplace().  It's an error for range to specify characters outside the bounds of aStr.
311    ///
312    /// (Note: This function is a convenience on CFAttributedStringGetMutableString(); however, until CFAttributedStringGetMutableString() is implemented, it remains the only way to edit the string of the attributed string.)
313    ///
314    /// # Safety
315    ///
316    /// - `a_str` might not allow `None`.
317    /// - `replacement` might not allow `None`.
318    #[doc(alias = "CFAttributedStringReplaceString")]
319    #[inline]
320    pub unsafe fn replace_string(
321        a_str: Option<&CFMutableAttributedString>,
322        range: CFRange,
323        replacement: Option<&CFString>,
324    ) {
325        extern "C-unwind" {
326            fn CFAttributedStringReplaceString(
327                a_str: Option<&CFMutableAttributedString>,
328                range: CFRange,
329                replacement: Option<&CFString>,
330            );
331        }
332        unsafe { CFAttributedStringReplaceString(a_str, range, replacement) }
333    }
334
335    /// Gets the string for the attributed string as a mutable string, allowing editing the character contents of the string as if it were an CFMutableString. Attributes corresponding to the edited range are appropriately modified. If, as a result of the edit, new characters are introduced into the string, they inherit the attributes of the first replaced character from range. If no existing characters are replaced by the edit, the new characters inherit the attributes of the character preceding range if it has any, otherwise of the character following range. If the initial string is empty, the attributes for the new characters are also empty.
336    ///
337    /// (Note: This function is not yet implemented and will return NULL except for toll-free bridged instances.)
338    #[doc(alias = "CFAttributedStringGetMutableString")]
339    #[inline]
340    pub fn mutable_string(
341        a_str: Option<&CFMutableAttributedString>,
342    ) -> Option<CFRetained<CFMutableString>> {
343        extern "C-unwind" {
344            fn CFAttributedStringGetMutableString(
345                a_str: Option<&CFMutableAttributedString>,
346            ) -> Option<NonNull<CFMutableString>>;
347        }
348        let ret = unsafe { CFAttributedStringGetMutableString(a_str) };
349        ret.map(|ret| unsafe { CFRetained::retain(ret) })
350    }
351
352    /// Sets the value of multiple attributes over the specified range, which should be valid. If clearOtherAttributes is false, existing attributes (which aren't being replaced) are left alone; otherwise they are cleared. The dictionary should be setup for "usual" CF type usage --- CFString keys, and arbitrary CFType values. Note that after this call, further mutations to the replacement dictionary argument by the caller will not affect the contents of the attributed string.
353    ///
354    /// # Safety
355    ///
356    /// - `a_str` might not allow `None`.
357    /// - `replacement` generics must be of the correct type.
358    /// - `replacement` might not allow `None`.
359    #[doc(alias = "CFAttributedStringSetAttributes")]
360    #[cfg(feature = "CFDictionary")]
361    #[inline]
362    pub unsafe fn set_attributes(
363        a_str: Option<&CFMutableAttributedString>,
364        range: CFRange,
365        replacement: Option<&CFDictionary>,
366        clear_other_attributes: bool,
367    ) {
368        extern "C-unwind" {
369            fn CFAttributedStringSetAttributes(
370                a_str: Option<&CFMutableAttributedString>,
371                range: CFRange,
372                replacement: Option<&CFDictionary>,
373                clear_other_attributes: Boolean,
374            );
375        }
376        unsafe {
377            CFAttributedStringSetAttributes(a_str, range, replacement, clear_other_attributes as _)
378        }
379    }
380
381    /// Sets the value of a single attribute over the specified range, which should be valid. value should not be NULL.
382    ///
383    /// # Safety
384    ///
385    /// - `a_str` might not allow `None`.
386    /// - `attr_name` might not allow `None`.
387    /// - `value` should be of the correct type.
388    /// - `value` might not allow `None`.
389    #[doc(alias = "CFAttributedStringSetAttribute")]
390    #[inline]
391    pub unsafe fn set_attribute(
392        a_str: Option<&CFMutableAttributedString>,
393        range: CFRange,
394        attr_name: Option<&CFString>,
395        value: Option<&CFType>,
396    ) {
397        extern "C-unwind" {
398            fn CFAttributedStringSetAttribute(
399                a_str: Option<&CFMutableAttributedString>,
400                range: CFRange,
401                attr_name: Option<&CFString>,
402                value: Option<&CFType>,
403            );
404        }
405        unsafe { CFAttributedStringSetAttribute(a_str, range, attr_name, value) }
406    }
407
408    /// Removes the value of a single attribute over the specified range, which should be valid. It's OK for the attribute not the exist over the specified range.
409    ///
410    /// # Safety
411    ///
412    /// - `a_str` might not allow `None`.
413    /// - `attr_name` might not allow `None`.
414    #[doc(alias = "CFAttributedStringRemoveAttribute")]
415    #[inline]
416    pub unsafe fn remove_attribute(
417        a_str: Option<&CFMutableAttributedString>,
418        range: CFRange,
419        attr_name: Option<&CFString>,
420    ) {
421        extern "C-unwind" {
422            fn CFAttributedStringRemoveAttribute(
423                a_str: Option<&CFMutableAttributedString>,
424                range: CFRange,
425                attr_name: Option<&CFString>,
426            );
427        }
428        unsafe { CFAttributedStringRemoveAttribute(a_str, range, attr_name) }
429    }
430
431    /// Replaces the attributed substring over the specified range with the attributed string specified in replacement. range should be valid. To delete a range of the attributed string, call CFAttributedStringReplaceString() with empty string and specified range.
432    ///
433    /// # Safety
434    ///
435    /// - `a_str` might not allow `None`.
436    /// - `replacement` might not allow `None`.
437    #[doc(alias = "CFAttributedStringReplaceAttributedString")]
438    #[inline]
439    pub unsafe fn replace_attributed_string(
440        a_str: Option<&CFMutableAttributedString>,
441        range: CFRange,
442        replacement: Option<&CFAttributedString>,
443    ) {
444        extern "C-unwind" {
445            fn CFAttributedStringReplaceAttributedString(
446                a_str: Option<&CFMutableAttributedString>,
447                range: CFRange,
448                replacement: Option<&CFAttributedString>,
449            );
450        }
451        unsafe { CFAttributedStringReplaceAttributedString(a_str, range, replacement) }
452    }
453
454    /// In cases where attributed string might do a bunch of work to assure self-consistency, CFAttributedStringBeginEditing/CFAttributedStringEndEditing allow disabling that to allow deferring and coalescing any work. It's a good idea to call these around a set of related mutation calls which don't require the string to be in consistent state in between. These calls can be nested.
455    #[doc(alias = "CFAttributedStringBeginEditing")]
456    #[inline]
457    pub fn begin_editing(a_str: Option<&CFMutableAttributedString>) {
458        extern "C-unwind" {
459            fn CFAttributedStringBeginEditing(a_str: Option<&CFMutableAttributedString>);
460        }
461        unsafe { CFAttributedStringBeginEditing(a_str) }
462    }
463
464    /// In cases where attributed string might do a bunch of work to assure self-consistency, CFAttributedStringBeginEditing/CFAttributedStringEndEditing allow disabling that to allow deferring and coalescing any work. It's a good idea to call these around a set of related mutation calls which don't require the string to be in consistent state in between. These calls can be nested.
465    #[doc(alias = "CFAttributedStringEndEditing")]
466    #[inline]
467    pub fn end_editing(a_str: Option<&CFMutableAttributedString>) {
468        extern "C-unwind" {
469            fn CFAttributedStringEndEditing(a_str: Option<&CFMutableAttributedString>);
470        }
471        unsafe { CFAttributedStringEndEditing(a_str) }
472    }
473}
474
475impl CFAttributedString {
476    /// Fills bidiLevels by applying the Unicode Bidi Algorithm (P, X, W, N, and I) to the characters in range. Returns true if the result is not uni-level LTR (in other words, needing further Bidi processing). baseDirection is NSWritingDirection (NSWritingDirectionNatural, NSWritingDirectionLeftToRight, and NSWritingDirectionRightToLeft).  Understands NSWritingDirectionAttributeName values.
477    ///
478    /// # Safety
479    ///
480    /// - `bidi_levels` must be a valid pointer.
481    /// - `base_directions` must be a valid pointer.
482    #[doc(alias = "CFAttributedStringGetBidiLevelsAndResolvedDirections")]
483    #[inline]
484    pub unsafe fn bidi_levels_and_resolved_directions(
485        &self,
486        range: CFRange,
487        base_direction: i8,
488        bidi_levels: *mut u8,
489        base_directions: *mut u8,
490    ) -> bool {
491        extern "C-unwind" {
492            fn CFAttributedStringGetBidiLevelsAndResolvedDirections(
493                attributed_string: &CFAttributedString,
494                range: CFRange,
495                base_direction: i8,
496                bidi_levels: *mut u8,
497                base_directions: *mut u8,
498            ) -> bool;
499        }
500        unsafe {
501            CFAttributedStringGetBidiLevelsAndResolvedDirections(
502                self,
503                range,
504                base_direction,
505                bidi_levels,
506                base_directions,
507            )
508        }
509    }
510
511    /// If baseDirection is not NSWritingDirectionNatural, result comes from CFAttributedStringGetBidiLevelsAndResolvedDirections; otherwise, it fills bidiLevels by applying a statistical approach (a paragraph is RTL if 40% or more of its words are RTL) to the characters in range. Returns true if the result is not uni-level LTR (in other words, needing further Bidi processing). baseDirection is NSWritingDirection (NSWritingDirectionNatural, NSWritingDirectionLeftToRight, and NSWritingDirectionRightToLeft).  Understands NSWritingDirectionAttributeName values.
512    ///
513    /// # Safety
514    ///
515    /// - `bidi_levels` must be a valid pointer.
516    /// - `base_directions` must be a valid pointer.
517    #[doc(alias = "CFAttributedStringGetStatisticalWritingDirections")]
518    #[inline]
519    pub unsafe fn statistical_writing_directions(
520        &self,
521        range: CFRange,
522        base_direction: i8,
523        bidi_levels: *mut u8,
524        base_directions: *mut u8,
525    ) -> bool {
526        extern "C-unwind" {
527            fn CFAttributedStringGetStatisticalWritingDirections(
528                attributed_string: &CFAttributedString,
529                range: CFRange,
530                base_direction: i8,
531                bidi_levels: *mut u8,
532                base_directions: *mut u8,
533            ) -> bool;
534        }
535        unsafe {
536            CFAttributedStringGetStatisticalWritingDirections(
537                self,
538                range,
539                base_direction,
540                bidi_levels,
541                base_directions,
542            )
543        }
544    }
545}
546
547#[cfg(feature = "CFDictionary")]
548#[deprecated = "renamed to `CFAttributedString::new`"]
549#[inline]
550pub unsafe extern "C-unwind" fn CFAttributedStringCreate(
551    alloc: Option<&CFAllocator>,
552    str: Option<&CFString>,
553    attributes: Option<&CFDictionary>,
554) -> Option<CFRetained<CFAttributedString>> {
555    extern "C-unwind" {
556        fn CFAttributedStringCreate(
557            alloc: Option<&CFAllocator>,
558            str: Option<&CFString>,
559            attributes: Option<&CFDictionary>,
560        ) -> Option<NonNull<CFAttributedString>>;
561    }
562    let ret = unsafe { CFAttributedStringCreate(alloc, str, attributes) };
563    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
564}
565
566#[deprecated = "renamed to `CFAttributedString::with_substring`"]
567#[inline]
568pub unsafe extern "C-unwind" fn CFAttributedStringCreateWithSubstring(
569    alloc: Option<&CFAllocator>,
570    a_str: Option<&CFAttributedString>,
571    range: CFRange,
572) -> Option<CFRetained<CFAttributedString>> {
573    extern "C-unwind" {
574        fn CFAttributedStringCreateWithSubstring(
575            alloc: Option<&CFAllocator>,
576            a_str: Option<&CFAttributedString>,
577            range: CFRange,
578        ) -> Option<NonNull<CFAttributedString>>;
579    }
580    let ret = unsafe { CFAttributedStringCreateWithSubstring(alloc, a_str, range) };
581    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
582}
583
584#[deprecated = "renamed to `CFAttributedString::new_copy`"]
585#[inline]
586pub extern "C-unwind" fn CFAttributedStringCreateCopy(
587    alloc: Option<&CFAllocator>,
588    a_str: Option<&CFAttributedString>,
589) -> Option<CFRetained<CFAttributedString>> {
590    extern "C-unwind" {
591        fn CFAttributedStringCreateCopy(
592            alloc: Option<&CFAllocator>,
593            a_str: Option<&CFAttributedString>,
594        ) -> Option<NonNull<CFAttributedString>>;
595    }
596    let ret = unsafe { CFAttributedStringCreateCopy(alloc, a_str) };
597    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
598}
599
600#[deprecated = "renamed to `CFAttributedString::string`"]
601#[inline]
602pub extern "C-unwind" fn CFAttributedStringGetString(
603    a_str: &CFAttributedString,
604) -> Option<CFRetained<CFString>> {
605    extern "C-unwind" {
606        fn CFAttributedStringGetString(a_str: &CFAttributedString) -> Option<NonNull<CFString>>;
607    }
608    let ret = unsafe { CFAttributedStringGetString(a_str) };
609    ret.map(|ret| unsafe { CFRetained::retain(ret) })
610}
611
612#[deprecated = "renamed to `CFAttributedString::length`"]
613#[inline]
614pub extern "C-unwind" fn CFAttributedStringGetLength(a_str: &CFAttributedString) -> CFIndex {
615    extern "C-unwind" {
616        fn CFAttributedStringGetLength(a_str: &CFAttributedString) -> CFIndex;
617    }
618    unsafe { CFAttributedStringGetLength(a_str) }
619}
620
621#[cfg(feature = "CFDictionary")]
622#[deprecated = "renamed to `CFAttributedString::attributes`"]
623#[inline]
624pub unsafe extern "C-unwind" fn CFAttributedStringGetAttributes(
625    a_str: &CFAttributedString,
626    loc: CFIndex,
627    effective_range: *mut CFRange,
628) -> Option<CFRetained<CFDictionary>> {
629    extern "C-unwind" {
630        fn CFAttributedStringGetAttributes(
631            a_str: &CFAttributedString,
632            loc: CFIndex,
633            effective_range: *mut CFRange,
634        ) -> Option<NonNull<CFDictionary>>;
635    }
636    let ret = unsafe { CFAttributedStringGetAttributes(a_str, loc, effective_range) };
637    ret.map(|ret| unsafe { CFRetained::retain(ret) })
638}
639
640#[deprecated = "renamed to `CFAttributedString::attribute`"]
641#[inline]
642pub unsafe extern "C-unwind" fn CFAttributedStringGetAttribute(
643    a_str: &CFAttributedString,
644    loc: CFIndex,
645    attr_name: Option<&CFString>,
646    effective_range: *mut CFRange,
647) -> Option<CFRetained<CFType>> {
648    extern "C-unwind" {
649        fn CFAttributedStringGetAttribute(
650            a_str: &CFAttributedString,
651            loc: CFIndex,
652            attr_name: Option<&CFString>,
653            effective_range: *mut CFRange,
654        ) -> Option<NonNull<CFType>>;
655    }
656    let ret = unsafe { CFAttributedStringGetAttribute(a_str, loc, attr_name, effective_range) };
657    ret.map(|ret| unsafe { CFRetained::retain(ret) })
658}
659
660#[cfg(feature = "CFDictionary")]
661#[deprecated = "renamed to `CFAttributedString::attributes_and_longest_effective_range`"]
662#[inline]
663pub unsafe extern "C-unwind" fn CFAttributedStringGetAttributesAndLongestEffectiveRange(
664    a_str: &CFAttributedString,
665    loc: CFIndex,
666    in_range: CFRange,
667    longest_effective_range: *mut CFRange,
668) -> Option<CFRetained<CFDictionary>> {
669    extern "C-unwind" {
670        fn CFAttributedStringGetAttributesAndLongestEffectiveRange(
671            a_str: &CFAttributedString,
672            loc: CFIndex,
673            in_range: CFRange,
674            longest_effective_range: *mut CFRange,
675        ) -> Option<NonNull<CFDictionary>>;
676    }
677    let ret = unsafe {
678        CFAttributedStringGetAttributesAndLongestEffectiveRange(
679            a_str,
680            loc,
681            in_range,
682            longest_effective_range,
683        )
684    };
685    ret.map(|ret| unsafe { CFRetained::retain(ret) })
686}
687
688#[deprecated = "renamed to `CFAttributedString::attribute_and_longest_effective_range`"]
689#[inline]
690pub unsafe extern "C-unwind" fn CFAttributedStringGetAttributeAndLongestEffectiveRange(
691    a_str: &CFAttributedString,
692    loc: CFIndex,
693    attr_name: Option<&CFString>,
694    in_range: CFRange,
695    longest_effective_range: *mut CFRange,
696) -> Option<CFRetained<CFType>> {
697    extern "C-unwind" {
698        fn CFAttributedStringGetAttributeAndLongestEffectiveRange(
699            a_str: &CFAttributedString,
700            loc: CFIndex,
701            attr_name: Option<&CFString>,
702            in_range: CFRange,
703            longest_effective_range: *mut CFRange,
704        ) -> Option<NonNull<CFType>>;
705    }
706    let ret = unsafe {
707        CFAttributedStringGetAttributeAndLongestEffectiveRange(
708            a_str,
709            loc,
710            attr_name,
711            in_range,
712            longest_effective_range,
713        )
714    };
715    ret.map(|ret| unsafe { CFRetained::retain(ret) })
716}
717
718#[deprecated = "renamed to `CFMutableAttributedString::new_copy`"]
719#[inline]
720pub extern "C-unwind" fn CFAttributedStringCreateMutableCopy(
721    alloc: Option<&CFAllocator>,
722    max_length: CFIndex,
723    a_str: Option<&CFAttributedString>,
724) -> Option<CFRetained<CFMutableAttributedString>> {
725    extern "C-unwind" {
726        fn CFAttributedStringCreateMutableCopy(
727            alloc: Option<&CFAllocator>,
728            max_length: CFIndex,
729            a_str: Option<&CFAttributedString>,
730        ) -> Option<NonNull<CFMutableAttributedString>>;
731    }
732    let ret = unsafe { CFAttributedStringCreateMutableCopy(alloc, max_length, a_str) };
733    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
734}
735
736#[deprecated = "renamed to `CFMutableAttributedString::new`"]
737#[inline]
738pub extern "C-unwind" fn CFAttributedStringCreateMutable(
739    alloc: Option<&CFAllocator>,
740    max_length: CFIndex,
741) -> Option<CFRetained<CFMutableAttributedString>> {
742    extern "C-unwind" {
743        fn CFAttributedStringCreateMutable(
744            alloc: Option<&CFAllocator>,
745            max_length: CFIndex,
746        ) -> Option<NonNull<CFMutableAttributedString>>;
747    }
748    let ret = unsafe { CFAttributedStringCreateMutable(alloc, max_length) };
749    ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
750}
751
752extern "C-unwind" {
753    #[deprecated = "renamed to `CFMutableAttributedString::replace_string`"]
754    pub fn CFAttributedStringReplaceString(
755        a_str: Option<&CFMutableAttributedString>,
756        range: CFRange,
757        replacement: Option<&CFString>,
758    );
759}
760
761#[deprecated = "renamed to `CFMutableAttributedString::mutable_string`"]
762#[inline]
763pub extern "C-unwind" fn CFAttributedStringGetMutableString(
764    a_str: Option<&CFMutableAttributedString>,
765) -> Option<CFRetained<CFMutableString>> {
766    extern "C-unwind" {
767        fn CFAttributedStringGetMutableString(
768            a_str: Option<&CFMutableAttributedString>,
769        ) -> Option<NonNull<CFMutableString>>;
770    }
771    let ret = unsafe { CFAttributedStringGetMutableString(a_str) };
772    ret.map(|ret| unsafe { CFRetained::retain(ret) })
773}
774
775#[cfg(feature = "CFDictionary")]
776#[deprecated = "renamed to `CFMutableAttributedString::set_attributes`"]
777#[inline]
778pub unsafe extern "C-unwind" fn CFAttributedStringSetAttributes(
779    a_str: Option<&CFMutableAttributedString>,
780    range: CFRange,
781    replacement: Option<&CFDictionary>,
782    clear_other_attributes: bool,
783) {
784    extern "C-unwind" {
785        fn CFAttributedStringSetAttributes(
786            a_str: Option<&CFMutableAttributedString>,
787            range: CFRange,
788            replacement: Option<&CFDictionary>,
789            clear_other_attributes: Boolean,
790        );
791    }
792    unsafe {
793        CFAttributedStringSetAttributes(a_str, range, replacement, clear_other_attributes as _)
794    }
795}
796
797extern "C-unwind" {
798    #[deprecated = "renamed to `CFMutableAttributedString::set_attribute`"]
799    pub fn CFAttributedStringSetAttribute(
800        a_str: Option<&CFMutableAttributedString>,
801        range: CFRange,
802        attr_name: Option<&CFString>,
803        value: Option<&CFType>,
804    );
805}
806
807extern "C-unwind" {
808    #[deprecated = "renamed to `CFMutableAttributedString::remove_attribute`"]
809    pub fn CFAttributedStringRemoveAttribute(
810        a_str: Option<&CFMutableAttributedString>,
811        range: CFRange,
812        attr_name: Option<&CFString>,
813    );
814}
815
816extern "C-unwind" {
817    #[deprecated = "renamed to `CFMutableAttributedString::replace_attributed_string`"]
818    pub fn CFAttributedStringReplaceAttributedString(
819        a_str: Option<&CFMutableAttributedString>,
820        range: CFRange,
821        replacement: Option<&CFAttributedString>,
822    );
823}
824
825#[deprecated = "renamed to `CFMutableAttributedString::begin_editing`"]
826#[inline]
827pub extern "C-unwind" fn CFAttributedStringBeginEditing(a_str: Option<&CFMutableAttributedString>) {
828    extern "C-unwind" {
829        fn CFAttributedStringBeginEditing(a_str: Option<&CFMutableAttributedString>);
830    }
831    unsafe { CFAttributedStringBeginEditing(a_str) }
832}
833
834#[deprecated = "renamed to `CFMutableAttributedString::end_editing`"]
835#[inline]
836pub extern "C-unwind" fn CFAttributedStringEndEditing(a_str: Option<&CFMutableAttributedString>) {
837    extern "C-unwind" {
838        fn CFAttributedStringEndEditing(a_str: Option<&CFMutableAttributedString>);
839    }
840    unsafe { CFAttributedStringEndEditing(a_str) }
841}
842
843extern "C-unwind" {
844    #[deprecated = "renamed to `CFAttributedString::bidi_levels_and_resolved_directions`"]
845    pub fn CFAttributedStringGetBidiLevelsAndResolvedDirections(
846        attributed_string: &CFAttributedString,
847        range: CFRange,
848        base_direction: i8,
849        bidi_levels: *mut u8,
850        base_directions: *mut u8,
851    ) -> bool;
852}
853
854extern "C-unwind" {
855    #[deprecated = "renamed to `CFAttributedString::statistical_writing_directions`"]
856    pub fn CFAttributedStringGetStatisticalWritingDirections(
857        attributed_string: &CFAttributedString,
858        range: CFRange,
859        base_direction: i8,
860        bidi_levels: *mut u8,
861        base_directions: *mut u8,
862    ) -> bool;
863}