objc2_core_text/generated/
CTRubyAnnotation.rs1use core::cell::UnsafeCell;
4use core::marker::{PhantomData, PhantomPinned};
5use core::ptr::NonNull;
6#[cfg(feature = "objc2")]
7use objc2::__framework_prelude::*;
8use objc2_core_foundation::*;
9
10use crate::*;
11
12#[doc(alias = "CTRubyAnnotationRef")]
14#[repr(C)]
15pub struct CTRubyAnnotation {
16 inner: [u8; 0],
17 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
18}
19
20cf_type!(
21 unsafe impl CTRubyAnnotation {}
22);
23#[cfg(feature = "objc2")]
24cf_objc2_type!(
25 unsafe impl RefEncode<"__CTRubyAnnotation"> for CTRubyAnnotation {}
26);
27
28unsafe impl ConcreteType for CTRubyAnnotation {
29 #[doc(alias = "CTRubyAnnotationGetTypeID")]
31 #[inline]
32 fn type_id() -> CFTypeID {
33 extern "C-unwind" {
34 fn CTRubyAnnotationGetTypeID() -> CFTypeID;
35 }
36 unsafe { CTRubyAnnotationGetTypeID() }
37 }
38}
39
40#[repr(transparent)]
66#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
67pub struct CTRubyAlignment(pub u8);
68impl CTRubyAlignment {
69 #[doc(alias = "kCTRubyAlignmentInvalid")]
70 pub const Invalid: Self = Self(255);
71 #[doc(alias = "kCTRubyAlignmentAuto")]
72 pub const Auto: Self = Self(0);
73 #[doc(alias = "kCTRubyAlignmentStart")]
74 pub const Start: Self = Self(1);
75 #[doc(alias = "kCTRubyAlignmentCenter")]
76 pub const Center: Self = Self(2);
77 #[doc(alias = "kCTRubyAlignmentEnd")]
78 pub const End: Self = Self(3);
79 #[doc(alias = "kCTRubyAlignmentDistributeLetter")]
80 pub const DistributeLetter: Self = Self(4);
81 #[doc(alias = "kCTRubyAlignmentDistributeSpace")]
82 pub const DistributeSpace: Self = Self(5);
83 #[doc(alias = "kCTRubyAlignmentLineEdge")]
84 pub const LineEdge: Self = Self(6);
85}
86
87#[cfg(feature = "objc2")]
88unsafe impl Encode for CTRubyAlignment {
89 const ENCODING: Encoding = u8::ENCODING;
90}
91
92#[cfg(feature = "objc2")]
93unsafe impl RefEncode for CTRubyAlignment {
94 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
95}
96
97#[repr(transparent)]
114#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
115pub struct CTRubyOverhang(pub u8);
116impl CTRubyOverhang {
117 #[doc(alias = "kCTRubyOverhangInvalid")]
118 pub const Invalid: Self = Self(255);
119 #[doc(alias = "kCTRubyOverhangAuto")]
120 pub const Auto: Self = Self(0);
121 #[doc(alias = "kCTRubyOverhangStart")]
122 pub const Start: Self = Self(1);
123 #[doc(alias = "kCTRubyOverhangEnd")]
124 pub const End: Self = Self(2);
125 #[doc(alias = "kCTRubyOverhangNone")]
126 pub const None: Self = Self(3);
127}
128
129#[cfg(feature = "objc2")]
130unsafe impl Encode for CTRubyOverhang {
131 const ENCODING: Encoding = u8::ENCODING;
132}
133
134#[cfg(feature = "objc2")]
135unsafe impl RefEncode for CTRubyOverhang {
136 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
137}
138
139#[repr(transparent)]
156#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
157pub struct CTRubyPosition(pub u8);
158impl CTRubyPosition {
159 #[doc(alias = "kCTRubyPositionBefore")]
160 pub const Before: Self = Self(0);
161 #[doc(alias = "kCTRubyPositionAfter")]
162 pub const After: Self = Self(1);
163 #[doc(alias = "kCTRubyPositionInterCharacter")]
164 pub const InterCharacter: Self = Self(2);
165 #[doc(alias = "kCTRubyPositionInline")]
166 pub const Inline: Self = Self(3);
167 #[doc(alias = "kCTRubyPositionCount")]
168 pub const Count: Self = Self(4);
169}
170
171#[cfg(feature = "objc2")]
172unsafe impl Encode for CTRubyPosition {
173 const ENCODING: Encoding = u8::ENCODING;
174}
175
176#[cfg(feature = "objc2")]
177unsafe impl RefEncode for CTRubyPosition {
178 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
179}
180
181extern "C" {
182 pub static kCTRubyAnnotationSizeFactorAttributeName: &'static CFString;
189}
190
191extern "C" {
192 pub static kCTRubyAnnotationScaleToFitAttributeName: &'static CFString;
202}
203
204impl CTRubyAnnotation {
205 #[doc(alias = "CTRubyAnnotationCreateWithAttributes")]
236 #[inline]
237 pub unsafe fn with_attributes(
238 alignment: CTRubyAlignment,
239 overhang: CTRubyOverhang,
240 position: CTRubyPosition,
241 string: &CFString,
242 attributes: &CFDictionary,
243 ) -> CFRetained<CTRubyAnnotation> {
244 extern "C-unwind" {
245 fn CTRubyAnnotationCreateWithAttributes(
246 alignment: CTRubyAlignment,
247 overhang: CTRubyOverhang,
248 position: CTRubyPosition,
249 string: &CFString,
250 attributes: &CFDictionary,
251 ) -> Option<NonNull<CTRubyAnnotation>>;
252 }
253 let ret = unsafe {
254 CTRubyAnnotationCreateWithAttributes(alignment, overhang, position, string, attributes)
255 };
256 let ret =
257 ret.expect("function was marked as returning non-null, but actually returned NULL");
258 unsafe { CFRetained::from_raw(ret) }
259 }
260
261 #[doc(alias = "CTRubyAnnotationCreateCopy")]
272 #[inline]
273 pub unsafe fn copy(&self) -> CFRetained<CTRubyAnnotation> {
274 extern "C-unwind" {
275 fn CTRubyAnnotationCreateCopy(
276 ruby_annotation: &CTRubyAnnotation,
277 ) -> Option<NonNull<CTRubyAnnotation>>;
278 }
279 let ret = unsafe { CTRubyAnnotationCreateCopy(self) };
280 let ret =
281 ret.expect("function was marked as returning non-null, but actually returned NULL");
282 unsafe { CFRetained::from_raw(ret) }
283 }
284
285 #[doc(alias = "CTRubyAnnotationGetAlignment")]
294 #[inline]
295 pub unsafe fn alignment(&self) -> CTRubyAlignment {
296 extern "C-unwind" {
297 fn CTRubyAnnotationGetAlignment(ruby_annotation: &CTRubyAnnotation) -> CTRubyAlignment;
298 }
299 unsafe { CTRubyAnnotationGetAlignment(self) }
300 }
301
302 #[doc(alias = "CTRubyAnnotationGetOverhang")]
311 #[inline]
312 pub unsafe fn overhang(&self) -> CTRubyOverhang {
313 extern "C-unwind" {
314 fn CTRubyAnnotationGetOverhang(ruby_annotation: &CTRubyAnnotation) -> CTRubyOverhang;
315 }
316 unsafe { CTRubyAnnotationGetOverhang(self) }
317 }
318
319 #[doc(alias = "CTRubyAnnotationGetSizeFactor")]
328 #[inline]
329 pub unsafe fn size_factor(&self) -> CGFloat {
330 extern "C-unwind" {
331 fn CTRubyAnnotationGetSizeFactor(ruby_annotation: &CTRubyAnnotation) -> CGFloat;
332 }
333 unsafe { CTRubyAnnotationGetSizeFactor(self) }
334 }
335
336 #[doc(alias = "CTRubyAnnotationGetTextForPosition")]
348 #[inline]
349 pub unsafe fn text_for_position(
350 &self,
351 position: CTRubyPosition,
352 ) -> Option<CFRetained<CFString>> {
353 extern "C-unwind" {
354 fn CTRubyAnnotationGetTextForPosition(
355 ruby_annotation: &CTRubyAnnotation,
356 position: CTRubyPosition,
357 ) -> Option<NonNull<CFString>>;
358 }
359 let ret = unsafe { CTRubyAnnotationGetTextForPosition(self, position) };
360 ret.map(|ret| unsafe { CFRetained::retain(ret) })
361 }
362}
363
364#[deprecated = "renamed to `CTRubyAnnotation::with_attributes`"]
365#[inline]
366pub unsafe extern "C-unwind" fn CTRubyAnnotationCreateWithAttributes(
367 alignment: CTRubyAlignment,
368 overhang: CTRubyOverhang,
369 position: CTRubyPosition,
370 string: &CFString,
371 attributes: &CFDictionary,
372) -> CFRetained<CTRubyAnnotation> {
373 extern "C-unwind" {
374 fn CTRubyAnnotationCreateWithAttributes(
375 alignment: CTRubyAlignment,
376 overhang: CTRubyOverhang,
377 position: CTRubyPosition,
378 string: &CFString,
379 attributes: &CFDictionary,
380 ) -> Option<NonNull<CTRubyAnnotation>>;
381 }
382 let ret = unsafe {
383 CTRubyAnnotationCreateWithAttributes(alignment, overhang, position, string, attributes)
384 };
385 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
386 unsafe { CFRetained::from_raw(ret) }
387}
388
389#[deprecated = "renamed to `CTRubyAnnotation::copy`"]
390#[inline]
391pub unsafe extern "C-unwind" fn CTRubyAnnotationCreateCopy(
392 ruby_annotation: &CTRubyAnnotation,
393) -> CFRetained<CTRubyAnnotation> {
394 extern "C-unwind" {
395 fn CTRubyAnnotationCreateCopy(
396 ruby_annotation: &CTRubyAnnotation,
397 ) -> Option<NonNull<CTRubyAnnotation>>;
398 }
399 let ret = unsafe { CTRubyAnnotationCreateCopy(ruby_annotation) };
400 let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
401 unsafe { CFRetained::from_raw(ret) }
402}
403
404extern "C-unwind" {
405 #[deprecated = "renamed to `CTRubyAnnotation::alignment`"]
406 pub fn CTRubyAnnotationGetAlignment(ruby_annotation: &CTRubyAnnotation) -> CTRubyAlignment;
407}
408
409extern "C-unwind" {
410 #[deprecated = "renamed to `CTRubyAnnotation::overhang`"]
411 pub fn CTRubyAnnotationGetOverhang(ruby_annotation: &CTRubyAnnotation) -> CTRubyOverhang;
412}
413
414extern "C-unwind" {
415 #[deprecated = "renamed to `CTRubyAnnotation::size_factor`"]
416 pub fn CTRubyAnnotationGetSizeFactor(ruby_annotation: &CTRubyAnnotation) -> CGFloat;
417}
418
419#[deprecated = "renamed to `CTRubyAnnotation::text_for_position`"]
420#[inline]
421pub unsafe extern "C-unwind" fn CTRubyAnnotationGetTextForPosition(
422 ruby_annotation: &CTRubyAnnotation,
423 position: CTRubyPosition,
424) -> Option<CFRetained<CFString>> {
425 extern "C-unwind" {
426 fn CTRubyAnnotationGetTextForPosition(
427 ruby_annotation: &CTRubyAnnotation,
428 position: CTRubyPosition,
429 ) -> Option<NonNull<CFString>>;
430 }
431 let ret = unsafe { CTRubyAnnotationGetTextForPosition(ruby_annotation, position) };
432 ret.map(|ret| unsafe { CFRetained::retain(ret) })
433}