Skip to content

Commit

Permalink
Add ffi::NSComparisonResult
Browse files Browse the repository at this point in the history
  • Loading branch information
madsmtm committed Jul 5, 2022
1 parent f549bf5 commit 362ea19
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 6 additions & 1 deletion objc2-foundation-sys/src/generated_others_shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 5 additions & 3 deletions objc2-foundation/src/comparison_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@ 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).
#[repr(isize)] // NSInteger
#[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 {
Expand Down

0 comments on commit 362ea19

Please sign in to comment.