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::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use crate::*;
pub const NSBundleExecutableArchitectureI386: c_uint = 0x00000007;
pub const NSBundleExecutableArchitecturePPC: c_uint = 0x00000012;
pub const NSBundleExecutableArchitectureX86_64: c_uint = 0x01000007;
pub const NSBundleExecutableArchitecturePPC64: c_uint = 0x01000012;
pub const NSBundleExecutableArchitectureARM64: c_uint = 0x0100000c;
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSBundle;
);
unsafe impl Send for NSBundle {}
unsafe impl Sync for NSBundle {}
extern_conformance!(
unsafe impl NSObjectProtocol for NSBundle {}
);
impl NSBundle {
extern_methods!(
#[unsafe(method(mainBundle))]
#[unsafe(method_family = none)]
pub fn mainBundle() -> Retained<NSBundle>;
#[cfg(feature = "NSString")]
#[unsafe(method(bundleWithPath:))]
#[unsafe(method_family = none)]
pub fn bundleWithPath(path: &NSString) -> Option<Retained<Self>>;
#[cfg(feature = "NSString")]
#[unsafe(method(initWithPath:))]
#[unsafe(method_family = init)]
pub fn initWithPath(this: Allocated<Self>, path: &NSString) -> Option<Retained<Self>>;
#[cfg(feature = "NSURL")]
#[unsafe(method(bundleWithURL:))]
#[unsafe(method_family = none)]
pub fn bundleWithURL(url: &NSURL) -> Option<Retained<Self>>;
#[cfg(feature = "NSURL")]
#[unsafe(method(initWithURL:))]
#[unsafe(method_family = init)]
pub fn initWithURL(this: Allocated<Self>, url: &NSURL) -> Option<Retained<Self>>;
/// # Safety
///
/// `a_class` probably has further requirements.
#[unsafe(method(bundleForClass:))]
#[unsafe(method_family = none)]
pub unsafe fn bundleForClass(a_class: &AnyClass) -> Retained<NSBundle>;
#[cfg(feature = "NSString")]
#[unsafe(method(bundleWithIdentifier:))]
#[unsafe(method_family = none)]
pub fn bundleWithIdentifier(identifier: &NSString) -> Option<Retained<NSBundle>>;
#[cfg(feature = "NSArray")]
#[unsafe(method(allBundles))]
#[unsafe(method_family = none)]
pub unsafe fn allBundles() -> Retained<NSArray<NSBundle>>;
#[cfg(feature = "NSArray")]
#[unsafe(method(allFrameworks))]
#[unsafe(method_family = none)]
pub unsafe fn allFrameworks() -> Retained<NSArray<NSBundle>>;
#[unsafe(method(load))]
#[unsafe(method_family = none)]
pub unsafe fn load(&self) -> bool;
#[unsafe(method(isLoaded))]
#[unsafe(method_family = none)]
pub fn isLoaded(&self) -> bool;
#[unsafe(method(unload))]
#[unsafe(method_family = none)]
pub unsafe fn unload(&self) -> bool;
#[cfg(feature = "NSError")]
#[unsafe(method(preflightAndReturnError:_))]
#[unsafe(method_family = none)]
pub fn preflightAndReturnError(&self) -> Result<(), Retained<NSError>>;
#[cfg(feature = "NSError")]
#[unsafe(method(loadAndReturnError:_))]
#[unsafe(method_family = none)]
pub unsafe fn loadAndReturnError(&self) -> Result<(), Retained<NSError>>;
#[cfg(feature = "NSURL")]
#[unsafe(method(bundleURL))]
#[unsafe(method_family = none)]
pub fn bundleURL(&self) -> Retained<NSURL>;
#[cfg(feature = "NSURL")]
#[unsafe(method(resourceURL))]
#[unsafe(method_family = none)]
pub fn resourceURL(&self) -> Option<Retained<NSURL>>;
#[cfg(feature = "NSURL")]
#[unsafe(method(executableURL))]
#[unsafe(method_family = none)]
pub fn executableURL(&self) -> Option<Retained<NSURL>>;
#[cfg(all(feature = "NSString", feature = "NSURL"))]
#[unsafe(method(URLForAuxiliaryExecutable:))]
#[unsafe(method_family = none)]
pub fn URLForAuxiliaryExecutable(
&self,
executable_name: &NSString,
) -> Option<Retained<NSURL>>;
#[cfg(feature = "NSURL")]
#[unsafe(method(privateFrameworksURL))]
#[unsafe(method_family = none)]
pub fn privateFrameworksURL(&self) -> Option<Retained<NSURL>>;
#[cfg(feature = "NSURL")]
#[unsafe(method(sharedFrameworksURL))]
#[unsafe(method_family = none)]
pub fn sharedFrameworksURL(&self) -> Option<Retained<NSURL>>;
#[cfg(feature = "NSURL")]
#[unsafe(method(sharedSupportURL))]
#[unsafe(method_family = none)]
pub fn sharedSupportURL(&self) -> Option<Retained<NSURL>>;
#[cfg(feature = "NSURL")]
#[unsafe(method(builtInPlugInsURL))]
#[unsafe(method_family = none)]
pub fn builtInPlugInsURL(&self) -> Option<Retained<NSURL>>;
#[cfg(feature = "NSURL")]
#[unsafe(method(appStoreReceiptURL))]
#[unsafe(method_family = none)]
pub fn appStoreReceiptURL(&self) -> Option<Retained<NSURL>>;
#[cfg(feature = "NSString")]
#[unsafe(method(bundlePath))]
#[unsafe(method_family = none)]
pub fn bundlePath(&self) -> Retained<NSString>;
#[cfg(feature = "NSString")]
#[unsafe(method(resourcePath))]
#[unsafe(method_family = none)]
pub fn resourcePath(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
#[unsafe(method(executablePath))]
#[unsafe(method_family = none)]
pub fn executablePath(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
#[unsafe(method(pathForAuxiliaryExecutable:))]
#[unsafe(method_family = none)]
pub fn pathForAuxiliaryExecutable(
&self,
executable_name: &NSString,
) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
#[unsafe(method(privateFrameworksPath))]
#[unsafe(method_family = none)]
pub fn privateFrameworksPath(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
#[unsafe(method(sharedFrameworksPath))]
#[unsafe(method_family = none)]
pub fn sharedFrameworksPath(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
#[unsafe(method(sharedSupportPath))]
#[unsafe(method_family = none)]
pub fn sharedSupportPath(&self) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
#[unsafe(method(builtInPlugInsPath))]
#[unsafe(method_family = none)]
pub fn builtInPlugInsPath(&self) -> Option<Retained<NSString>>;
#[cfg(all(feature = "NSString", feature = "NSURL"))]
#[unsafe(method(URLForResource:withExtension:subdirectory:inBundleWithURL:))]
#[unsafe(method_family = none)]
pub fn URLForResource_withExtension_subdirectory_inBundleWithURL(
name: Option<&NSString>,
ext: Option<&NSString>,
subpath: Option<&NSString>,
bundle_url: &NSURL,
) -> Option<Retained<NSURL>>;
#[cfg(all(feature = "NSArray", feature = "NSString", feature = "NSURL"))]
#[unsafe(method(URLsForResourcesWithExtension:subdirectory:inBundleWithURL:))]
#[unsafe(method_family = none)]
pub fn URLsForResourcesWithExtension_subdirectory_inBundleWithURL(
ext: Option<&NSString>,
subpath: Option<&NSString>,
bundle_url: &NSURL,
) -> Option<Retained<NSArray<NSURL>>>;
#[cfg(all(feature = "NSString", feature = "NSURL"))]
#[unsafe(method(URLForResource:withExtension:))]
#[unsafe(method_family = none)]
pub fn URLForResource_withExtension(
&self,
name: Option<&NSString>,
ext: Option<&NSString>,
) -> Option<Retained<NSURL>>;
#[cfg(all(feature = "NSString", feature = "NSURL"))]
#[unsafe(method(URLForResource:withExtension:subdirectory:))]
#[unsafe(method_family = none)]
pub fn URLForResource_withExtension_subdirectory(
&self,
name: Option<&NSString>,
ext: Option<&NSString>,
subpath: Option<&NSString>,
) -> Option<Retained<NSURL>>;
#[cfg(all(feature = "NSString", feature = "NSURL"))]
#[unsafe(method(URLForResource:withExtension:subdirectory:localization:))]
#[unsafe(method_family = none)]
pub fn URLForResource_withExtension_subdirectory_localization(
&self,
name: Option<&NSString>,
ext: Option<&NSString>,
subpath: Option<&NSString>,
localization_name: Option<&NSString>,
) -> Option<Retained<NSURL>>;
#[cfg(all(feature = "NSArray", feature = "NSString", feature = "NSURL"))]
#[unsafe(method(URLsForResourcesWithExtension:subdirectory:))]
#[unsafe(method_family = none)]
pub fn URLsForResourcesWithExtension_subdirectory(
&self,
ext: Option<&NSString>,
subpath: Option<&NSString>,
) -> Option<Retained<NSArray<NSURL>>>;
#[cfg(all(feature = "NSArray", feature = "NSString", feature = "NSURL"))]
#[unsafe(method(URLsForResourcesWithExtension:subdirectory:localization:))]
#[unsafe(method_family = none)]
pub fn URLsForResourcesWithExtension_subdirectory_localization(
&self,
ext: Option<&NSString>,
subpath: Option<&NSString>,
localization_name: Option<&NSString>,
) -> Option<Retained<NSArray<NSURL>>>;
#[cfg(feature = "NSString")]
#[unsafe(method(pathForResource:ofType:inDirectory:))]
#[unsafe(method_family = none)]
pub fn pathForResource_ofType_inDirectory_class(
name: Option<&NSString>,
ext: Option<&NSString>,
bundle_path: &NSString,
) -> Option<Retained<NSString>>;
#[cfg(all(feature = "NSArray", feature = "NSString"))]
#[unsafe(method(pathsForResourcesOfType:inDirectory:))]
#[unsafe(method_family = none)]
pub fn pathsForResourcesOfType_inDirectory_class(
ext: Option<&NSString>,
bundle_path: &NSString,
) -> Retained<NSArray<NSString>>;
#[cfg(feature = "NSString")]
#[unsafe(method(pathForResource:ofType:))]
#[unsafe(method_family = none)]
pub fn pathForResource_ofType(
&self,
name: Option<&NSString>,
ext: Option<&NSString>,
) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
#[unsafe(method(pathForResource:ofType:inDirectory:))]
#[unsafe(method_family = none)]
pub fn pathForResource_ofType_inDirectory(
&self,
name: Option<&NSString>,
ext: Option<&NSString>,
subpath: Option<&NSString>,
) -> Option<Retained<NSString>>;
#[cfg(feature = "NSString")]
#[unsafe(method(pathForResource:ofType:inDirectory:forLocalization:))]
#[unsafe(method_family = none)]
pub fn pathForResource_ofType_inDirectory_forLocalization(
&self,
name: Option<&NSString>,
ext: Option<&NSString>,
subpath: Option<&NSString>,
localization_name: Option<&NSString>,
) -> Option<Retained<NSString>>;
#[cfg(all(feature = "NSArray", feature = "NSString"))]
#[unsafe(method(pathsForResourcesOfType:inDirectory:))]
#[unsafe(method_family = none)]
pub fn pathsForResourcesOfType_inDirectory(
&self,
ext: Option<&NSString>,
subpath: Option<&NSString>,
) -> Retained<NSArray<NSString>>;
#[cfg(all(feature = "NSArray", feature = "NSString"))]
#[unsafe(method(pathsForResourcesOfType:inDirectory:forLocalization:))]
#[unsafe(method_family = none)]
pub fn pathsForResourcesOfType_inDirectory_forLocalization(
&self,
ext: Option<&NSString>,
subpath: Option<&NSString>,
localization_name: Option<&NSString>,
) -> Retained<NSArray<NSString>>;
#[cfg(feature = "NSString")]
#[unsafe(method(localizedStringForKey:value:table:))]
#[unsafe(method_family = none)]
pub fn localizedStringForKey_value_table(
&self,
key: &NSString,
value: Option<&NSString>,
table_name: Option<&NSString>,
) -> Retained<NSString>;
#[cfg(all(feature = "NSArray", feature = "NSString"))]
/// Look up a localized string given a list of available localizations.
/// - Parameters:
/// - key: The key for the localized string to retrieve.
/// - value: A default value to return if a localized string for ``key`` cannot be found.
/// - tableName: The name of the strings file to search. If `nil`, the method uses tables in `Localizable.strings`.
/// - localizations: An array of BCP 47 language codes corresponding to available localizations. Bundle compares the array against its available localizations, and uses the best result to retrieve the localized string. If empty, we treat it as no localization is available, and may return a fallback.
/// - Returns: A localized version of the string designated by ``key`` in table ``tableName``.
#[unsafe(method(localizedStringForKey:value:table:localizations:))]
#[unsafe(method_family = none)]
pub fn localizedStringForKey_value_table_localizations(
&self,
key: &NSString,
value: Option<&NSString>,
table_name: Option<&NSString>,
localizations: &NSArray<NSString>,
) -> Retained<NSString>;
#[cfg(feature = "NSString")]
#[unsafe(method(bundleIdentifier))]
#[unsafe(method_family = none)]
pub fn bundleIdentifier(&self) -> Option<Retained<NSString>>;
#[cfg(all(feature = "NSDictionary", feature = "NSString"))]
#[unsafe(method(infoDictionary))]
#[unsafe(method_family = none)]
pub fn infoDictionary(&self) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
#[cfg(all(feature = "NSDictionary", feature = "NSString"))]
#[unsafe(method(localizedInfoDictionary))]
#[unsafe(method_family = none)]
pub fn localizedInfoDictionary(
&self,
) -> Option<Retained<NSDictionary<NSString, AnyObject>>>;
#[cfg(feature = "NSString")]
#[unsafe(method(objectForInfoDictionaryKey:))]
#[unsafe(method_family = none)]
pub fn objectForInfoDictionaryKey(&self, key: &NSString) -> Option<Retained<AnyObject>>;
#[cfg(feature = "NSString")]
#[unsafe(method(classNamed:))]
#[unsafe(method_family = none)]
pub fn classNamed(&self, class_name: &NSString) -> Option<&'static AnyClass>;
#[unsafe(method(principalClass))]
#[unsafe(method_family = none)]
pub fn principalClass(&self) -> Option<&'static AnyClass>;
#[cfg(all(feature = "NSArray", feature = "NSString"))]
#[unsafe(method(preferredLocalizations))]
#[unsafe(method_family = none)]
pub fn preferredLocalizations(&self) -> Retained<NSArray<NSString>>;
#[cfg(all(feature = "NSArray", feature = "NSString"))]
#[unsafe(method(localizations))]
#[unsafe(method_family = none)]
pub fn localizations(&self) -> Retained<NSArray<NSString>>;
#[cfg(feature = "NSString")]
#[unsafe(method(developmentLocalization))]
#[unsafe(method_family = none)]
pub fn developmentLocalization(&self) -> Option<Retained<NSString>>;
#[cfg(all(feature = "NSArray", feature = "NSString"))]
#[unsafe(method(preferredLocalizationsFromArray:))]
#[unsafe(method_family = none)]
pub fn preferredLocalizationsFromArray(
localizations_array: &NSArray<NSString>,
) -> Retained<NSArray<NSString>>;
#[cfg(all(feature = "NSArray", feature = "NSString"))]
#[unsafe(method(preferredLocalizationsFromArray:forPreferences:))]
#[unsafe(method_family = none)]
pub fn preferredLocalizationsFromArray_forPreferences(
localizations_array: &NSArray<NSString>,
preferences_array: Option<&NSArray<NSString>>,
) -> Retained<NSArray<NSString>>;
#[cfg(all(feature = "NSArray", feature = "NSValue"))]
#[unsafe(method(executableArchitectures))]
#[unsafe(method_family = none)]
pub fn executableArchitectures(&self) -> Option<Retained<NSArray<NSNumber>>>;
);
}
/// Methods declared on superclass `NSObject`.
impl NSBundle {
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 NSBundle {
#[inline]
fn default_retained() -> Retained<Self> {
Self::new()
}
}
/// NSBundleExtensionMethods.
#[cfg(feature = "NSString")]
impl NSString {
extern_methods!(
#[unsafe(method(variantFittingPresentationWidth:))]
#[unsafe(method_family = none)]
pub fn variantFittingPresentationWidth(&self, width: NSInteger) -> Retained<NSString>;
);
}
extern "C" {
#[cfg(all(feature = "NSNotification", feature = "NSString"))]
pub static NSBundleDidLoadNotification: &'static NSNotificationName;
}
extern "C" {
#[cfg(feature = "NSString")]
pub static NSLoadedClasses: &'static NSString;
}
extern_class!(
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct NSBundleResourceRequest;
);
extern_conformance!(
unsafe impl NSObjectProtocol for NSBundleResourceRequest {}
);
#[cfg(feature = "NSProgress")]
extern_conformance!(
unsafe impl NSProgressReporting for NSBundleResourceRequest {}
);
impl NSBundleResourceRequest {
extern_methods!(
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[cfg(all(feature = "NSSet", feature = "NSString"))]
#[unsafe(method(initWithTags:))]
#[unsafe(method_family = init)]
pub fn initWithTags(this: Allocated<Self>, tags: &NSSet<NSString>) -> Retained<Self>;
#[cfg(all(feature = "NSSet", feature = "NSString"))]
#[unsafe(method(initWithTags:bundle:))]
#[unsafe(method_family = init)]
pub fn initWithTags_bundle(
this: Allocated<Self>,
tags: &NSSet<NSString>,
bundle: &NSBundle,
) -> Retained<Self>;
#[unsafe(method(loadingPriority))]
#[unsafe(method_family = none)]
pub fn loadingPriority(&self) -> c_double;
/// Setter for [`loadingPriority`][Self::loadingPriority].
#[unsafe(method(setLoadingPriority:))]
#[unsafe(method_family = none)]
pub fn setLoadingPriority(&self, loading_priority: c_double);
#[cfg(all(feature = "NSSet", feature = "NSString"))]
#[unsafe(method(tags))]
#[unsafe(method_family = none)]
pub fn tags(&self) -> Retained<NSSet<NSString>>;
#[unsafe(method(bundle))]
#[unsafe(method_family = none)]
pub fn bundle(&self) -> Retained<NSBundle>;
#[cfg(all(feature = "NSError", feature = "block2"))]
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(beginAccessingResourcesWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn beginAccessingResourcesWithCompletionHandler(
&self,
completion_handler: &block2::DynBlock<dyn Fn(*mut NSError)>,
);
#[cfg(feature = "block2")]
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(conditionallyBeginAccessingResourcesWithCompletionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn conditionallyBeginAccessingResourcesWithCompletionHandler(
&self,
completion_handler: &block2::DynBlock<dyn Fn(Bool)>,
);
#[unsafe(method(endAccessingResources))]
#[unsafe(method_family = none)]
pub fn endAccessingResources(&self);
#[cfg(feature = "NSProgress")]
#[unsafe(method(progress))]
#[unsafe(method_family = none)]
pub fn progress(&self) -> Retained<NSProgress>;
);
}
/// Methods declared on superclass `NSObject`.
impl NSBundleResourceRequest {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
/// NSBundleResourceRequestAdditions.
impl NSBundle {
extern_methods!(
#[cfg(all(feature = "NSSet", feature = "NSString"))]
#[unsafe(method(setPreservationPriority:forTags:))]
#[unsafe(method_family = none)]
pub fn setPreservationPriority_forTags(&self, priority: c_double, tags: &NSSet<NSString>);
#[cfg(feature = "NSString")]
#[unsafe(method(preservationPriorityForTag:))]
#[unsafe(method_family = none)]
pub fn preservationPriorityForTag(&self, tag: &NSString) -> c_double;
);
}
extern "C" {
#[cfg(all(feature = "NSNotification", feature = "NSString"))]
pub static NSBundleResourceRequestLowDiskSpaceNotification: &'static NSNotificationName;
}
extern "C" {
pub static NSBundleResourceRequestLoadingPriorityUrgent: c_double;
}