objc2_foundation/generated/
NSDecimalNumber.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9extern "C" {
10 #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
14 pub static NSDecimalNumberExactnessException: &'static NSExceptionName;
15}
16
17extern "C" {
18 #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
20 pub static NSDecimalNumberOverflowException: &'static NSExceptionName;
21}
22
23extern "C" {
24 #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
26 pub static NSDecimalNumberUnderflowException: &'static NSExceptionName;
27}
28
29extern "C" {
30 #[cfg(all(feature = "NSObjCRuntime", feature = "NSString"))]
32 pub static NSDecimalNumberDivideByZeroException: &'static NSExceptionName;
33}
34
35extern_protocol!(
36 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 #[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"))]
77extern_conformance!(
78 unsafe impl NSCoding for NSDecimalNumber {}
79);
80
81#[cfg(all(feature = "NSObject", feature = "NSValue"))]
82extern_conformance!(
83 unsafe impl NSCopying for NSDecimalNumber {}
84);
85
86#[cfg(all(feature = "NSObject", feature = "NSValue"))]
87unsafe impl CopyingHelper for NSDecimalNumber {
88 type Result = Self;
89}
90
91#[cfg(feature = "NSValue")]
92extern_conformance!(
93 unsafe impl NSObjectProtocol for NSDecimalNumber {}
94);
95
96#[cfg(all(feature = "NSObject", feature = "NSValue"))]
97extern_conformance!(
98 unsafe impl NSSecureCoding for NSDecimalNumber {}
99);
100
101#[cfg(feature = "NSValue")]
102impl NSDecimalNumber {
103 extern_methods!(
104 #[unsafe(method(initWithMantissa:exponent:isNegative:))]
105 #[unsafe(method_family = init)]
106 pub unsafe fn initWithMantissa_exponent_isNegative(
107 this: Allocated<Self>,
108 mantissa: c_ulonglong,
109 exponent: c_short,
110 flag: bool,
111 ) -> Retained<Self>;
112
113 #[cfg(feature = "NSDecimal")]
114 #[unsafe(method(initWithDecimal:))]
115 #[unsafe(method_family = init)]
116 pub unsafe fn initWithDecimal(this: Allocated<Self>, dcm: NSDecimal) -> Retained<Self>;
117
118 #[cfg(feature = "NSString")]
119 #[unsafe(method(initWithString:))]
120 #[unsafe(method_family = init)]
121 pub unsafe fn initWithString(
122 this: Allocated<Self>,
123 number_value: Option<&NSString>,
124 ) -> Retained<Self>;
125
126 #[cfg(feature = "NSString")]
127 #[unsafe(method(initWithString:locale:))]
128 #[unsafe(method_family = init)]
129 pub unsafe fn initWithString_locale(
130 this: Allocated<Self>,
131 number_value: Option<&NSString>,
132 locale: Option<&AnyObject>,
133 ) -> Retained<Self>;
134
135 #[cfg(feature = "NSString")]
136 #[unsafe(method(descriptionWithLocale:))]
137 #[unsafe(method_family = none)]
138 pub unsafe fn descriptionWithLocale(
139 &self,
140 locale: Option<&AnyObject>,
141 ) -> Retained<NSString>;
142
143 #[cfg(feature = "NSDecimal")]
144 #[unsafe(method(decimalValue))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn decimalValue(&self) -> NSDecimal;
147
148 #[unsafe(method(decimalNumberWithMantissa:exponent:isNegative:))]
149 #[unsafe(method_family = none)]
150 pub unsafe fn decimalNumberWithMantissa_exponent_isNegative(
151 mantissa: c_ulonglong,
152 exponent: c_short,
153 flag: bool,
154 ) -> Retained<NSDecimalNumber>;
155
156 #[cfg(feature = "NSDecimal")]
157 #[unsafe(method(decimalNumberWithDecimal:))]
158 #[unsafe(method_family = none)]
159 pub unsafe fn decimalNumberWithDecimal(dcm: NSDecimal) -> Retained<NSDecimalNumber>;
160
161 #[cfg(feature = "NSString")]
162 #[unsafe(method(decimalNumberWithString:))]
163 #[unsafe(method_family = none)]
164 pub unsafe fn decimalNumberWithString(
165 number_value: Option<&NSString>,
166 ) -> Retained<NSDecimalNumber>;
167
168 #[cfg(feature = "NSString")]
169 #[unsafe(method(decimalNumberWithString:locale:))]
170 #[unsafe(method_family = none)]
171 pub unsafe fn decimalNumberWithString_locale(
172 number_value: Option<&NSString>,
173 locale: Option<&AnyObject>,
174 ) -> Retained<NSDecimalNumber>;
175
176 #[unsafe(method(zero))]
177 #[unsafe(method_family = none)]
178 pub unsafe fn zero() -> Retained<NSDecimalNumber>;
179
180 #[unsafe(method(one))]
181 #[unsafe(method_family = none)]
182 pub unsafe fn one() -> Retained<NSDecimalNumber>;
183
184 #[unsafe(method(minimumDecimalNumber))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn minimumDecimalNumber() -> Retained<NSDecimalNumber>;
187
188 #[unsafe(method(maximumDecimalNumber))]
189 #[unsafe(method_family = none)]
190 pub unsafe fn maximumDecimalNumber() -> Retained<NSDecimalNumber>;
191
192 #[unsafe(method(notANumber))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn notANumber() -> Retained<NSDecimalNumber>;
195
196 #[unsafe(method(decimalNumberByAdding:))]
197 #[unsafe(method_family = none)]
198 pub unsafe fn decimalNumberByAdding(
199 &self,
200 decimal_number: &NSDecimalNumber,
201 ) -> Retained<NSDecimalNumber>;
202
203 #[unsafe(method(decimalNumberByAdding:withBehavior:))]
204 #[unsafe(method_family = none)]
205 pub unsafe fn decimalNumberByAdding_withBehavior(
206 &self,
207 decimal_number: &NSDecimalNumber,
208 behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
209 ) -> Retained<NSDecimalNumber>;
210
211 #[unsafe(method(decimalNumberBySubtracting:))]
212 #[unsafe(method_family = none)]
213 pub unsafe fn decimalNumberBySubtracting(
214 &self,
215 decimal_number: &NSDecimalNumber,
216 ) -> Retained<NSDecimalNumber>;
217
218 #[unsafe(method(decimalNumberBySubtracting:withBehavior:))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn decimalNumberBySubtracting_withBehavior(
221 &self,
222 decimal_number: &NSDecimalNumber,
223 behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
224 ) -> Retained<NSDecimalNumber>;
225
226 #[unsafe(method(decimalNumberByMultiplyingBy:))]
227 #[unsafe(method_family = none)]
228 pub unsafe fn decimalNumberByMultiplyingBy(
229 &self,
230 decimal_number: &NSDecimalNumber,
231 ) -> Retained<NSDecimalNumber>;
232
233 #[unsafe(method(decimalNumberByMultiplyingBy:withBehavior:))]
234 #[unsafe(method_family = none)]
235 pub unsafe fn decimalNumberByMultiplyingBy_withBehavior(
236 &self,
237 decimal_number: &NSDecimalNumber,
238 behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
239 ) -> Retained<NSDecimalNumber>;
240
241 #[unsafe(method(decimalNumberByDividingBy:))]
242 #[unsafe(method_family = none)]
243 pub unsafe fn decimalNumberByDividingBy(
244 &self,
245 decimal_number: &NSDecimalNumber,
246 ) -> Retained<NSDecimalNumber>;
247
248 #[unsafe(method(decimalNumberByDividingBy:withBehavior:))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn decimalNumberByDividingBy_withBehavior(
251 &self,
252 decimal_number: &NSDecimalNumber,
253 behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
254 ) -> Retained<NSDecimalNumber>;
255
256 #[unsafe(method(decimalNumberByRaisingToPower:))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn decimalNumberByRaisingToPower(
259 &self,
260 power: NSUInteger,
261 ) -> Retained<NSDecimalNumber>;
262
263 #[unsafe(method(decimalNumberByRaisingToPower:withBehavior:))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn decimalNumberByRaisingToPower_withBehavior(
266 &self,
267 power: NSUInteger,
268 behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
269 ) -> Retained<NSDecimalNumber>;
270
271 #[unsafe(method(decimalNumberByMultiplyingByPowerOf10:))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn decimalNumberByMultiplyingByPowerOf10(
274 &self,
275 power: c_short,
276 ) -> Retained<NSDecimalNumber>;
277
278 #[unsafe(method(decimalNumberByMultiplyingByPowerOf10:withBehavior:))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn decimalNumberByMultiplyingByPowerOf10_withBehavior(
281 &self,
282 power: c_short,
283 behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
284 ) -> Retained<NSDecimalNumber>;
285
286 #[unsafe(method(decimalNumberByRoundingAccordingToBehavior:))]
287 #[unsafe(method_family = none)]
288 pub unsafe fn decimalNumberByRoundingAccordingToBehavior(
289 &self,
290 behavior: Option<&ProtocolObject<dyn NSDecimalNumberBehaviors>>,
291 ) -> Retained<NSDecimalNumber>;
292
293 #[cfg(feature = "NSObjCRuntime")]
294 #[unsafe(method(compare:))]
295 #[unsafe(method_family = none)]
296 pub unsafe fn compare(&self, decimal_number: &NSNumber) -> NSComparisonResult;
297
298 #[unsafe(method(defaultBehavior))]
299 #[unsafe(method_family = none)]
300 pub unsafe fn defaultBehavior() -> Retained<ProtocolObject<dyn NSDecimalNumberBehaviors>>;
301
302 #[unsafe(method(setDefaultBehavior:))]
304 #[unsafe(method_family = none)]
305 pub unsafe fn setDefaultBehavior(
306 default_behavior: &ProtocolObject<dyn NSDecimalNumberBehaviors>,
307 );
308
309 #[unsafe(method(objCType))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn objCType(&self) -> NonNull<c_char>;
312
313 #[unsafe(method(doubleValue))]
314 #[unsafe(method_family = none)]
315 pub unsafe fn doubleValue(&self) -> c_double;
316 );
317}
318
319#[cfg(feature = "NSValue")]
321impl NSDecimalNumber {
322 extern_methods!(
323 #[cfg(feature = "NSCoder")]
324 #[unsafe(method(initWithCoder:))]
325 #[unsafe(method_family = init)]
326 pub unsafe fn initWithCoder(
327 this: Allocated<Self>,
328 coder: &NSCoder,
329 ) -> Option<Retained<Self>>;
330 );
331}
332
333#[cfg(feature = "NSValue")]
335impl NSDecimalNumber {
336 extern_methods!(
337 #[unsafe(method(initWithBytes:objCType:))]
338 #[unsafe(method_family = init)]
339 pub unsafe fn initWithBytes_objCType(
340 this: Allocated<Self>,
341 value: NonNull<c_void>,
342 r#type: NonNull<c_char>,
343 ) -> Retained<Self>;
344 );
345}
346
347#[cfg(feature = "NSValue")]
349impl NSDecimalNumber {
350 extern_methods!(
351 #[unsafe(method(init))]
352 #[unsafe(method_family = init)]
353 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
354
355 #[unsafe(method(new))]
356 #[unsafe(method_family = new)]
357 pub unsafe fn new() -> Retained<Self>;
358 );
359}
360
361extern_class!(
362 #[unsafe(super(NSObject))]
366 #[derive(Debug, PartialEq, Eq, Hash)]
367 pub struct NSDecimalNumberHandler;
368);
369
370unsafe impl Send for NSDecimalNumberHandler {}
371
372unsafe impl Sync for NSDecimalNumberHandler {}
373
374#[cfg(feature = "NSObject")]
375extern_conformance!(
376 unsafe impl NSCoding for NSDecimalNumberHandler {}
377);
378
379extern_conformance!(
380 unsafe impl NSDecimalNumberBehaviors for NSDecimalNumberHandler {}
381);
382
383extern_conformance!(
384 unsafe impl NSObjectProtocol for NSDecimalNumberHandler {}
385);
386
387impl NSDecimalNumberHandler {
388 extern_methods!(
389 #[unsafe(method(defaultDecimalNumberHandler))]
390 #[unsafe(method_family = none)]
391 pub unsafe fn defaultDecimalNumberHandler() -> Retained<NSDecimalNumberHandler>;
392
393 #[cfg(feature = "NSDecimal")]
394 #[unsafe(method(initWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:))]
395 #[unsafe(method_family = init)]
396 pub unsafe fn initWithRoundingMode_scale_raiseOnExactness_raiseOnOverflow_raiseOnUnderflow_raiseOnDivideByZero(
397 this: Allocated<Self>,
398 rounding_mode: NSRoundingMode,
399 scale: c_short,
400 exact: bool,
401 overflow: bool,
402 underflow: bool,
403 divide_by_zero: bool,
404 ) -> Retained<Self>;
405
406 #[cfg(feature = "NSDecimal")]
407 #[unsafe(method(decimalNumberHandlerWithRoundingMode:scale:raiseOnExactness:raiseOnOverflow:raiseOnUnderflow:raiseOnDivideByZero:))]
408 #[unsafe(method_family = none)]
409 pub unsafe fn decimalNumberHandlerWithRoundingMode_scale_raiseOnExactness_raiseOnOverflow_raiseOnUnderflow_raiseOnDivideByZero(
410 rounding_mode: NSRoundingMode,
411 scale: c_short,
412 exact: bool,
413 overflow: bool,
414 underflow: bool,
415 divide_by_zero: bool,
416 ) -> Retained<Self>;
417 );
418}
419
420impl NSDecimalNumberHandler {
422 extern_methods!(
423 #[unsafe(method(init))]
424 #[unsafe(method_family = init)]
425 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
426
427 #[unsafe(method(new))]
428 #[unsafe(method_family = new)]
429 pub unsafe fn new() -> Retained<Self>;
430 );
431}
432
433#[cfg(feature = "NSValue")]
436impl NSNumber {
437 extern_methods!(
438 #[cfg(feature = "NSDecimal")]
439 #[unsafe(method(decimalValue))]
440 #[unsafe(method_family = none)]
441 pub unsafe fn decimalValue(&self) -> NSDecimal;
442 );
443}
444
445#[cfg(feature = "NSScanner")]
447impl NSScanner {
448 extern_methods!(
449 #[cfg(feature = "NSDecimal")]
450 #[unsafe(method(scanDecimal:))]
451 #[unsafe(method_family = none)]
452 pub unsafe fn scanDecimal(&self, dcm: *mut NSDecimal) -> bool;
453 );
454}