Source code
Revision control
Copy as Markdown
Other Tools
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use crate::*;
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsformattingcontext?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSFormattingContext(pub NSInteger);
impl NSFormattingContext {
#[doc(alias = "NSFormattingContextUnknown")]
pub const Unknown: Self = Self(0);
#[doc(alias = "NSFormattingContextDynamic")]
pub const Dynamic: Self = Self(1);
#[doc(alias = "NSFormattingContextStandalone")]
pub const Standalone: Self = Self(2);
#[doc(alias = "NSFormattingContextListItem")]
pub const ListItem: Self = Self(3);
#[doc(alias = "NSFormattingContextBeginningOfSentence")]
pub const BeginningOfSentence: Self = Self(4);
#[doc(alias = "NSFormattingContextMiddleOfSentence")]
pub const MiddleOfSentence: Self = Self(5);
}
unsafe impl Encode for NSFormattingContext {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSFormattingContext {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsformattingunitstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSFormattingUnitStyle(pub NSInteger);
impl NSFormattingUnitStyle {
#[doc(alias = "NSFormattingUnitStyleShort")]
pub const Short: Self = Self(1);
#[doc(alias = "NSFormattingUnitStyleMedium")]
pub const Medium: Self = Self(2);
#[doc(alias = "NSFormattingUnitStyleLong")]
pub const Long: Self = Self(3);
}
unsafe impl Encode for NSFormattingUnitStyle {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for NSFormattingUnitStyle {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsformatter?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSFormatter;
);
#[cfg(feature = "NSObject")]
extern_conformance!(
unsafe impl NSCoding for NSFormatter {}
);
#[cfg(feature = "NSObject")]
extern_conformance!(
unsafe impl NSCopying for NSFormatter {}
);
#[cfg(feature = "NSObject")]
unsafe impl CopyingHelper for NSFormatter {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for NSFormatter {}
);
impl NSFormatter {
extern_methods!(
#[cfg(feature = "NSString")]
/// # Safety
///
/// `obj` should be of the correct type.
#[unsafe(method(stringForObjectValue:))]
#[unsafe(method_family = none)]
pub unsafe fn stringForObjectValue(
&self,
obj: Option<&AnyObject>,
) -> Option<Retained<NSString>>;
#[cfg(all(
feature = "NSAttributedString",
feature = "NSDictionary",
feature = "NSString"
))]
/// # Safety
///
/// - `obj` should be of the correct type.
/// - `attrs` generic should be of the correct type.
#[unsafe(method(attributedStringForObjectValue:withDefaultAttributes:))]
#[unsafe(method_family = none)]
pub unsafe fn attributedStringForObjectValue_withDefaultAttributes(
&self,
obj: &AnyObject,
attrs: Option<&NSDictionary<NSAttributedStringKey, AnyObject>>,
) -> Option<Retained<NSAttributedString>>;
#[cfg(feature = "NSString")]
/// # Safety
///
/// `obj` should be of the correct type.
#[unsafe(method(editingStringForObjectValue:))]
#[unsafe(method_family = none)]
pub unsafe fn editingStringForObjectValue(
&self,
obj: &AnyObject,
) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
/// # Safety
///
/// `obj` should be of the correct type.
#[unsafe(method(getObjectValue:forString:errorDescription:))]
#[unsafe(method_family = none)]
pub unsafe fn getObjectValue_forString_errorDescription(
&self,
obj: Option<&mut Option<Retained<AnyObject>>>,
string: &NSString,
error: Option<&mut Option<Retained<NSString>>>,
) -> bool;
#[cfg(feature = "NSString")]
#[unsafe(method(isPartialStringValid:newEditingString:errorDescription:))]
#[unsafe(method_family = none)]
pub fn isPartialStringValid_newEditingString_errorDescription(
&self,
partial_string: &NSString,
new_string: Option<&mut Option<Retained<NSString>>>,
error: Option<&mut Option<Retained<NSString>>>,
) -> bool;
#[cfg(all(feature = "NSRange", feature = "NSString"))]
/// # Safety
///
/// `proposed_sel_range_ptr` must be a valid pointer or null.
#[unsafe(method(isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription:))]
#[unsafe(method_family = none)]
pub unsafe fn isPartialStringValid_proposedSelectedRange_originalString_originalSelectedRange_errorDescription(
&self,
partial_string_ptr: &mut Retained<NSString>,
proposed_sel_range_ptr: NSRangePointer,
orig_string: &NSString,
orig_sel_range: NSRange,
error: Option<&mut Option<Retained<NSString>>>,
) -> bool;
);
}
/// Methods declared on superclass `NSObject`.
impl NSFormatter {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub fn new() -> Retained<Self>;
);
}
impl DefaultRetained for NSFormatter {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}