From 362ea193421842e5013f4614c81874d62103b6cf Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Tue, 21 Dec 2021 03:01:49 +0100 Subject: [PATCH] Add ffi::NSComparisonResult --- objc2-foundation-sys/src/generated_others_shim.rs | 7 ++++++- objc2-foundation/src/comparison_result.rs | 8 +++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/objc2-foundation-sys/src/generated_others_shim.rs b/objc2-foundation-sys/src/generated_others_shim.rs index 53cc2be53..754fd292c 100644 --- a/objc2-foundation-sys/src/generated_others_shim.rs +++ b/objc2-foundation-sys/src/generated_others_shim.rs @@ -2,13 +2,18 @@ use core::ptr::NonNull; -use objc2::ffi::NSUInteger; +use objc2::ffi::{NSInteger, NSUInteger}; use objc2::rc::{Allocated, Id, Unknown}; use objc2::runtime::Object; use objc2::{class, msg_send, msg_send_id, Encoding, Message, RefEncode}; use crate::{NSCoder, NSObject, NSRange}; +pub const NSComparisonResult_NSOrderedAscending: NSComparisonResult = -1; +pub const NSComparisonResult_NSOrderedSame: NSComparisonResult = 0; +pub const NSComparisonResult_NSOrderedDescending: NSComparisonResult = 1; +pub type NSComparisonResult = NSInteger; + #[repr(transparent)] pub struct NSArray(NSObject); impl core::ops::Deref for NSArray { diff --git a/objc2-foundation/src/comparison_result.rs b/objc2-foundation/src/comparison_result.rs index f276fa732..107bcef59 100644 --- a/objc2-foundation/src/comparison_result.rs +++ b/objc2-foundation/src/comparison_result.rs @@ -2,6 +2,8 @@ use core::cmp::Ordering; use objc2::{Encode, Encoding, RefEncode}; +use crate::ffi; + /// Constants that indicate sort order. /// /// See [Apple's documentation](https://developer.apple.com/documentation/foundation/nscomparisonresult?language=objc). @@ -9,11 +11,11 @@ use objc2::{Encode, Encoding, RefEncode}; #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)] pub enum NSComparisonResult { /// The left operand is smaller than the right operand. - Ascending = -1, + Ascending = ffi::NSComparisonResult_NSOrderedAscending, /// The two operands are equal. - Same = 0, + Same = ffi::NSComparisonResult_NSOrderedSame, /// The left operand is greater than the right operand. - Descending = 1, + Descending = ffi::NSComparisonResult_NSOrderedDescending, } impl Default for NSComparisonResult {