use core::cell::UnsafeCell;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
use crate::*;
#[doc(alias = "CTRubyAnnotationRef")]
#[repr(C)]
pub struct CTRubyAnnotation {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
cf_type!(
unsafe impl CTRubyAnnotation {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"__CTRubyAnnotation"> for CTRubyAnnotation {}
);
unsafe impl ConcreteType for CTRubyAnnotation {
#[doc(alias = "CTRubyAnnotationGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn CTRubyAnnotationGetTypeID() -> CFTypeID;
}
unsafe { CTRubyAnnotationGetTypeID() }
}
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CTRubyAlignment(pub u8);
impl CTRubyAlignment {
#[doc(alias = "kCTRubyAlignmentInvalid")]
pub const Invalid: Self = Self(255);
#[doc(alias = "kCTRubyAlignmentAuto")]
pub const Auto: Self = Self(0);
#[doc(alias = "kCTRubyAlignmentStart")]
pub const Start: Self = Self(1);
#[doc(alias = "kCTRubyAlignmentCenter")]
pub const Center: Self = Self(2);
#[doc(alias = "kCTRubyAlignmentEnd")]
pub const End: Self = Self(3);
#[doc(alias = "kCTRubyAlignmentDistributeLetter")]
pub const DistributeLetter: Self = Self(4);
#[doc(alias = "kCTRubyAlignmentDistributeSpace")]
pub const DistributeSpace: Self = Self(5);
#[doc(alias = "kCTRubyAlignmentLineEdge")]
pub const LineEdge: Self = Self(6);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CTRubyAlignment {
const ENCODING: Encoding = u8::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CTRubyAlignment {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CTRubyOverhang(pub u8);
impl CTRubyOverhang {
#[doc(alias = "kCTRubyOverhangInvalid")]
pub const Invalid: Self = Self(255);
#[doc(alias = "kCTRubyOverhangAuto")]
pub const Auto: Self = Self(0);
#[doc(alias = "kCTRubyOverhangStart")]
pub const Start: Self = Self(1);
#[doc(alias = "kCTRubyOverhangEnd")]
pub const End: Self = Self(2);
#[doc(alias = "kCTRubyOverhangNone")]
pub const None: Self = Self(3);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CTRubyOverhang {
const ENCODING: Encoding = u8::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CTRubyOverhang {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CTRubyPosition(pub u8);
impl CTRubyPosition {
#[doc(alias = "kCTRubyPositionBefore")]
pub const Before: Self = Self(0);
#[doc(alias = "kCTRubyPositionAfter")]
pub const After: Self = Self(1);
#[doc(alias = "kCTRubyPositionInterCharacter")]
pub const InterCharacter: Self = Self(2);
#[doc(alias = "kCTRubyPositionInline")]
pub const Inline: Self = Self(3);
#[doc(alias = "kCTRubyPositionCount")]
pub const Count: Self = Self(4);
}
#[cfg(feature = "objc2")]
unsafe impl Encode for CTRubyPosition {
const ENCODING: Encoding = u8::ENCODING;
}
#[cfg(feature = "objc2")]
unsafe impl RefEncode for CTRubyPosition {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern "C" {
pub static kCTRubyAnnotationSizeFactorAttributeName: &'static CFString;
}
extern "C" {
pub static kCTRubyAnnotationScaleToFitAttributeName: &'static CFString;
}
impl CTRubyAnnotation {
#[doc(alias = "CTRubyAnnotationCreateWithAttributes")]
#[inline]
pub unsafe fn with_attributes(
alignment: CTRubyAlignment,
overhang: CTRubyOverhang,
position: CTRubyPosition,
string: &CFString,
attributes: &CFDictionary,
) -> CFRetained<CTRubyAnnotation> {
extern "C-unwind" {
fn CTRubyAnnotationCreateWithAttributes(
alignment: CTRubyAlignment,
overhang: CTRubyOverhang,
position: CTRubyPosition,
string: &CFString,
attributes: &CFDictionary,
) -> Option<NonNull<CTRubyAnnotation>>;
}
let ret = unsafe {
CTRubyAnnotationCreateWithAttributes(alignment, overhang, position, string, attributes)
};
let ret =
ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::from_raw(ret) }
}
#[doc(alias = "CTRubyAnnotationCreateCopy")]
#[inline]
pub unsafe fn copy(&self) -> CFRetained<CTRubyAnnotation> {
extern "C-unwind" {
fn CTRubyAnnotationCreateCopy(
ruby_annotation: &CTRubyAnnotation,
) -> Option<NonNull<CTRubyAnnotation>>;
}
let ret = unsafe { CTRubyAnnotationCreateCopy(self) };
let ret =
ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::from_raw(ret) }
}
#[doc(alias = "CTRubyAnnotationGetAlignment")]
#[inline]
pub unsafe fn alignment(&self) -> CTRubyAlignment {
extern "C-unwind" {
fn CTRubyAnnotationGetAlignment(ruby_annotation: &CTRubyAnnotation) -> CTRubyAlignment;
}
unsafe { CTRubyAnnotationGetAlignment(self) }
}
#[doc(alias = "CTRubyAnnotationGetOverhang")]
#[inline]
pub unsafe fn overhang(&self) -> CTRubyOverhang {
extern "C-unwind" {
fn CTRubyAnnotationGetOverhang(ruby_annotation: &CTRubyAnnotation) -> CTRubyOverhang;
}
unsafe { CTRubyAnnotationGetOverhang(self) }
}
#[doc(alias = "CTRubyAnnotationGetSizeFactor")]
#[inline]
pub unsafe fn size_factor(&self) -> CGFloat {
extern "C-unwind" {
fn CTRubyAnnotationGetSizeFactor(ruby_annotation: &CTRubyAnnotation) -> CGFloat;
}
unsafe { CTRubyAnnotationGetSizeFactor(self) }
}
#[doc(alias = "CTRubyAnnotationGetTextForPosition")]
#[inline]
pub unsafe fn text_for_position(
&self,
position: CTRubyPosition,
) -> Option<CFRetained<CFString>> {
extern "C-unwind" {
fn CTRubyAnnotationGetTextForPosition(
ruby_annotation: &CTRubyAnnotation,
position: CTRubyPosition,
) -> Option<NonNull<CFString>>;
}
let ret = unsafe { CTRubyAnnotationGetTextForPosition(self, position) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}
}
#[deprecated = "renamed to `CTRubyAnnotation::with_attributes`"]
#[inline]
pub unsafe extern "C-unwind" fn CTRubyAnnotationCreateWithAttributes(
alignment: CTRubyAlignment,
overhang: CTRubyOverhang,
position: CTRubyPosition,
string: &CFString,
attributes: &CFDictionary,
) -> CFRetained<CTRubyAnnotation> {
extern "C-unwind" {
fn CTRubyAnnotationCreateWithAttributes(
alignment: CTRubyAlignment,
overhang: CTRubyOverhang,
position: CTRubyPosition,
string: &CFString,
attributes: &CFDictionary,
) -> Option<NonNull<CTRubyAnnotation>>;
}
let ret = unsafe {
CTRubyAnnotationCreateWithAttributes(alignment, overhang, position, string, attributes)
};
let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::from_raw(ret) }
}
#[deprecated = "renamed to `CTRubyAnnotation::copy`"]
#[inline]
pub unsafe extern "C-unwind" fn CTRubyAnnotationCreateCopy(
ruby_annotation: &CTRubyAnnotation,
) -> CFRetained<CTRubyAnnotation> {
extern "C-unwind" {
fn CTRubyAnnotationCreateCopy(
ruby_annotation: &CTRubyAnnotation,
) -> Option<NonNull<CTRubyAnnotation>>;
}
let ret = unsafe { CTRubyAnnotationCreateCopy(ruby_annotation) };
let ret = ret.expect("function was marked as returning non-null, but actually returned NULL");
unsafe { CFRetained::from_raw(ret) }
}
extern "C-unwind" {
#[deprecated = "renamed to `CTRubyAnnotation::alignment`"]
pub fn CTRubyAnnotationGetAlignment(ruby_annotation: &CTRubyAnnotation) -> CTRubyAlignment;
}
extern "C-unwind" {
#[deprecated = "renamed to `CTRubyAnnotation::overhang`"]
pub fn CTRubyAnnotationGetOverhang(ruby_annotation: &CTRubyAnnotation) -> CTRubyOverhang;
}
extern "C-unwind" {
#[deprecated = "renamed to `CTRubyAnnotation::size_factor`"]
pub fn CTRubyAnnotationGetSizeFactor(ruby_annotation: &CTRubyAnnotation) -> CGFloat;
}
#[deprecated = "renamed to `CTRubyAnnotation::text_for_position`"]
#[inline]
pub unsafe extern "C-unwind" fn CTRubyAnnotationGetTextForPosition(
ruby_annotation: &CTRubyAnnotation,
position: CTRubyPosition,
) -> Option<CFRetained<CFString>> {
extern "C-unwind" {
fn CTRubyAnnotationGetTextForPosition(
ruby_annotation: &CTRubyAnnotation,
position: CTRubyPosition,
) -> Option<NonNull<CFString>>;
}
let ret = unsafe { CTRubyAnnotationGetTextForPosition(ruby_annotation, position) };
ret.map(|ret| unsafe { CFRetained::retain(ret) })
}