objc2_foundation/generated/
NSDecimalNumber.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern "C" {
10    /// *************    Exceptions        **********
11    ///
12    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdecimalnumberexactnessexception?language=objc)
13    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
14    pub static NSDecimalNumberExactnessException: &'static NSExceptionName;
15}
16
17extern "C" {
18    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdecimalnumberoverflowexception?language=objc)
19    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
20    pub static NSDecimalNumberOverflowException: &'static NSExceptionName;
21}
22
23extern "C" {
24    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdecimalnumberunderflowexception?language=objc)
25    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
26    pub static NSDecimalNumberUnderflowException: &'static NSExceptionName;
27}
28
29extern "C" {
30    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdecimalnumberdividebyzeroexception?language=objc)
31    #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
32    pub static NSDecimalNumberDivideByZeroException: &'static NSExceptionName;
33}
34
35extern_protocol!(
36    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdecimalnumberbehaviors?language=objc)
37    pub unsafe trait NSDecimalNumberBehaviors {
38        #[cfg(feature = "NSDecimal")]
39        #[unsafe(method(roundingMode))]
40        #[unsafe(method_family = none)]
41        unsafe fn roundingMode(&self) -> NSRoundingMode;
42
43        #[unsafe(method(scale))]
44        #[unsafe(method_family = none)]
45        unsafe fn scale(&self) -> c_short;
46
47        #[cfg(all(feature = "NSDecimal", feature = "NSValue"))]
48        #[unsafe(method(exceptionDuringOperation:error:leftOperand:rightOperand:))]
49        #[unsafe(method_family = none)]
50        unsafe fn exceptionDuringOperation_error_leftOperand_rightOperand(
51            &self,
52            operation: Sel,
53            error: NSCalculationError,
54            left_operand: &NSDecimalNumber,
55            right_operand: Option<&NSDecimalNumber>,
56        ) -> Option<Retained<NSDecimalNumber>>;
57    }
58);
59
60extern_class!(
61    /// *************    NSDecimalNumber: the class        **********
62    ///
63    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdecimalnumber?language=objc)
64    #[unsafe(super(NSNumber, NSValue, NSObject))]
65    #[derive(Debug, PartialEq, Eq, Hash)]
66    #[cfg(feature = "NSValue")]
67    pub struct NSDecimalNumber;
68);
69
70#[cfg(feature = "NSValue")]
71unsafe impl Send for NSDecimalNumber {}
72
73#[cfg(feature = "NSValue")]
74unsafe impl Sync for NSDecimalNumber {}
75
76#[cfg(all(feature = "NSObject", feature = "NSValue"))]
77unsafe impl NSCoding for NSDecimalNumber {}
78
79#[cfg(all(feature = "NSObject", feature = "NSValue"))]
80unsafe impl NSCopying for NSDecimalNumber {}
81
82#[cfg(all(feature = "NSObject", feature = "NSValue"))]
83unsafe impl CopyingHelper for NSDecimalNumber {
84    type Result = Self;
85}
86
87#[cfg(feature = "NSValue")]
88unsafe impl NSObjectProtocol for NSDecimalNumber {}
89
90#[cfg(all(feature = "NSObject", feature = "NSValue"))]
91unsafe impl NSSecureCoding for NSDecimalNumber {}
92
93#[cfg(feature = "NSValue")]
94impl NSDecimalNumber {
95    extern_methods!(
96        #[unsafe(method(initWithMantissa:exponent:isNegative:))]
97        #[unsafe(method_family = init)]
98        pub unsafe fn initWithMantissa_exponent_isNegative(
99            this: Allocated<Self>,
100            mantissa: c_ulonglong,
101            exponent: c_short,
102            flag: bool,
103        ) -> Retained<Self>;
104
105        #[cfg(feature = "NSDecimal")]
106        #[unsafe(method(initWithDecimal:))]
107        #[unsafe(method_family = init)]
108        pub unsafe fn initWithDecimal(this: Allocated<Self>, dcm: NSDecimal) -> Retained<Self>;
109
110        #[cfg(feature = "NSString")]
111        #[unsafe(method(initWithString:))]
112        #[unsafe(method_family = init)]
113        pub unsafe fn initWithString(
114            this: Allocated<Self>,
115            number_value: Option<&NSString>,
116        ) -> Retained<Self>;
117
118        #[cfg(feature = "NSString")]
119        #[unsafe(method(initWithString:locale:))]
120        #[unsafe(method_family = init)]
121        pub unsafe fn initWithString_locale(
122            this: Allocated<Self>,
123            number_value: Option<&NSString>,
124            locale: Option<&AnyObject>,
125        ) -> Retained<Self>;
126
127        #[cfg(feature = "NSString")]
128        #[unsafe(method(descriptionWithLocale:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn descriptionWithLocale(
131            &self,
132            locale: Option<&AnyObject>,
133        ) -> Retained<NSString>;
134
135        #[cfg(feature = "NSDecimal")]
136        #[unsafe(method(decimalValue))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn decimalValue(&self) -> NSDecimal;
139
140        #[unsafe(method(decimalNumberWithMantissa:exponent:isNegative:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn decimalNumberWithMantissa_exponent_isNegative(
143            mantissa: c_ulonglong,
144            exponent: c_short,
145            flag: bool,
146        ) -> Retained<NSDecimalNumber>;
147
148        #[cfg(feature = "NSDecimal")]
149        #[unsafe(method(decimalNumberWithDecimal:))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn decimalNumberWithDecimal(dcm: NSDecimal) -> Retained<NSDecimalNumber>;
152
153        #[cfg(feature = "NSString")]
154        #[unsafe(method(decimalNumberWithString:))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn decimalNumberWithString(
157            number_value: Option<&NSString>,
158        ) -> Retained<NSDecimalNumber>;
159
160        #[cfg(feature = "NSString")]
161        #[unsafe(method(decimalNumberWithString:locale:))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn decimalNumberWithString_locale(
164            number_value: Option<&NSString>,
165            locale: Option<&AnyObject>,
166        ) -> Retained<NSDecimalNumber>;
167
168        #[unsafe(method(zero))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn zero() -> Retained<NSDecimalNumber>;
171
172        #[unsafe(method(one))]
173        #[unsafe(method_family = none)]
174        pub unsafe fn one() -> Retained<NSDecimalNumber>;
175
176        #[unsafe(method(minimumDecimalNumber))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn minimumDecimalNumber() -> Retained<NSDecimalNumber>;
179
180        #[unsafe(method(maximumDecimalNumber))]
181        #[unsafe(method_family = none)]
182        pub unsafe fn maximumDecimalNumber() -> Retained<NSDecimalNumber>;
183
184        #[unsafe(method(notANumber))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn notANumber() -> Retained<NSDecimalNumber>;
187
188        #[unsafe(method(decimalNumberByAdding:))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn decimalNumberByAdding(
191            &self,
192            decimal_number: &NSDecimalNumber,
193        ) -> Retained<NSDecimalNumber>;
194
195        #[unsafe(method(decimalNumberByAdding:withBehavior:))]
196        #[unsafe(method_family = none)]
197        pub unsafe fn decimalNumberByAdding_withBehavior(
198            &self,
199            decimal_number: &NSDecimalNumber,
200            behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
201        ) -> Retained<NSDecimalNumber>;
202
203        #[unsafe(method(decimalNumberBySubtracting:))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn decimalNumberBySubtracting(
206            &self,
207            decimal_number: &NSDecimalNumber,
208        ) -> Retained<NSDecimalNumber>;
209
210        #[unsafe(method(decimalNumberBySubtracting:withBehavior:))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn decimalNumberBySubtracting_withBehavior(
213            &self,
214            decimal_number: &NSDecimalNumber,
215            behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
216        ) -> Retained<NSDecimalNumber>;
217
218        #[unsafe(method(decimalNumberByMultiplyingBy:))]
219        #[unsafe(method_family = none)]
220        pub unsafe fn decimalNumberByMultiplyingBy(
221            &self,
222            decimal_number: &NSDecimalNumber,
223        ) -> Retained<NSDecimalNumber>;
224
225        #[unsafe(method(decimalNumberByMultiplyingBy:withBehavior:))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn decimalNumberByMultiplyingBy_withBehavior(
228            &self,
229            decimal_number: &NSDecimalNumber,
230            behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
231        ) -> Retained<NSDecimalNumber>;
232
233        #[unsafe(method(decimalNumberByDividingBy:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn decimalNumberByDividingBy(
236            &self,
237            decimal_number: &NSDecimalNumber,
238        ) -> Retained<NSDecimalNumber>;
239
240        #[unsafe(method(decimalNumberByDividingBy:withBehavior:))]
241        #[unsafe(method_family = none)]
242        pub unsafe fn decimalNumberByDividingBy_withBehavior(
243            &self,
244            decimal_number: &NSDecimalNumber,
245            behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
246        ) -> Retained<NSDecimalNumber>;
247
248        #[unsafe(method(decimalNumberByRaisingToPower:))]
249        #[unsafe(method_family = none)]
250        pub unsafe fn decimalNumberByRaisingToPower(
251            &self,
252            power: NSUInteger,
253        ) -> Retained<NSDecimalNumber>;
254
255        #[unsafe(method(decimalNumberByRaisingToPower:withBehavior:))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn decimalNumberByRaisingToPower_withBehavior(
258            &self,
259            power: NSUInteger,
260            behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
261        ) -> Retained<NSDecimalNumber>;
262
263        #[unsafe(method(decimalNumberByMultiplyingByPowerOf10:))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn decimalNumberByMultiplyingByPowerOf10(
266            &self,
267            power: c_short,
268        ) -> Retained<NSDecimalNumber>;
269
270        #[unsafe(method(decimalNumberByMultiplyingByPowerOf10:withBehavior:))]
271        #[unsafe(method_family = none)]
272        pub unsafe fn decimalNumberByMultiplyingByPowerOf10_withBehavior(
273            &self,
274            power: c_short,
275            behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
276        ) -> Retained<NSDecimalNumber>;
277
278        #[unsafe(method(decimalNumberByRoundingAccordingToBehavior:))]
279        #[unsafe(method_family = none)]
280        pub unsafe fn decimalNumberByRoundingAccordingToBehavior(
281            &self,
282            behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
283        ) -> Retained<NSDecimalNumber>;
284
285        #[cfg(feature = "NSObjCRuntime")]
286        #[unsafe(method(compare:))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn compare(&self, decimal_number: &NSNumber) -> NSComparisonResult;
289
290        #[unsafe(method(defaultBehavior))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn defaultBehavior() -> Retained<ProtocolObject<dyn NSDecimalNumberBehaviors>>;
293
294        /// Setter for [`defaultBehavior`][Self::defaultBehavior].
295        #[unsafe(method(setDefaultBehavior:))]
296        #[unsafe(method_family = none)]
297        pub unsafe fn setDefaultBehavior(
298            default_behavior: &ProtocolObject<dyn NSDecimalNumberBehaviors>,
299        );
300
301        #[unsafe(method(objCType))]
302        #[unsafe(method_family = none)]
303        pub unsafe fn objCType(&self) -> NonNull<c_char>;
304
305        #[unsafe(method(doubleValue))]
306        #[unsafe(method_family = none)]
307        pub unsafe fn doubleValue(&self) -> c_double;
308    );
309}
310
311/// Methods declared on superclass `NSNumber`.
312#[cfg(feature = "NSValue")]
313impl NSDecimalNumber {
314    extern_methods!(
315        #[cfg(feature = "NSCoder")]
316        #[unsafe(method(initWithCoder:))]
317        #[unsafe(method_family = init)]
318        pub unsafe fn initWithCoder(
319            this: Allocated<Self>,
320            coder: &NSCoder,
321        ) -> Option<Retained<Self>>;
322    );
323}
324
325/// Methods declared on superclass `NSValue`.
326#[cfg(feature = "NSValue")]
327impl NSDecimalNumber {
328    extern_methods!(
329        #[unsafe(method(initWithBytes:objCType:))]
330        #[unsafe(method_family = init)]
331        pub unsafe fn initWithBytes_objCType(
332            this: Allocated<Self>,
333            value: NonNull<c_void>,
334            r#type: NonNull<c_char>,
335        ) -> Retained<Self>;
336    );
337}
338
339/// Methods declared on superclass `NSObject`.
340#[cfg(feature = "NSValue")]
341impl NSDecimalNumber {
342    extern_methods!(
343        #[unsafe(method(init))]
344        #[unsafe(method_family = init)]
345        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
346
347        #[unsafe(method(new))]
348        #[unsafe(method_family = new)]
349        pub unsafe fn new() -> Retained<Self>;
350    );
351}
352
353extern_class!(
354    /// *********    A class for defining common behaviors        ******
355    ///
356    /// See also [Apple's documentation](https://developer.apple.com/documentation/foundation/nsdecimalnumberhandler?language=objc)
357    #[unsafe(super(NSObject))]
358    #[derive(Debug, PartialEq, Eq, Hash)]
359    pub struct NSDecimalNumberHandler;
360);
361
362unsafe impl Send for NSDecimalNumberHandler {}
363
364unsafe impl Sync for NSDecimalNumberHandler {}
365
366#[cfg(feature = "NSObject")]
367unsafe impl NSCoding for NSDecimalNumberHandler {}
368
369unsafe impl NSDecimalNumberBehaviors for NSDecimalNumberHandler {}
370
371unsafe impl NSObjectProtocol for NSDecimalNumberHandler {}
372
373impl NSDecimalNumberHandler {
374    extern_methods!(
375        #[unsafe(method(defaultDecimalNumberHandler))]
376        #[unsafe(method_family = none)]
377        pub unsafe fn defaultDecimalNumberHandler() -> Retained<NSDecimalNumberHandler>;
378
379        #[cfg(feature = "NSDecimal")]
380        #[unsafe(method(initWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:))]
381        #[unsafe(method_family = init)]
382        pub unsafe fn initWithRoundingMode_scale_raiseOnExactness_raiseOnOverflow_raiseOnUnderflow_raiseOnDivideByZero(
383            this: Allocated<Self>,
384            rounding_mode: NSRoundingMode,
385            scale: c_short,
386            exact: bool,
387            overflow: bool,
388            underflow: bool,
389            divide_by_zero: bool,
390        ) -> Retained<Self>;
391
392        #[cfg(feature = "NSDecimal")]
393        #[unsafe(method(decimalNumberHandlerWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:))]
394        #[unsafe(method_family = none)]
395        pub unsafe fn decimalNumberHandlerWithRoundingMode_scale_raiseOnExactness_raiseOnOverflow_raiseOnUnderflow_raiseOnDivideByZero(
396            rounding_mode: NSRoundingMode,
397            scale: c_short,
398            exact: bool,
399            overflow: bool,
400            underflow: bool,
401            divide_by_zero: bool,
402        ) -> Retained<Self>;
403    );
404}
405
406/// Methods declared on superclass `NSObject`.
407impl NSDecimalNumberHandler {
408    extern_methods!(
409        #[unsafe(method(init))]
410        #[unsafe(method_family = init)]
411        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
412
413        #[unsafe(method(new))]
414        #[unsafe(method_family = new)]
415        pub unsafe fn new() -> Retained<Self>;
416    );
417}
418
419/// NSDecimalNumberExtensions.
420/// *********    Extensions to other classes        ******
421#[cfg(feature = "NSValue")]
422impl NSNumber {
423    extern_methods!(
424        #[cfg(feature = "NSDecimal")]
425        #[unsafe(method(decimalValue))]
426        #[unsafe(method_family = none)]
427        pub unsafe fn decimalValue(&self) -> NSDecimal;
428    );
429}
430
431/// NSDecimalNumberScanning.
432#[cfg(feature = "NSScanner")]
433impl NSScanner {
434    extern_methods!(
435        #[cfg(feature = "NSDecimal")]
436        #[unsafe(method(scanDecimal:))]
437        #[unsafe(method_family = none)]
438        pub unsafe fn scanDecimal(&self, dcm: *mut NSDecimal) -> bool;
439    );
440}