@@ -105,14 +105,16 @@ pub type BOOL = inner::BOOL;
105
105
//
106
106
// Likewise for NSUInteger.
107
107
//
108
+ //
108
109
// ## GNUStep / WinObjC
109
110
//
110
111
// Defined as intptr_t/uintptr_t, which is exactly the same as isize/usize.
111
112
//
113
+ //
112
114
// ## ObjFW
113
115
//
114
- // Doesn't define these, but e.g. ` OFString - length` returns size_t, so our
115
- // definitions are should be correct on effectively all targets.
116
+ // Doesn't define these, but e.g. -[ OFString length] returns size_t, so our
117
+ // definitions should be correct on effectively all targets.
116
118
//
117
119
// Things might change slightly in the future, see
118
120
// <https://internals.rust-lang.org/t/pre-rfc-usize-is-not-size-t/15369>.
@@ -127,15 +129,23 @@ pub type BOOL = inner::BOOL;
127
129
///
128
130
/// [docs]: https://developer.apple.com/documentation/objectivec/nsinteger?language=objc
129
131
///
132
+ ///
130
133
/// # Examples
131
134
///
132
135
/// ```
133
- /// #[repr(isize)] // NSInteger
136
+ /// use core::mem::size_of;
137
+ /// # use objc_sys::NSInteger;
138
+ /// # #[cfg(not_available)]
139
+ /// use objc2::ffi::NSInteger;
140
+ ///
141
+ /// #[repr(isize)]
134
142
/// pub enum NSComparisonResult {
135
143
/// NSOrderedAscending = -1,
136
144
/// NSOrderedSame = 0,
137
145
/// NSOrderedDescending = 1,
138
146
/// }
147
+ ///
148
+ /// assert_eq!(size_of::<NSComparisonResult>(), size_of::<NSInteger>());
139
149
/// ```
140
150
pub type NSInteger = isize ;
141
151
@@ -149,36 +159,43 @@ pub type NSInteger = isize;
149
159
///
150
160
/// [docs]: https://developer.apple.com/documentation/objectivec/nsuinteger?language=objc
151
161
///
162
+ ///
152
163
/// # Examples
153
164
///
154
165
/// ```
155
- /// use objc_sys::NSUInteger;
156
- /// // Or:
157
- /// // use objc2::ffi::NSUInteger;
158
- /// // use icrate::Foundation::NSUInteger;
166
+ /// # use objc_sys::NSUInteger;
167
+ /// # #[cfg(not_available)]
168
+ /// use objc2::ffi::NSUInteger;
169
+ ///
159
170
/// extern "C" {
160
171
/// fn some_external_function() -> NSUInteger;
161
172
/// }
162
173
/// ```
163
174
///
164
175
/// ```
165
- /// #[repr(usize)] // NSUInteger
166
- /// enum NSRoundingMode {
167
- /// NSRoundPlain = 0,
168
- /// NSRoundDown = 1,
169
- /// NSRoundUp = 2,
170
- /// NSRoundBankers = 3,
171
- /// };
176
+ /// use core::mem::size_of;
177
+ /// # use objc_sys::NSUInteger;
178
+ /// # #[cfg(not_available)]
179
+ /// use objc2::ffi::NSUInteger;
180
+ ///
181
+ /// #[repr(usize)]
182
+ /// enum CLRegionState {
183
+ /// Unknown = 0,
184
+ /// Inside = 1,
185
+ /// Outside = 2,
186
+ /// }
187
+ ///
188
+ /// assert_eq!(size_of::<CLRegionState>(), size_of::<NSUInteger>());
172
189
/// ```
173
190
pub type NSUInteger = usize ;
174
191
175
- /// The maximum value for an NSInteger.
192
+ /// The maximum value for a [` NSInteger`] .
176
193
pub const NSIntegerMax : NSInteger = NSInteger :: MAX ;
177
194
178
- /// The minimum value for an NSInteger.
195
+ /// The minimum value for a [` NSInteger`] .
179
196
pub const NSIntegerMin : NSInteger = NSInteger :: MIN ;
180
197
181
- /// The maximum value for an NSUInteger.
198
+ /// The maximum value for a [` NSUInteger`] .
182
199
pub const NSUIntegerMax : NSUInteger = NSUInteger :: MAX ;
183
200
184
201
/// An immutable pointer to a selector.
@@ -189,7 +206,9 @@ pub type SEL = *const objc_selector;
189
206
190
207
/// A mutable pointer to an object / instance.
191
208
///
192
- /// Type alias provided for convenience. See `objc2::runtime::Object` for a
193
- /// higher level binding, and `objc2::rc::Id` for an easier way of handling
194
- /// objects.
209
+ /// Type alias provided for convenience. You'll likely want to use one of:
210
+ /// - `icrate::Foundation::NS[...]` for when you know the class of the object
211
+ /// you're dealing with.
212
+ /// - `objc2::rc::Id` for a proper way of doing memory management.
213
+ /// - `objc2::runtime::Object` for a bit safer representation of this.
195
214
pub type id = * mut objc_object ;
0 commit comments