objc2-foundation 0.3.2

Bindings to the Foundation framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;

use crate::*;

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nslistformatter?language=objc)
    #[unsafe(super(NSFormatter, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "NSFormatter")]
    pub struct NSListFormatter;
);

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
extern_conformance!(
    unsafe impl NSCoding for NSListFormatter {}
);

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
extern_conformance!(
    unsafe impl NSCopying for NSListFormatter {}
);

#[cfg(all(feature = "NSFormatter", feature = "NSObject"))]
unsafe impl CopyingHelper for NSListFormatter {
    type Result = Self;
}

#[cfg(feature = "NSFormatter")]
extern_conformance!(
    unsafe impl NSObjectProtocol for NSListFormatter {}
);

#[cfg(feature = "NSFormatter")]
impl NSListFormatter {
    extern_methods!(
        #[cfg(feature = "NSLocale")]
        #[unsafe(method(locale))]
        #[unsafe(method_family = none)]
        pub fn locale(&self) -> Retained<NSLocale>;

        #[cfg(feature = "NSLocale")]
        /// Setter for [`locale`][Self::locale].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setLocale:))]
        #[unsafe(method_family = none)]
        pub fn setLocale(&self, locale: Option<&NSLocale>);

        #[unsafe(method(itemFormatter))]
        #[unsafe(method_family = none)]
        pub fn itemFormatter(&self) -> Option<Retained<NSFormatter>>;

        /// Setter for [`itemFormatter`][Self::itemFormatter].
        ///
        /// This is [copied][crate::NSCopying::copy] when set.
        #[unsafe(method(setItemFormatter:))]
        #[unsafe(method_family = none)]
        pub fn setItemFormatter(&self, item_formatter: Option<&NSFormatter>);

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        #[unsafe(method(localizedStringByJoiningStrings:))]
        #[unsafe(method_family = none)]
        pub fn localizedStringByJoiningStrings(strings: &NSArray<NSString>) -> Retained<NSString>;

        #[cfg(all(feature = "NSArray", feature = "NSString"))]
        /// # Safety
        ///
        /// `items` generic should be of the correct type.
        #[unsafe(method(stringFromItems:))]
        #[unsafe(method_family = none)]
        pub unsafe fn stringFromItems(&self, items: &NSArray) -> Option<Retained<NSString>>;

        #[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>>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "NSFormatter")]
impl NSListFormatter {
    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>;
    );
}

#[cfg(feature = "NSFormatter")]
impl DefaultRetained for NSListFormatter {
    #[inline]
    fn default_retained() -> Retained<Self> {
        Self::new()
    }
}