objc2_core_foundation/generated/
CFAttributedString.rs1use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7
8use crate::*;
9
10#[repr(C)]
12pub struct CFAttributedString {
13 inner: [u8; 0],
14 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
15}
16
17cf_type!(
18 #[encoding_name = "__CFAttributedString"]
19 unsafe impl CFAttributedString {}
20);
21
22#[repr(C)]
24pub struct CFMutableAttributedString {
25 inner: [u8; 0],
26 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
27}
28
29cf_type!(
30 #[encoding_name = "__CFAttributedString"]
31 unsafe impl CFMutableAttributedString: CFAttributedString {}
32);
33
34#[cfg(feature = "CFBase")]
35unsafe impl ConcreteType for CFAttributedString {
36 #[doc(alias = "CFAttributedStringGetTypeID")]
38 #[inline]
39 fn type_id() -> CFTypeID {
40 extern "C-unwind" {
41 fn CFAttributedStringGetTypeID() -> CFTypeID;
42 }
43 unsafe { CFAttributedStringGetTypeID() }
44 }
45}
46
47#[cfg(all(feature = "CFBase", feature = "CFDictionary"))]
49#[inline]
50pub unsafe extern "C-unwind" fn CFAttributedStringCreate(
51 alloc: Option<&CFAllocator>,
52 str: Option<&CFString>,
53 attributes: Option<&CFDictionary>,
54) -> Option<CFRetained<CFAttributedString>> {
55 extern "C-unwind" {
56 fn CFAttributedStringCreate(
57 alloc: Option<&CFAllocator>,
58 str: Option<&CFString>,
59 attributes: Option<&CFDictionary>,
60 ) -> Option<NonNull<CFAttributedString>>;
61 }
62 let ret = unsafe { CFAttributedStringCreate(alloc, str, attributes) };
63 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
64}
65
66#[cfg(feature = "CFBase")]
68#[inline]
69pub unsafe extern "C-unwind" fn CFAttributedStringCreateWithSubstring(
70 alloc: Option<&CFAllocator>,
71 a_str: Option<&CFAttributedString>,
72 range: CFRange,
73) -> Option<CFRetained<CFAttributedString>> {
74 extern "C-unwind" {
75 fn CFAttributedStringCreateWithSubstring(
76 alloc: Option<&CFAllocator>,
77 a_str: Option<&CFAttributedString>,
78 range: CFRange,
79 ) -> Option<NonNull<CFAttributedString>>;
80 }
81 let ret = unsafe { CFAttributedStringCreateWithSubstring(alloc, a_str, range) };
82 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
83}
84
85#[cfg(feature = "CFBase")]
87#[inline]
88pub unsafe extern "C-unwind" fn CFAttributedStringCreateCopy(
89 alloc: Option<&CFAllocator>,
90 a_str: Option<&CFAttributedString>,
91) -> Option<CFRetained<CFAttributedString>> {
92 extern "C-unwind" {
93 fn CFAttributedStringCreateCopy(
94 alloc: Option<&CFAllocator>,
95 a_str: Option<&CFAttributedString>,
96 ) -> Option<NonNull<CFAttributedString>>;
97 }
98 let ret = unsafe { CFAttributedStringCreateCopy(alloc, a_str) };
99 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
100}
101
102#[cfg(feature = "CFBase")]
104#[inline]
105pub unsafe extern "C-unwind" fn CFAttributedStringGetString(
106 a_str: &CFAttributedString,
107) -> Option<CFRetained<CFString>> {
108 extern "C-unwind" {
109 fn CFAttributedStringGetString(a_str: &CFAttributedString) -> Option<NonNull<CFString>>;
110 }
111 let ret = unsafe { CFAttributedStringGetString(a_str) };
112 ret.map(|ret| unsafe { CFRetained::retain(ret) })
113}
114
115extern "C-unwind" {
116 #[cfg(feature = "CFBase")]
118 pub fn CFAttributedStringGetLength(a_str: &CFAttributedString) -> CFIndex;
119}
120
121#[cfg(all(feature = "CFBase", feature = "CFDictionary"))]
125#[inline]
126pub unsafe extern "C-unwind" fn CFAttributedStringGetAttributes(
127 a_str: &CFAttributedString,
128 loc: CFIndex,
129 effective_range: *mut CFRange,
130) -> Option<CFRetained<CFDictionary>> {
131 extern "C-unwind" {
132 fn CFAttributedStringGetAttributes(
133 a_str: &CFAttributedString,
134 loc: CFIndex,
135 effective_range: *mut CFRange,
136 ) -> Option<NonNull<CFDictionary>>;
137 }
138 let ret = unsafe { CFAttributedStringGetAttributes(a_str, loc, effective_range) };
139 ret.map(|ret| unsafe { CFRetained::retain(ret) })
140}
141
142#[cfg(feature = "CFBase")]
144#[inline]
145pub unsafe extern "C-unwind" fn CFAttributedStringGetAttribute(
146 a_str: &CFAttributedString,
147 loc: CFIndex,
148 attr_name: Option<&CFString>,
149 effective_range: *mut CFRange,
150) -> Option<CFRetained<CFType>> {
151 extern "C-unwind" {
152 fn CFAttributedStringGetAttribute(
153 a_str: &CFAttributedString,
154 loc: CFIndex,
155 attr_name: Option<&CFString>,
156 effective_range: *mut CFRange,
157 ) -> Option<NonNull<CFType>>;
158 }
159 let ret = unsafe { CFAttributedStringGetAttribute(a_str, loc, attr_name, effective_range) };
160 ret.map(|ret| unsafe { CFRetained::retain(ret) })
161}
162
163#[cfg(all(feature = "CFBase", feature = "CFDictionary"))]
165#[inline]
166pub unsafe extern "C-unwind" fn CFAttributedStringGetAttributesAndLongestEffectiveRange(
167 a_str: &CFAttributedString,
168 loc: CFIndex,
169 in_range: CFRange,
170 longest_effective_range: *mut CFRange,
171) -> Option<CFRetained<CFDictionary>> {
172 extern "C-unwind" {
173 fn CFAttributedStringGetAttributesAndLongestEffectiveRange(
174 a_str: &CFAttributedString,
175 loc: CFIndex,
176 in_range: CFRange,
177 longest_effective_range: *mut CFRange,
178 ) -> Option<NonNull<CFDictionary>>;
179 }
180 let ret = unsafe {
181 CFAttributedStringGetAttributesAndLongestEffectiveRange(
182 a_str,
183 loc,
184 in_range,
185 longest_effective_range,
186 )
187 };
188 ret.map(|ret| unsafe { CFRetained::retain(ret) })
189}
190
191#[cfg(feature = "CFBase")]
193#[inline]
194pub unsafe extern "C-unwind" fn CFAttributedStringGetAttributeAndLongestEffectiveRange(
195 a_str: &CFAttributedString,
196 loc: CFIndex,
197 attr_name: Option<&CFString>,
198 in_range: CFRange,
199 longest_effective_range: *mut CFRange,
200) -> Option<CFRetained<CFType>> {
201 extern "C-unwind" {
202 fn CFAttributedStringGetAttributeAndLongestEffectiveRange(
203 a_str: &CFAttributedString,
204 loc: CFIndex,
205 attr_name: Option<&CFString>,
206 in_range: CFRange,
207 longest_effective_range: *mut CFRange,
208 ) -> Option<NonNull<CFType>>;
209 }
210 let ret = unsafe {
211 CFAttributedStringGetAttributeAndLongestEffectiveRange(
212 a_str,
213 loc,
214 attr_name,
215 in_range,
216 longest_effective_range,
217 )
218 };
219 ret.map(|ret| unsafe { CFRetained::retain(ret) })
220}
221
222#[cfg(feature = "CFBase")]
224#[inline]
225pub unsafe extern "C-unwind" fn CFAttributedStringCreateMutableCopy(
226 alloc: Option<&CFAllocator>,
227 max_length: CFIndex,
228 a_str: Option<&CFAttributedString>,
229) -> Option<CFRetained<CFMutableAttributedString>> {
230 extern "C-unwind" {
231 fn CFAttributedStringCreateMutableCopy(
232 alloc: Option<&CFAllocator>,
233 max_length: CFIndex,
234 a_str: Option<&CFAttributedString>,
235 ) -> Option<NonNull<CFMutableAttributedString>>;
236 }
237 let ret = unsafe { CFAttributedStringCreateMutableCopy(alloc, max_length, a_str) };
238 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
239}
240
241#[cfg(feature = "CFBase")]
243#[inline]
244pub unsafe extern "C-unwind" fn CFAttributedStringCreateMutable(
245 alloc: Option<&CFAllocator>,
246 max_length: CFIndex,
247) -> Option<CFRetained<CFMutableAttributedString>> {
248 extern "C-unwind" {
249 fn CFAttributedStringCreateMutable(
250 alloc: Option<&CFAllocator>,
251 max_length: CFIndex,
252 ) -> Option<NonNull<CFMutableAttributedString>>;
253 }
254 let ret = unsafe { CFAttributedStringCreateMutable(alloc, max_length) };
255 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
256}
257
258extern "C-unwind" {
259 #[cfg(feature = "CFBase")]
263 pub fn CFAttributedStringReplaceString(
264 a_str: Option<&CFMutableAttributedString>,
265 range: CFRange,
266 replacement: Option<&CFString>,
267 );
268}
269
270#[cfg(feature = "CFBase")]
274#[inline]
275pub unsafe extern "C-unwind" fn CFAttributedStringGetMutableString(
276 a_str: Option<&CFMutableAttributedString>,
277) -> Option<CFRetained<CFMutableString>> {
278 extern "C-unwind" {
279 fn CFAttributedStringGetMutableString(
280 a_str: Option<&CFMutableAttributedString>,
281 ) -> Option<NonNull<CFMutableString>>;
282 }
283 let ret = unsafe { CFAttributedStringGetMutableString(a_str) };
284 ret.map(|ret| unsafe { CFRetained::retain(ret) })
285}
286
287#[cfg(all(feature = "CFBase", feature = "CFDictionary"))]
289#[inline]
290pub unsafe extern "C-unwind" fn CFAttributedStringSetAttributes(
291 a_str: Option<&CFMutableAttributedString>,
292 range: CFRange,
293 replacement: Option<&CFDictionary>,
294 clear_other_attributes: bool,
295) {
296 extern "C-unwind" {
297 fn CFAttributedStringSetAttributes(
298 a_str: Option<&CFMutableAttributedString>,
299 range: CFRange,
300 replacement: Option<&CFDictionary>,
301 clear_other_attributes: Boolean,
302 );
303 }
304 unsafe {
305 CFAttributedStringSetAttributes(a_str, range, replacement, clear_other_attributes as _)
306 }
307}
308
309extern "C-unwind" {
310 #[cfg(feature = "CFBase")]
312 pub fn CFAttributedStringSetAttribute(
313 a_str: Option<&CFMutableAttributedString>,
314 range: CFRange,
315 attr_name: Option<&CFString>,
316 value: Option<&CFType>,
317 );
318}
319
320extern "C-unwind" {
321 #[cfg(feature = "CFBase")]
323 pub fn CFAttributedStringRemoveAttribute(
324 a_str: Option<&CFMutableAttributedString>,
325 range: CFRange,
326 attr_name: Option<&CFString>,
327 );
328}
329
330extern "C-unwind" {
331 #[cfg(feature = "CFBase")]
333 pub fn CFAttributedStringReplaceAttributedString(
334 a_str: Option<&CFMutableAttributedString>,
335 range: CFRange,
336 replacement: Option<&CFAttributedString>,
337 );
338}
339
340extern "C-unwind" {
341 pub fn CFAttributedStringBeginEditing(a_str: Option<&CFMutableAttributedString>);
343}
344
345extern "C-unwind" {
346 pub fn CFAttributedStringEndEditing(a_str: Option<&CFMutableAttributedString>);
348}
349
350extern "C-unwind" {
351 #[cfg(feature = "CFBase")]
353 pub fn CFAttributedStringGetBidiLevelsAndResolvedDirections(
354 attributed_string: &CFAttributedString,
355 range: CFRange,
356 base_direction: i8,
357 bidi_levels: *mut u8,
358 base_directions: *mut u8,
359 ) -> bool;
360}