objc2_foundation/generated/
NSDecimal.rs1use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct NSRoundingMode(pub NSUInteger);
16impl NSRoundingMode {
17 #[doc(alias = "NSRoundPlain")]
18 pub const RoundPlain: Self = Self(0);
19 #[doc(alias = "NSRoundDown")]
20 pub const RoundDown: Self = Self(1);
21 #[doc(alias = "NSRoundUp")]
22 pub const RoundUp: Self = Self(2);
23 #[doc(alias = "NSRoundBankers")]
24 pub const RoundBankers: Self = Self(3);
25}
26
27unsafe impl Encode for NSRoundingMode {
28 const ENCODING: Encoding = NSUInteger::ENCODING;
29}
30
31unsafe impl RefEncode for NSRoundingMode {
32 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35#[repr(transparent)]
38#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
39pub struct NSCalculationError(pub NSUInteger);
40impl NSCalculationError {
41 #[doc(alias = "NSCalculationNoError")]
42 pub const NoError: Self = Self(0);
43 #[doc(alias = "NSCalculationLossOfPrecision")]
44 pub const LossOfPrecision: Self = Self(1);
45 #[doc(alias = "NSCalculationUnderflow")]
46 pub const Underflow: Self = Self(2);
47 #[doc(alias = "NSCalculationOverflow")]
48 pub const Overflow: Self = Self(3);
49 #[doc(alias = "NSCalculationDivideByZero")]
50 pub const DivideByZero: Self = Self(4);
51}
52
53unsafe impl Encode for NSCalculationError {
54 const ENCODING: Encoding = NSUInteger::ENCODING;
55}
56
57unsafe impl RefEncode for NSCalculationError {
58 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
59}
60
61impl NSDecimal {
62 #[doc(alias = "NSDecimalCopy")]
66 #[inline]
67 pub unsafe fn copy(destination: NonNull<NSDecimal>, source: NonNull<NSDecimal>) {
68 extern "C-unwind" {
69 fn NSDecimalCopy(destination: NonNull<NSDecimal>, source: NonNull<NSDecimal>);
70 }
71 unsafe { NSDecimalCopy(destination, source) }
72 }
73
74 #[doc(alias = "NSDecimalCompact")]
75 #[inline]
76 pub unsafe fn compact(number: NonNull<NSDecimal>) {
77 extern "C-unwind" {
78 fn NSDecimalCompact(number: NonNull<NSDecimal>);
79 }
80 unsafe { NSDecimalCompact(number) }
81 }
82
83 #[doc(alias = "NSDecimalCompare")]
84 #[cfg(feature = "NSObjCRuntime")]
85 #[inline]
86 pub unsafe fn compare(
87 left_operand: NonNull<NSDecimal>,
88 right_operand: NonNull<NSDecimal>,
89 ) -> NSComparisonResult {
90 extern "C-unwind" {
91 fn NSDecimalCompare(
92 left_operand: NonNull<NSDecimal>,
93 right_operand: NonNull<NSDecimal>,
94 ) -> NSComparisonResult;
95 }
96 unsafe { NSDecimalCompare(left_operand, right_operand) }
97 }
98
99 #[doc(alias = "NSDecimalRound")]
100 #[inline]
101 pub unsafe fn round(
102 result: NonNull<NSDecimal>,
103 number: NonNull<NSDecimal>,
104 scale: NSInteger,
105 rounding_mode: NSRoundingMode,
106 ) {
107 extern "C-unwind" {
108 fn NSDecimalRound(
109 result: NonNull<NSDecimal>,
110 number: NonNull<NSDecimal>,
111 scale: NSInteger,
112 rounding_mode: NSRoundingMode,
113 );
114 }
115 unsafe { NSDecimalRound(result, number, scale, rounding_mode) }
116 }
117
118 #[doc(alias = "NSDecimalNormalize")]
119 #[inline]
120 pub unsafe fn normalize(
121 number1: NonNull<NSDecimal>,
122 number2: NonNull<NSDecimal>,
123 rounding_mode: NSRoundingMode,
124 ) -> NSCalculationError {
125 extern "C-unwind" {
126 fn NSDecimalNormalize(
127 number1: NonNull<NSDecimal>,
128 number2: NonNull<NSDecimal>,
129 rounding_mode: NSRoundingMode,
130 ) -> NSCalculationError;
131 }
132 unsafe { NSDecimalNormalize(number1, number2, rounding_mode) }
133 }
134
135 #[doc(alias = "NSDecimalAdd")]
136 #[inline]
137 pub unsafe fn add(
138 result: NonNull<NSDecimal>,
139 left_operand: NonNull<NSDecimal>,
140 right_operand: NonNull<NSDecimal>,
141 rounding_mode: NSRoundingMode,
142 ) -> NSCalculationError {
143 extern "C-unwind" {
144 fn NSDecimalAdd(
145 result: NonNull<NSDecimal>,
146 left_operand: NonNull<NSDecimal>,
147 right_operand: NonNull<NSDecimal>,
148 rounding_mode: NSRoundingMode,
149 ) -> NSCalculationError;
150 }
151 unsafe { NSDecimalAdd(result, left_operand, right_operand, rounding_mode) }
152 }
153
154 #[doc(alias = "NSDecimalSubtract")]
155 #[inline]
156 pub unsafe fn subtract(
157 result: NonNull<NSDecimal>,
158 left_operand: NonNull<NSDecimal>,
159 right_operand: NonNull<NSDecimal>,
160 rounding_mode: NSRoundingMode,
161 ) -> NSCalculationError {
162 extern "C-unwind" {
163 fn NSDecimalSubtract(
164 result: NonNull<NSDecimal>,
165 left_operand: NonNull<NSDecimal>,
166 right_operand: NonNull<NSDecimal>,
167 rounding_mode: NSRoundingMode,
168 ) -> NSCalculationError;
169 }
170 unsafe { NSDecimalSubtract(result, left_operand, right_operand, rounding_mode) }
171 }
172
173 #[doc(alias = "NSDecimalMultiply")]
174 #[inline]
175 pub unsafe fn multiply(
176 result: NonNull<NSDecimal>,
177 left_operand: NonNull<NSDecimal>,
178 right_operand: NonNull<NSDecimal>,
179 rounding_mode: NSRoundingMode,
180 ) -> NSCalculationError {
181 extern "C-unwind" {
182 fn NSDecimalMultiply(
183 result: NonNull<NSDecimal>,
184 left_operand: NonNull<NSDecimal>,
185 right_operand: NonNull<NSDecimal>,
186 rounding_mode: NSRoundingMode,
187 ) -> NSCalculationError;
188 }
189 unsafe { NSDecimalMultiply(result, left_operand, right_operand, rounding_mode) }
190 }
191
192 #[doc(alias = "NSDecimalDivide")]
193 #[inline]
194 pub unsafe fn divide(
195 result: NonNull<NSDecimal>,
196 left_operand: NonNull<NSDecimal>,
197 right_operand: NonNull<NSDecimal>,
198 rounding_mode: NSRoundingMode,
199 ) -> NSCalculationError {
200 extern "C-unwind" {
201 fn NSDecimalDivide(
202 result: NonNull<NSDecimal>,
203 left_operand: NonNull<NSDecimal>,
204 right_operand: NonNull<NSDecimal>,
205 rounding_mode: NSRoundingMode,
206 ) -> NSCalculationError;
207 }
208 unsafe { NSDecimalDivide(result, left_operand, right_operand, rounding_mode) }
209 }
210
211 #[doc(alias = "NSDecimalPower")]
212 #[inline]
213 pub unsafe fn power(
214 result: NonNull<NSDecimal>,
215 number: NonNull<NSDecimal>,
216 power: NSUInteger,
217 rounding_mode: NSRoundingMode,
218 ) -> NSCalculationError {
219 extern "C-unwind" {
220 fn NSDecimalPower(
221 result: NonNull<NSDecimal>,
222 number: NonNull<NSDecimal>,
223 power: NSUInteger,
224 rounding_mode: NSRoundingMode,
225 ) -> NSCalculationError;
226 }
227 unsafe { NSDecimalPower(result, number, power, rounding_mode) }
228 }
229
230 #[doc(alias = "NSDecimalMultiplyByPowerOf10")]
231 #[inline]
232 pub unsafe fn multiply_by_power_of10(
233 result: NonNull<NSDecimal>,
234 number: NonNull<NSDecimal>,
235 power: c_short,
236 rounding_mode: NSRoundingMode,
237 ) -> NSCalculationError {
238 extern "C-unwind" {
239 fn NSDecimalMultiplyByPowerOf10(
240 result: NonNull<NSDecimal>,
241 number: NonNull<NSDecimal>,
242 power: c_short,
243 rounding_mode: NSRoundingMode,
244 ) -> NSCalculationError;
245 }
246 unsafe { NSDecimalMultiplyByPowerOf10(result, number, power, rounding_mode) }
247 }
248
249 #[doc(alias = "NSDecimalString")]
250 #[cfg(feature = "NSString")]
251 #[inline]
252 pub unsafe fn string(
253 dcm: NonNull<NSDecimal>,
254 locale: Option<&AnyObject>,
255 ) -> Retained<NSString> {
256 extern "C-unwind" {
257 fn NSDecimalString(
258 dcm: NonNull<NSDecimal>,
259 locale: Option<&AnyObject>,
260 ) -> *mut NSString;
261 }
262 let ret = unsafe { NSDecimalString(dcm, locale) };
263 unsafe { Retained::retain_autoreleased(ret) }
264 .expect("function was marked as returning non-null, but actually returned NULL")
265 }
266}
267
268extern "C-unwind" {
269 #[deprecated = "renamed to `NSDecimal::copy`"]
270 pub fn NSDecimalCopy(destination: NonNull<NSDecimal>, source: NonNull<NSDecimal>);
271}
272
273extern "C-unwind" {
274 #[deprecated = "renamed to `NSDecimal::compact`"]
275 pub fn NSDecimalCompact(number: NonNull<NSDecimal>);
276}
277
278extern "C-unwind" {
279 #[cfg(feature = "NSObjCRuntime")]
280 #[deprecated = "renamed to `NSDecimal::compare`"]
281 pub fn NSDecimalCompare(
282 left_operand: NonNull<NSDecimal>,
283 right_operand: NonNull<NSDecimal>,
284 ) -> NSComparisonResult;
285}
286
287extern "C-unwind" {
288 #[deprecated = "renamed to `NSDecimal::round`"]
289 pub fn NSDecimalRound(
290 result: NonNull<NSDecimal>,
291 number: NonNull<NSDecimal>,
292 scale: NSInteger,
293 rounding_mode: NSRoundingMode,
294 );
295}
296
297extern "C-unwind" {
298 #[deprecated = "renamed to `NSDecimal::normalize`"]
299 pub fn NSDecimalNormalize(
300 number1: NonNull<NSDecimal>,
301 number2: NonNull<NSDecimal>,
302 rounding_mode: NSRoundingMode,
303 ) -> NSCalculationError;
304}
305
306extern "C-unwind" {
307 #[deprecated = "renamed to `NSDecimal::add`"]
308 pub fn NSDecimalAdd(
309 result: NonNull<NSDecimal>,
310 left_operand: NonNull<NSDecimal>,
311 right_operand: NonNull<NSDecimal>,
312 rounding_mode: NSRoundingMode,
313 ) -> NSCalculationError;
314}
315
316extern "C-unwind" {
317 #[deprecated = "renamed to `NSDecimal::subtract`"]
318 pub fn NSDecimalSubtract(
319 result: NonNull<NSDecimal>,
320 left_operand: NonNull<NSDecimal>,
321 right_operand: NonNull<NSDecimal>,
322 rounding_mode: NSRoundingMode,
323 ) -> NSCalculationError;
324}
325
326extern "C-unwind" {
327 #[deprecated = "renamed to `NSDecimal::multiply`"]
328 pub fn NSDecimalMultiply(
329 result: NonNull<NSDecimal>,
330 left_operand: NonNull<NSDecimal>,
331 right_operand: NonNull<NSDecimal>,
332 rounding_mode: NSRoundingMode,
333 ) -> NSCalculationError;
334}
335
336extern "C-unwind" {
337 #[deprecated = "renamed to `NSDecimal::divide`"]
338 pub fn NSDecimalDivide(
339 result: NonNull<NSDecimal>,
340 left_operand: NonNull<NSDecimal>,
341 right_operand: NonNull<NSDecimal>,
342 rounding_mode: NSRoundingMode,
343 ) -> NSCalculationError;
344}
345
346extern "C-unwind" {
347 #[deprecated = "renamed to `NSDecimal::power`"]
348 pub fn NSDecimalPower(
349 result: NonNull<NSDecimal>,
350 number: NonNull<NSDecimal>,
351 power: NSUInteger,
352 rounding_mode: NSRoundingMode,
353 ) -> NSCalculationError;
354}
355
356extern "C-unwind" {
357 #[deprecated = "renamed to `NSDecimal::multiply_by_power_of10`"]
358 pub fn NSDecimalMultiplyByPowerOf10(
359 result: NonNull<NSDecimal>,
360 number: NonNull<NSDecimal>,
361 power: c_short,
362 rounding_mode: NSRoundingMode,
363 ) -> NSCalculationError;
364}
365
366#[cfg(feature = "NSString")]
367#[deprecated = "renamed to `NSDecimal::string`"]
368#[inline]
369pub unsafe extern "C-unwind" fn NSDecimalString(
370 dcm: NonNull<NSDecimal>,
371 locale: Option<&AnyObject>,
372) -> Retained<NSString> {
373 extern "C-unwind" {
374 fn NSDecimalString(dcm: NonNull<NSDecimal>, locale: Option<&AnyObject>) -> *mut NSString;
375 }
376 let ret = unsafe { NSDecimalString(dcm, locale) };
377 unsafe { Retained::retain_autoreleased(ret) }
378 .expect("function was marked as returning non-null, but actually returned NULL")
379}