| 1 |
// Copyright 2023 The Servo Project Developers. See the COPYRIGHT |
| 2 |
// file at the top-level directory of this distribution. |
| 3 |
// |
| 4 |
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
| 5 |
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
| 6 |
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
| 7 |
// option. This file may not be copied, modified, or distributed |
| 8 |
// except according to those terms. |
| 9 |
|
| 10 |
use crate::array::CFArrayRef; |
| 11 |
use crate::base::{CFAllocatorRef, CFIndex, CFTypeID, CFTypeRef, LangCode, RegionCode}; |
| 12 |
use crate::dictionary::CFDictionaryRef; |
| 13 |
use crate::notification_center::CFNotificationName; |
| 14 |
use crate::string::CFStringRef; |
| 15 |
use std::os::raw::c_void; |
| 16 |
|
| 17 |
#[repr(C)] |
| 18 |
pub struct __CFLocale(c_void); |
| 19 |
pub type CFLocaleRef = *const __CFLocale; |
| 20 |
|
| 21 |
pub type CFLocaleIdentifier = CFStringRef; |
| 22 |
pub type CFLocaleKey = CFStringRef; |
| 23 |
pub type CFCalendarIdentifier = CFStringRef; |
| 24 |
pub type CFLocaleLanguageDirection = CFIndex; |
| 25 |
|
| 26 |
pub const kCFLocaleLanguageDirectionUnknown: CFLocaleLanguageDirection = 0; |
| 27 |
pub const kCFLocaleLanguageDirectionLeftToRight: CFLocaleLanguageDirection = 1; |
| 28 |
pub const kCFLocaleLanguageDirectionRightToLeft: CFLocaleLanguageDirection = 2; |
| 29 |
pub const kCFLocaleLanguageDirectionTopToBottom: CFLocaleLanguageDirection = 3; |
| 30 |
pub const kCFLocaleLanguageDirectionBottomToTop: CFLocaleLanguageDirection = 4; |
| 31 |
|
| 32 |
extern "C" { |
| 33 |
/* |
| 34 |
* CFLocale.h |
| 35 |
*/ |
| 36 |
|
| 37 |
/* Locale Change Notification */ |
| 38 |
pub static kCFLocaleCurrentLocaleDidChangeNotification: CFNotificationName; |
| 39 |
|
| 40 |
/* Locale Property Keys */ |
| 41 |
pub static kCFLocaleIdentifier: CFLocaleKey; |
| 42 |
pub static kCFLocaleLanguageCode: CFLocaleKey; |
| 43 |
pub static kCFLocaleCountryCode: CFLocaleKey; |
| 44 |
pub static kCFLocaleScriptCode: CFLocaleKey; |
| 45 |
pub static kCFLocaleVariantCode: CFLocaleKey; |
| 46 |
|
| 47 |
pub static kCFLocaleExemplarCharacterSet: CFLocaleKey; |
| 48 |
pub static kCFLocaleCalendarIdentifier: CFLocaleKey; |
| 49 |
pub static kCFLocaleCalendar: CFLocaleKey; |
| 50 |
pub static kCFLocaleCollationIdentifier: CFLocaleKey; |
| 51 |
pub static kCFLocaleUsesMetricSystem: CFLocaleKey; |
| 52 |
pub static kCFLocaleMeasurementSystem: CFLocaleKey; |
| 53 |
pub static kCFLocaleDecimalSeparator: CFLocaleKey; |
| 54 |
pub static kCFLocaleGroupingSeparator: CFLocaleKey; |
| 55 |
pub static kCFLocaleCurrencySymbol: CFLocaleKey; |
| 56 |
pub static kCFLocaleCurrencyCode: CFLocaleKey; |
| 57 |
pub static kCFLocaleCollatorIdentifier: CFLocaleKey; |
| 58 |
pub static kCFLocaleQuotationBeginDelimiterKey: CFLocaleKey; |
| 59 |
pub static kCFLocaleQuotationEndDelimiterKey: CFLocaleKey; |
| 60 |
pub static kCFLocaleAlternateQuotationBeginDelimiterKey: CFLocaleKey; |
| 61 |
pub static kCFLocaleAlternateQuotationEndDelimiterKey: CFLocaleKey; |
| 62 |
|
| 63 |
/* Locale Calendar Identifiers */ |
| 64 |
pub static kCFGregorianCalendar: CFCalendarIdentifier; |
| 65 |
pub static kCFBuddhistCalendar: CFCalendarIdentifier; |
| 66 |
pub static kCFChineseCalendar: CFCalendarIdentifier; |
| 67 |
pub static kCFHebrewCalendar: CFCalendarIdentifier; |
| 68 |
pub static kCFIslamicCalendar: CFCalendarIdentifier; |
| 69 |
pub static kCFIslamicCivilCalendar: CFCalendarIdentifier; |
| 70 |
pub static kCFJapaneseCalendar: CFCalendarIdentifier; |
| 71 |
pub static kCFRepublicOfChinaCalendar: CFCalendarIdentifier; |
| 72 |
pub static kCFPersianCalendar: CFCalendarIdentifier; |
| 73 |
pub static kCFIndianCalendar: CFCalendarIdentifier; |
| 74 |
pub static kCFISO8601Calendar: CFCalendarIdentifier; |
| 75 |
//pub static kCFIslamicTabularCalendar: CFCalendarIdentifier; // macos(10.10)+ |
| 76 |
//pub static kCFIslamicUmmAlQuraCalendar: CFCalendarIdentifier; // macos(10.10)+ |
| 77 |
|
| 78 |
/* Creating a Locale */ |
| 79 |
pub fn CFLocaleCopyCurrent() -> CFLocaleRef; |
| 80 |
pub fn CFLocaleCreate( |
| 81 |
allocator: CFAllocatorRef, |
| 82 |
localeIdentifier: CFLocaleIdentifier, |
| 83 |
) -> CFLocaleRef; |
| 84 |
pub fn CFLocaleCreateCopy(allocator: CFAllocatorRef, locale: CFLocaleRef) -> CFLocaleRef; |
| 85 |
pub fn CFLocaleGetSystem() -> CFLocaleRef; |
| 86 |
|
| 87 |
/* Getting System Locale Information */ |
| 88 |
pub fn CFLocaleCopyAvailableLocaleIdentifiers() -> CFArrayRef; |
| 89 |
|
| 90 |
/* Getting ISO Information */ |
| 91 |
pub fn CFLocaleCopyISOCountryCodes() -> CFArrayRef; |
| 92 |
pub fn CFLocaleCopyISOLanguageCodes() -> CFArrayRef; |
| 93 |
pub fn CFLocaleCopyISOCurrencyCodes() -> CFArrayRef; |
| 94 |
pub fn CFLocaleCopyCommonISOCurrencyCodes() -> CFArrayRef; |
| 95 |
|
| 96 |
/* Language Preferences */ |
| 97 |
pub fn CFLocaleCopyPreferredLanguages() -> CFArrayRef; |
| 98 |
|
| 99 |
/* Getting Information About a Locale */ |
| 100 |
pub fn CFLocaleCopyDisplayNameForPropertyValue( |
| 101 |
displayLocale: CFLocaleRef, |
| 102 |
key: CFLocaleKey, |
| 103 |
value: CFStringRef, |
| 104 |
) -> CFStringRef; |
| 105 |
pub fn CFLocaleGetValue(locale: CFLocaleRef, key: CFLocaleKey) -> CFTypeRef; |
| 106 |
pub fn CFLocaleGetIdentifier(locale: CFLocaleRef) -> CFLocaleIdentifier; |
| 107 |
|
| 108 |
/* Getting and Creating Locale Identifiers */ |
| 109 |
pub fn CFLocaleCreateCanonicalLocaleIdentifierFromScriptManagerCodes( |
| 110 |
allocator: CFAllocatorRef, |
| 111 |
lcode: LangCode, |
| 112 |
rcode: RegionCode, |
| 113 |
) -> CFLocaleIdentifier; |
| 114 |
pub fn CFLocaleCreateCanonicalLanguageIdentifierFromString( |
| 115 |
allocator: CFAllocatorRef, |
| 116 |
localeIdentifier: CFStringRef, |
| 117 |
) -> CFLocaleIdentifier; |
| 118 |
pub fn CFLocaleCreateCanonicalLocaleIdentifierFromString( |
| 119 |
allocator: CFAllocatorRef, |
| 120 |
localeIdentifier: CFStringRef, |
| 121 |
) -> CFLocaleIdentifier; |
| 122 |
pub fn CFLocaleCreateComponentsFromLocaleIdentifier( |
| 123 |
allocator: CFAllocatorRef, |
| 124 |
localeID: CFLocaleIdentifier, |
| 125 |
) -> CFDictionaryRef; |
| 126 |
pub fn CFLocaleCreateLocaleIdentifierFromComponents( |
| 127 |
allocator: CFAllocatorRef, |
| 128 |
dictionary: CFDictionaryRef, |
| 129 |
) -> CFLocaleIdentifier; |
| 130 |
pub fn CFLocaleCreateLocaleIdentifierFromWindowsLocaleCode( |
| 131 |
allocator: CFAllocatorRef, |
| 132 |
lcid: u32, |
| 133 |
) -> CFLocaleIdentifier; |
| 134 |
pub fn CFLocaleGetWindowsLocaleCodeFromLocaleIdentifier( |
| 135 |
localeIdentifier: CFLocaleIdentifier, |
| 136 |
) -> u32; |
| 137 |
|
| 138 |
/* Getting Line and Character Direction for a Language */ |
| 139 |
pub fn CFLocaleGetLanguageCharacterDirection( |
| 140 |
isoLangCode: CFStringRef, |
| 141 |
) -> CFLocaleLanguageDirection; |
| 142 |
pub fn CFLocaleGetLanguageLineDirection(isoLangCode: CFStringRef) -> CFLocaleLanguageDirection; |
| 143 |
|
| 144 |
/* Getting the CFLocale Type ID */ |
| 145 |
pub fn CFLocaleGetTypeID() -> CFTypeID; |
| 146 |
} |