summaryrefslogtreecommitdiffstats
path: root/vendor/core-foundation-sys/src/number.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:02:58 +0000
commit698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch)
tree173a775858bd501c378080a10dca74132f05bc50 /vendor/core-foundation-sys/src/number.rs
parentInitial commit. (diff)
downloadrustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz
rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/core-foundation-sys/src/number.rs')
-rw-r--r--vendor/core-foundation-sys/src/number.rs84
1 files changed, 84 insertions, 0 deletions
diff --git a/vendor/core-foundation-sys/src/number.rs b/vendor/core-foundation-sys/src/number.rs
new file mode 100644
index 000000000..c056a245b
--- /dev/null
+++ b/vendor/core-foundation-sys/src/number.rs
@@ -0,0 +1,84 @@
+// Copyright 2013-2015 The Servo Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use std::os::raw::c_void;
+
+use base::{CFAllocatorRef, CFTypeID, CFComparisonResult};
+
+#[repr(C)]
+pub struct __CFBoolean(c_void);
+
+pub type CFBooleanRef = *const __CFBoolean;
+
+pub type CFNumberType = u32;
+
+// members of enum CFNumberType
+pub const kCFNumberSInt8Type: CFNumberType = 1;
+pub const kCFNumberSInt16Type: CFNumberType = 2;
+pub const kCFNumberSInt32Type: CFNumberType = 3;
+pub const kCFNumberSInt64Type: CFNumberType = 4;
+pub const kCFNumberFloat32Type: CFNumberType = 5;
+pub const kCFNumberFloat64Type: CFNumberType = 6;
+pub const kCFNumberCharType: CFNumberType = 7;
+pub const kCFNumberShortType: CFNumberType = 8;
+pub const kCFNumberIntType: CFNumberType = 9;
+pub const kCFNumberLongType: CFNumberType = 10;
+pub const kCFNumberLongLongType: CFNumberType = 11;
+pub const kCFNumberFloatType: CFNumberType = 12;
+pub const kCFNumberDoubleType: CFNumberType = 13;
+pub const kCFNumberCFIndexType: CFNumberType = 14;
+pub const kCFNumberNSIntegerType: CFNumberType = 15;
+pub const kCFNumberCGFloatType: CFNumberType = 16;
+pub const kCFNumberMaxType: CFNumberType = 16;
+
+// This is an enum due to zero-sized types warnings.
+// For more details see https://github.com/rust-lang/rust/issues/27303
+pub enum __CFNumber {}
+
+pub type CFNumberRef = *const __CFNumber;
+
+extern {
+ /*
+ * CFNumber.h
+ */
+ pub static kCFBooleanTrue: CFBooleanRef;
+ pub static kCFBooleanFalse: CFBooleanRef;
+
+ pub fn CFBooleanGetTypeID() -> CFTypeID;
+ pub fn CFBooleanGetValue(boolean: CFBooleanRef) -> bool;
+
+ pub fn CFNumberCreate(allocator: CFAllocatorRef, theType: CFNumberType, valuePtr: *const c_void)
+ -> CFNumberRef;
+ //fn CFNumberGetByteSize
+ pub fn CFNumberGetValue(number: CFNumberRef, theType: CFNumberType, valuePtr: *mut c_void) -> bool;
+ pub fn CFNumberCompare(date: CFNumberRef, other: CFNumberRef, context: *mut c_void) -> CFComparisonResult;
+ pub fn CFNumberGetTypeID() -> CFTypeID;
+ pub fn CFNumberGetType(number: CFNumberRef) -> CFNumberType;
+}
+
+#[cfg(test)]
+mod test {
+ use super::*;
+
+ #[test]
+ fn match_for_type_id_should_be_backwards_compatible() {
+ let type_id = kCFNumberFloat32Type;
+ // this is the old style of matching for static variables
+ match type_id {
+ vf64 if vf64 == kCFNumberFloat32Type => assert!(true),
+ _ => panic!("should not happen"),
+ };
+
+ // this is new new style of matching for consts
+ match type_id {
+ kCFNumberFloat32Type => assert!(true),
+ _ => panic!("should not happen"),
+ };
+ }
+}