1use 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#[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#[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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 #[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}