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