1 // Copyright 2013 The Servo Project Developers. See the COPYRIGHT 2 // file at the top-level directory of this distribution. 3 // 4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 7 // option. This file may not be copied, modified, or distributed 8 // except according to those terms. 9 10 #![allow(non_upper_case_globals)] 11 12 use std::ptr; 13 use std::os::raw::c_void; 14 use base::{id, BOOL, NO, SEL, nil}; 15 use block::Block; 16 use libc; 17 18 19 #[cfg(target_pointer_width = "32")] 20 pub type NSInteger = libc::c_int; 21 #[cfg(target_pointer_width = "32")] 22 pub type NSUInteger = libc::c_uint; 23 24 #[cfg(target_pointer_width = "64")] 25 pub type NSInteger = libc::c_long; 26 #[cfg(target_pointer_width = "64")] 27 pub type NSUInteger = libc::c_ulong; 28 29 pub const NSIntegerMax: NSInteger = NSInteger::max_value(); 30 pub const NSNotFound: NSInteger = NSIntegerMax; 31 32 const UTF8_ENCODING: usize = 4; 33 34 #[cfg(target_os = "macos")] 35 mod macos { 36 use std::mem; 37 use base::id; 38 use core_graphics_types::base::CGFloat; 39 use core_graphics_types::geometry::CGRect; 40 use objc; 41 42 #[repr(C)] 43 #[derive(Copy, Clone)] 44 pub struct NSPoint { 45 pub x: CGFloat, 46 pub y: CGFloat, 47 } 48 49 impl NSPoint { 50 #[inline] new(x: CGFloat, y: CGFloat) -> NSPoint51 pub fn new(x: CGFloat, y: CGFloat) -> NSPoint { 52 NSPoint { 53 x: x, 54 y: y, 55 } 56 } 57 } 58 59 unsafe impl objc::Encode for NSPoint { encode() -> objc::Encoding60 fn encode() -> objc::Encoding { 61 let encoding = format!("{{CGPoint={}{}}}", 62 CGFloat::encode().as_str(), 63 CGFloat::encode().as_str()); 64 unsafe { objc::Encoding::from_str(&encoding) } 65 } 66 } 67 68 #[repr(C)] 69 #[derive(Copy, Clone)] 70 pub struct NSSize { 71 pub width: CGFloat, 72 pub height: CGFloat, 73 } 74 75 impl NSSize { 76 #[inline] new(width: CGFloat, height: CGFloat) -> NSSize77 pub fn new(width: CGFloat, height: CGFloat) -> NSSize { 78 NSSize { 79 width: width, 80 height: height, 81 } 82 } 83 } 84 85 unsafe impl objc::Encode for NSSize { encode() -> objc::Encoding86 fn encode() -> objc::Encoding { 87 let encoding = format!("{{CGSize={}{}}}", 88 CGFloat::encode().as_str(), 89 CGFloat::encode().as_str()); 90 unsafe { objc::Encoding::from_str(&encoding) } 91 } 92 } 93 94 #[repr(C)] 95 #[derive(Copy, Clone)] 96 pub struct NSRect { 97 pub origin: NSPoint, 98 pub size: NSSize, 99 } 100 101 impl NSRect { 102 #[inline] new(origin: NSPoint, size: NSSize) -> NSRect103 pub fn new(origin: NSPoint, size: NSSize) -> NSRect { 104 NSRect { 105 origin: origin, 106 size: size 107 } 108 } 109 110 #[inline] as_CGRect(&self) -> &CGRect111 pub fn as_CGRect(&self) -> &CGRect { 112 unsafe { 113 mem::transmute::<&NSRect, &CGRect>(self) 114 } 115 } 116 117 #[inline] inset(&self, x: CGFloat, y: CGFloat) -> NSRect118 pub fn inset(&self, x: CGFloat, y: CGFloat) -> NSRect { 119 unsafe { 120 NSInsetRect(*self, x, y) 121 } 122 } 123 } 124 125 unsafe impl objc::Encode for NSRect { encode() -> objc::Encoding126 fn encode() -> objc::Encoding { 127 let encoding = format!("{{CGRect={}{}}}", 128 NSPoint::encode().as_str(), 129 NSSize::encode().as_str()); 130 unsafe { objc::Encoding::from_str(&encoding) } 131 } 132 } 133 134 // Same as CGRectEdge 135 #[repr(u32)] 136 pub enum NSRectEdge { 137 NSRectMinXEdge, 138 NSRectMinYEdge, 139 NSRectMaxXEdge, 140 NSRectMaxYEdge, 141 } 142 143 #[link(name = "Foundation", kind = "framework")] 144 extern { NSInsetRect(rect: NSRect, x: CGFloat, y: CGFloat) -> NSRect145 fn NSInsetRect(rect: NSRect, x: CGFloat, y: CGFloat) -> NSRect; 146 } 147 148 pub trait NSValue: Sized { valueWithPoint(_: Self, point: NSPoint) -> id149 unsafe fn valueWithPoint(_: Self, point: NSPoint) -> id { 150 msg_send![class!(NSValue), valueWithPoint:point] 151 } 152 valueWithSize(_: Self, size: NSSize) -> id153 unsafe fn valueWithSize(_: Self, size: NSSize) -> id { 154 msg_send![class!(NSValue), valueWithSize:size] 155 } 156 } 157 158 impl NSValue for id { 159 } 160 } 161 162 #[cfg(target_os = "macos")] 163 pub use self::macos::*; 164 165 #[repr(C)] 166 #[derive(Copy, Clone)] 167 pub struct NSRange { 168 pub location: NSUInteger, 169 pub length: NSUInteger, 170 } 171 172 impl NSRange { 173 #[inline] new(location: NSUInteger, length: NSUInteger) -> NSRange174 pub fn new(location: NSUInteger, length: NSUInteger) -> NSRange { 175 NSRange { 176 location: location, 177 length: length 178 } 179 } 180 } 181 182 #[link(name = "Foundation", kind = "framework")] 183 extern { 184 pub static NSDefaultRunLoopMode: id; 185 } 186 187 pub trait NSAutoreleasePool: Sized { new(_: Self) -> id188 unsafe fn new(_: Self) -> id { 189 msg_send![class!(NSAutoreleasePool), new] 190 } 191 autorelease(self) -> Self192 unsafe fn autorelease(self) -> Self; drain(self)193 unsafe fn drain(self); 194 } 195 196 impl NSAutoreleasePool for id { autorelease(self) -> id197 unsafe fn autorelease(self) -> id { 198 msg_send![self, autorelease] 199 } 200 drain(self)201 unsafe fn drain(self) { 202 msg_send![self, drain] 203 } 204 } 205 206 207 #[repr(C)] 208 #[derive(Copy, Clone)] 209 pub struct NSOperatingSystemVersion { 210 pub majorVersion: NSUInteger, 211 pub minorVersion: NSUInteger, 212 pub patchVersion: NSUInteger, 213 } 214 215 impl NSOperatingSystemVersion { 216 #[inline] new(majorVersion: NSUInteger, minorVersion: NSUInteger, patchVersion: NSUInteger) -> NSOperatingSystemVersion217 pub fn new(majorVersion: NSUInteger, minorVersion: NSUInteger, patchVersion: NSUInteger) -> NSOperatingSystemVersion { 218 NSOperatingSystemVersion { 219 majorVersion: majorVersion, 220 minorVersion: minorVersion, 221 patchVersion: patchVersion 222 } 223 } 224 } 225 226 227 pub trait NSProcessInfo: Sized { processInfo(_: Self) -> id228 unsafe fn processInfo(_: Self) -> id { 229 msg_send![class!(NSProcessInfo), processInfo] 230 } 231 processName(self) -> id232 unsafe fn processName(self) -> id; operatingSystemVersion(self) -> NSOperatingSystemVersion233 unsafe fn operatingSystemVersion(self) -> NSOperatingSystemVersion; isOperatingSystemAtLeastVersion(self, version: NSOperatingSystemVersion) -> bool234 unsafe fn isOperatingSystemAtLeastVersion(self, version: NSOperatingSystemVersion) -> bool; 235 } 236 237 impl NSProcessInfo for id { processName(self) -> id238 unsafe fn processName(self) -> id { 239 msg_send![self, processName] 240 } 241 operatingSystemVersion(self) -> NSOperatingSystemVersion242 unsafe fn operatingSystemVersion(self) -> NSOperatingSystemVersion { 243 msg_send![self, operatingSystemVersion] 244 } 245 isOperatingSystemAtLeastVersion(self, version: NSOperatingSystemVersion) -> bool246 unsafe fn isOperatingSystemAtLeastVersion(self, version: NSOperatingSystemVersion) -> bool { 247 msg_send![self, isOperatingSystemAtLeastVersion: version] 248 } 249 } 250 251 pub type NSTimeInterval = libc::c_double; 252 253 pub trait NSArray: Sized { array(_: Self) -> id254 unsafe fn array(_: Self) -> id { 255 msg_send![class!(NSArray), array] 256 } 257 arrayWithObjects(_: Self, objects: &[id]) -> id258 unsafe fn arrayWithObjects(_: Self, objects: &[id]) -> id { 259 msg_send![class!(NSArray), arrayWithObjects:objects.as_ptr() 260 count:objects.len()] 261 } 262 arrayWithObject(_: Self, object: id) -> id263 unsafe fn arrayWithObject(_: Self, object: id) -> id { 264 msg_send![class!(NSArray), arrayWithObject:object] 265 } 266 init(self) -> id267 unsafe fn init(self) -> id; 268 count(self) -> NSUInteger269 unsafe fn count(self) -> NSUInteger; 270 arrayByAddingObjectFromArray(self, object: id) -> id271 unsafe fn arrayByAddingObjectFromArray(self, object: id) -> id; arrayByAddingObjectsFromArray(self, objects: id) -> id272 unsafe fn arrayByAddingObjectsFromArray(self, objects: id) -> id; objectAtIndex(self, index: NSUInteger) -> id273 unsafe fn objectAtIndex(self, index: NSUInteger) -> id; 274 } 275 276 impl NSArray for id { init(self) -> id277 unsafe fn init(self) -> id { 278 msg_send![self, init] 279 } 280 count(self) -> NSUInteger281 unsafe fn count(self) -> NSUInteger { 282 msg_send![self, count] 283 } 284 arrayByAddingObjectFromArray(self, object: id) -> id285 unsafe fn arrayByAddingObjectFromArray(self, object: id) -> id { 286 msg_send![self, arrayByAddingObjectFromArray:object] 287 } 288 arrayByAddingObjectsFromArray(self, objects: id) -> id289 unsafe fn arrayByAddingObjectsFromArray(self, objects: id) -> id { 290 msg_send![self, arrayByAddingObjectsFromArray:objects] 291 } 292 objectAtIndex(self, index: NSUInteger) -> id293 unsafe fn objectAtIndex(self, index: NSUInteger) -> id { 294 msg_send![self, objectAtIndex:index] 295 } 296 } 297 298 pub trait NSDictionary: Sized { dictionary(_: Self) -> id299 unsafe fn dictionary(_: Self) -> id { 300 msg_send![class!(NSDictionary), dictionary] 301 } 302 dictionaryWithContentsOfFile_(_: Self, path: id) -> id303 unsafe fn dictionaryWithContentsOfFile_(_: Self, path: id) -> id { 304 msg_send![class!(NSDictionary), dictionaryWithContentsOfFile:path] 305 } 306 dictionaryWithContentsOfURL_(_: Self, aURL: id) -> id307 unsafe fn dictionaryWithContentsOfURL_(_: Self, aURL: id) -> id { 308 msg_send![class!(NSDictionary), dictionaryWithContentsOfURL:aURL] 309 } 310 dictionaryWithDictionary_(_: Self, otherDictionary: id) -> id311 unsafe fn dictionaryWithDictionary_(_: Self, otherDictionary: id) -> id { 312 msg_send![class!(NSDictionary), dictionaryWithDictionary:otherDictionary] 313 } 314 dictionaryWithObject_forKey_(_: Self, anObject: id, aKey: id) -> id315 unsafe fn dictionaryWithObject_forKey_(_: Self, anObject: id, aKey: id) -> id { 316 msg_send![class!(NSDictionary), dictionaryWithObject:anObject forKey:aKey] 317 } 318 dictionaryWithObjects_forKeys_(_: Self, objects: id, keys: id) -> id319 unsafe fn dictionaryWithObjects_forKeys_(_: Self, objects: id, keys: id) -> id { 320 msg_send![class!(NSDictionary), dictionaryWithObjects:objects forKeys:keys] 321 } 322 dictionaryWithObjects_forKeys_count_(_: Self, objects: *const id, keys: *const id, count: NSUInteger) -> id323 unsafe fn dictionaryWithObjects_forKeys_count_(_: Self, objects: *const id, keys: *const id, count: NSUInteger) -> id { 324 msg_send![class!(NSDictionary), dictionaryWithObjects:objects forKeys:keys count:count] 325 } 326 dictionaryWithObjectsAndKeys_(_: Self, firstObject: id) -> id327 unsafe fn dictionaryWithObjectsAndKeys_(_: Self, firstObject: id) -> id { 328 msg_send![class!(NSDictionary), dictionaryWithObjectsAndKeys:firstObject] 329 } 330 init(self) -> id331 unsafe fn init(self) -> id; initWithContentsOfFile_(self, path: id) -> id332 unsafe fn initWithContentsOfFile_(self, path: id) -> id; initWithContentsOfURL_(self, aURL: id) -> id333 unsafe fn initWithContentsOfURL_(self, aURL: id) -> id; initWithDictionary_(self, otherDicitonary: id) -> id334 unsafe fn initWithDictionary_(self, otherDicitonary: id) -> id; initWithDictionary_copyItems_(self, otherDicitonary: id, flag: BOOL) -> id335 unsafe fn initWithDictionary_copyItems_(self, otherDicitonary: id, flag: BOOL) -> id; initWithObjects_forKeys_(self, objects: id, keys: id) -> id336 unsafe fn initWithObjects_forKeys_(self, objects: id, keys: id) -> id; initWithObjects_forKeys_count_(self, objects: id, keys: id, count: NSUInteger) -> id337 unsafe fn initWithObjects_forKeys_count_(self, objects: id, keys: id, count: NSUInteger) -> id; initWithObjectsAndKeys_(self, firstObject: id) -> id338 unsafe fn initWithObjectsAndKeys_(self, firstObject: id) -> id; 339 sharedKeySetForKeys_(_: Self, keys: id) -> id340 unsafe fn sharedKeySetForKeys_(_: Self, keys: id) -> id { 341 msg_send![class!(NSDictionary), sharedKeySetForKeys:keys] 342 } 343 count(self) -> NSUInteger344 unsafe fn count(self) -> NSUInteger; 345 isEqualToDictionary_(self, otherDictionary: id) -> BOOL346 unsafe fn isEqualToDictionary_(self, otherDictionary: id) -> BOOL; 347 allKeys(self) -> id348 unsafe fn allKeys(self) -> id; allKeysForObject_(self, anObject: id) -> id349 unsafe fn allKeysForObject_(self, anObject: id) -> id; allValues(self) -> id350 unsafe fn allValues(self) -> id; objectForKey_(self, aKey: id) -> id351 unsafe fn objectForKey_(self, aKey: id) -> id; objectForKeyedSubscript_(self, key: id) -> id352 unsafe fn objectForKeyedSubscript_(self, key: id) -> id; objectsForKeys_notFoundMarker_(self, keys: id, anObject: id) -> id353 unsafe fn objectsForKeys_notFoundMarker_(self, keys: id, anObject: id) -> id; valueForKey_(self, key: id) -> id354 unsafe fn valueForKey_(self, key: id) -> id; 355 keyEnumerator(self) -> id356 unsafe fn keyEnumerator(self) -> id; objectEnumerator(self) -> id357 unsafe fn objectEnumerator(self) -> id; enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut BOOL), ()>)358 unsafe fn enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut BOOL), ()>); enumerateKeysAndObjectsWithOptions_usingBlock_(self, opts: NSEnumerationOptions, block: *mut Block<(id, id, *mut BOOL), ()>)359 unsafe fn enumerateKeysAndObjectsWithOptions_usingBlock_(self, opts: NSEnumerationOptions, 360 block: *mut Block<(id, id, *mut BOOL), ()>); 361 keysSortedByValueUsingSelector_(self, comparator: SEL) -> id362 unsafe fn keysSortedByValueUsingSelector_(self, comparator: SEL) -> id; keysSortedByValueUsingComparator_(self, cmptr: NSComparator) -> id363 unsafe fn keysSortedByValueUsingComparator_(self, cmptr: NSComparator) -> id; keysSortedByValueWithOptions_usingComparator_(self, opts: NSEnumerationOptions, cmptr: NSComparator) -> id364 unsafe fn keysSortedByValueWithOptions_usingComparator_(self, opts: NSEnumerationOptions, cmptr: NSComparator) -> id; 365 keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id366 unsafe fn keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id; keysOfEntriesWithOptions_PassingTest_(self, opts: NSEnumerationOptions, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id367 unsafe fn keysOfEntriesWithOptions_PassingTest_(self, opts: NSEnumerationOptions, 368 predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id; 369 writeToFile_atomically_(self, path: id, flag: BOOL) -> BOOL370 unsafe fn writeToFile_atomically_(self, path: id, flag: BOOL) -> BOOL; writeToURL_atomically_(self, aURL: id, flag: BOOL) -> BOOL371 unsafe fn writeToURL_atomically_(self, aURL: id, flag: BOOL) -> BOOL; 372 fileCreationDate(self) -> id373 unsafe fn fileCreationDate(self) -> id; fileExtensionHidden(self) -> BOOL374 unsafe fn fileExtensionHidden(self) -> BOOL; fileGroupOwnerAccountID(self) -> id375 unsafe fn fileGroupOwnerAccountID(self) -> id; fileGroupOwnerAccountName(self) -> id376 unsafe fn fileGroupOwnerAccountName(self) -> id; fileIsAppendOnly(self) -> BOOL377 unsafe fn fileIsAppendOnly(self) -> BOOL; fileIsImmutable(self) -> BOOL378 unsafe fn fileIsImmutable(self) -> BOOL; fileModificationDate(self) -> id379 unsafe fn fileModificationDate(self) -> id; fileOwnerAccountID(self) -> id380 unsafe fn fileOwnerAccountID(self) -> id; fileOwnerAccountName(self) -> id381 unsafe fn fileOwnerAccountName(self) -> id; filePosixPermissions(self) -> NSUInteger382 unsafe fn filePosixPermissions(self) -> NSUInteger; fileSize(self) -> libc::c_ulonglong383 unsafe fn fileSize(self) -> libc::c_ulonglong; fileSystemFileNumber(self) -> NSUInteger384 unsafe fn fileSystemFileNumber(self) -> NSUInteger; fileSystemNumber(self) -> NSInteger385 unsafe fn fileSystemNumber(self) -> NSInteger; fileType(self) -> id386 unsafe fn fileType(self) -> id; 387 description(self) -> id388 unsafe fn description(self) -> id; descriptionInStringsFileFormat(self) -> id389 unsafe fn descriptionInStringsFileFormat(self) -> id; descriptionWithLocale_(self, locale: id) -> id390 unsafe fn descriptionWithLocale_(self, locale: id) -> id; descriptionWithLocale_indent_(self, locale: id, indent: NSUInteger) -> id391 unsafe fn descriptionWithLocale_indent_(self, locale: id, indent: NSUInteger) -> id; 392 } 393 394 impl NSDictionary for id { init(self) -> id395 unsafe fn init(self) -> id { 396 msg_send![self, init] 397 } 398 initWithContentsOfFile_(self, path: id) -> id399 unsafe fn initWithContentsOfFile_(self, path: id) -> id { 400 msg_send![self, initWithContentsOfFile:path] 401 } 402 initWithContentsOfURL_(self, aURL: id) -> id403 unsafe fn initWithContentsOfURL_(self, aURL: id) -> id { 404 msg_send![self, initWithContentsOfURL:aURL] 405 } 406 initWithDictionary_(self, otherDictionary: id) -> id407 unsafe fn initWithDictionary_(self, otherDictionary: id) -> id { 408 msg_send![self, initWithDictionary:otherDictionary] 409 } 410 initWithDictionary_copyItems_(self, otherDictionary: id, flag: BOOL) -> id411 unsafe fn initWithDictionary_copyItems_(self, otherDictionary: id, flag: BOOL) -> id { 412 msg_send![self, initWithDictionary:otherDictionary copyItems:flag] 413 } 414 initWithObjects_forKeys_(self, objects: id, keys: id) -> id415 unsafe fn initWithObjects_forKeys_(self, objects: id, keys: id) -> id { 416 msg_send![self, initWithObjects:objects forKeys:keys] 417 } 418 initWithObjects_forKeys_count_(self, objects: id, keys: id, count: NSUInteger) -> id419 unsafe fn initWithObjects_forKeys_count_(self, objects: id, keys: id, count: NSUInteger) -> id { 420 msg_send![self, initWithObjects:objects forKeys:keys count:count] 421 } 422 initWithObjectsAndKeys_(self, firstObject: id) -> id423 unsafe fn initWithObjectsAndKeys_(self, firstObject: id) -> id { 424 msg_send![self, initWithObjectsAndKeys:firstObject] 425 } 426 count(self) -> NSUInteger427 unsafe fn count(self) -> NSUInteger { 428 msg_send![self, count] 429 } 430 isEqualToDictionary_(self, otherDictionary: id) -> BOOL431 unsafe fn isEqualToDictionary_(self, otherDictionary: id) -> BOOL { 432 msg_send![self, isEqualToDictionary:otherDictionary] 433 } 434 allKeys(self) -> id435 unsafe fn allKeys(self) -> id { 436 msg_send![self, allKeys] 437 } 438 allKeysForObject_(self, anObject: id) -> id439 unsafe fn allKeysForObject_(self, anObject: id) -> id { 440 msg_send![self, allKeysForObject:anObject] 441 } 442 allValues(self) -> id443 unsafe fn allValues(self) -> id { 444 msg_send![self, allValues] 445 } 446 objectForKey_(self, aKey: id) -> id447 unsafe fn objectForKey_(self, aKey: id) -> id { 448 msg_send![self, objectForKey:aKey] 449 } 450 objectForKeyedSubscript_(self, key: id) -> id451 unsafe fn objectForKeyedSubscript_(self, key: id) -> id { 452 msg_send![self, objectForKeyedSubscript:key] 453 } 454 objectsForKeys_notFoundMarker_(self, keys: id, anObject: id) -> id455 unsafe fn objectsForKeys_notFoundMarker_(self, keys: id, anObject: id) -> id { 456 msg_send![self, objectsForKeys:keys notFoundMarker:anObject] 457 } 458 valueForKey_(self, key: id) -> id459 unsafe fn valueForKey_(self, key: id) -> id { 460 msg_send![self, valueForKey:key] 461 } 462 keyEnumerator(self) -> id463 unsafe fn keyEnumerator(self) -> id { 464 msg_send![self, keyEnumerator] 465 } 466 objectEnumerator(self) -> id467 unsafe fn objectEnumerator(self) -> id { 468 msg_send![self, objectEnumerator] 469 } 470 enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut BOOL), ()>)471 unsafe fn enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut BOOL), ()>) { 472 msg_send![self, enumerateKeysAndObjectsUsingBlock:block] 473 } 474 enumerateKeysAndObjectsWithOptions_usingBlock_(self, opts: NSEnumerationOptions, block: *mut Block<(id, id, *mut BOOL), ()>)475 unsafe fn enumerateKeysAndObjectsWithOptions_usingBlock_(self, opts: NSEnumerationOptions, 476 block: *mut Block<(id, id, *mut BOOL), ()>) { 477 msg_send![self, enumerateKeysAndObjectsWithOptions:opts usingBlock:block] 478 } 479 keysSortedByValueUsingSelector_(self, comparator: SEL) -> id480 unsafe fn keysSortedByValueUsingSelector_(self, comparator: SEL) -> id { 481 msg_send![self, keysSortedByValueUsingSelector:comparator] 482 } 483 keysSortedByValueUsingComparator_(self, cmptr: NSComparator) -> id484 unsafe fn keysSortedByValueUsingComparator_(self, cmptr: NSComparator) -> id { 485 msg_send![self, keysSortedByValueUsingComparator:cmptr] 486 } 487 keysSortedByValueWithOptions_usingComparator_(self, opts: NSEnumerationOptions, cmptr: NSComparator) -> id488 unsafe fn keysSortedByValueWithOptions_usingComparator_(self, opts: NSEnumerationOptions, cmptr: NSComparator) -> id { 489 let rv: id = msg_send![self, keysSortedByValueWithOptions:opts usingComparator:cmptr]; 490 rv 491 } 492 keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id493 unsafe fn keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id { 494 msg_send![self, keysOfEntriesPassingTest:predicate] 495 } 496 keysOfEntriesWithOptions_PassingTest_(self, opts: NSEnumerationOptions, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id497 unsafe fn keysOfEntriesWithOptions_PassingTest_(self, opts: NSEnumerationOptions, 498 predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id { 499 msg_send![self, keysOfEntriesWithOptions:opts PassingTest:predicate] 500 } 501 writeToFile_atomically_(self, path: id, flag: BOOL) -> BOOL502 unsafe fn writeToFile_atomically_(self, path: id, flag: BOOL) -> BOOL { 503 msg_send![self, writeToFile:path atomically:flag] 504 } 505 writeToURL_atomically_(self, aURL: id, flag: BOOL) -> BOOL506 unsafe fn writeToURL_atomically_(self, aURL: id, flag: BOOL) -> BOOL { 507 msg_send![self, writeToURL:aURL atomically:flag] 508 } 509 fileCreationDate(self) -> id510 unsafe fn fileCreationDate(self) -> id { 511 msg_send![self, fileCreationDate] 512 } 513 fileExtensionHidden(self) -> BOOL514 unsafe fn fileExtensionHidden(self) -> BOOL { 515 msg_send![self, fileExtensionHidden] 516 } 517 fileGroupOwnerAccountID(self) -> id518 unsafe fn fileGroupOwnerAccountID(self) -> id { 519 msg_send![self, fileGroupOwnerAccountID] 520 } 521 fileGroupOwnerAccountName(self) -> id522 unsafe fn fileGroupOwnerAccountName(self) -> id { 523 msg_send![self, fileGroupOwnerAccountName] 524 } 525 fileIsAppendOnly(self) -> BOOL526 unsafe fn fileIsAppendOnly(self) -> BOOL { 527 msg_send![self, fileIsAppendOnly] 528 } 529 fileIsImmutable(self) -> BOOL530 unsafe fn fileIsImmutable(self) -> BOOL { 531 msg_send![self, fileIsImmutable] 532 } 533 fileModificationDate(self) -> id534 unsafe fn fileModificationDate(self) -> id { 535 msg_send![self, fileModificationDate] 536 } 537 fileOwnerAccountID(self) -> id538 unsafe fn fileOwnerAccountID(self) -> id { 539 msg_send![self, fileOwnerAccountID] 540 } 541 fileOwnerAccountName(self) -> id542 unsafe fn fileOwnerAccountName(self) -> id { 543 msg_send![self, fileOwnerAccountName] 544 } 545 filePosixPermissions(self) -> NSUInteger546 unsafe fn filePosixPermissions(self) -> NSUInteger { 547 msg_send![self, filePosixPermissions] 548 } 549 fileSize(self) -> libc::c_ulonglong550 unsafe fn fileSize(self) -> libc::c_ulonglong { 551 msg_send![self, fileSize] 552 } 553 fileSystemFileNumber(self) -> NSUInteger554 unsafe fn fileSystemFileNumber(self) -> NSUInteger { 555 msg_send![self, fileSystemFileNumber] 556 } 557 fileSystemNumber(self) -> NSInteger558 unsafe fn fileSystemNumber(self) -> NSInteger { 559 msg_send![self, fileSystemNumber] 560 } 561 fileType(self) -> id562 unsafe fn fileType(self) -> id { 563 msg_send![self, fileType] 564 } 565 description(self) -> id566 unsafe fn description(self) -> id { 567 msg_send![self, description] 568 } 569 descriptionInStringsFileFormat(self) -> id570 unsafe fn descriptionInStringsFileFormat(self) -> id { 571 msg_send![self, descriptionInStringsFileFormat] 572 } 573 descriptionWithLocale_(self, locale: id) -> id574 unsafe fn descriptionWithLocale_(self, locale: id) -> id { 575 msg_send![self, descriptionWithLocale:locale] 576 } 577 descriptionWithLocale_indent_(self, locale: id, indent: NSUInteger) -> id578 unsafe fn descriptionWithLocale_indent_(self, locale: id, indent: NSUInteger) -> id { 579 msg_send![self, descriptionWithLocale:locale indent:indent] 580 } 581 } 582 583 bitflags! { 584 pub struct NSEnumerationOptions: libc::c_ulonglong { 585 const NSEnumerationConcurrent = 1 << 0; 586 const NSEnumerationReverse = 1 << 1; 587 } 588 } 589 590 pub type NSComparator = *mut Block<(id, id), NSComparisonResult>; 591 592 #[repr(isize)] 593 #[derive(Clone, Copy, Debug, Eq, PartialEq)] 594 pub enum NSComparisonResult { 595 NSOrderedAscending = -1, 596 NSOrderedSame = 0, 597 NSOrderedDescending = 1 598 } 599 600 pub trait NSString: Sized { alloc(_: Self) -> id601 unsafe fn alloc(_: Self) -> id { 602 msg_send![class!(NSString), alloc] 603 } 604 stringByAppendingString_(self, other: id) -> id605 unsafe fn stringByAppendingString_(self, other: id) -> id; init_str(self, string: &str) -> Self606 unsafe fn init_str(self, string: &str) -> Self; UTF8String(self) -> *const libc::c_char607 unsafe fn UTF8String(self) -> *const libc::c_char; len(self) -> usize608 unsafe fn len(self) -> usize; isEqualToString(self, &str) -> bool609 unsafe fn isEqualToString(self, &str) -> bool; substringWithRange(self, range: NSRange) -> id610 unsafe fn substringWithRange(self, range: NSRange) -> id; 611 } 612 613 impl NSString for id { isEqualToString(self, other: &str) -> bool614 unsafe fn isEqualToString(self, other: &str) -> bool { 615 let other = NSString::alloc(nil).init_str(other); 616 let rv: BOOL = msg_send![self, isEqualToString:other]; 617 rv != NO 618 } 619 stringByAppendingString_(self, other: id) -> id620 unsafe fn stringByAppendingString_(self, other: id) -> id { 621 msg_send![self, stringByAppendingString:other] 622 } 623 init_str(self, string: &str) -> id624 unsafe fn init_str(self, string: &str) -> id { 625 return msg_send![self, 626 initWithBytes:string.as_ptr() 627 length:string.len() 628 encoding:UTF8_ENCODING as id]; 629 } 630 len(self) -> usize631 unsafe fn len(self) -> usize { 632 msg_send![self, lengthOfBytesUsingEncoding:UTF8_ENCODING] 633 } 634 UTF8String(self) -> *const libc::c_char635 unsafe fn UTF8String(self) -> *const libc::c_char { 636 msg_send![self, UTF8String] 637 } 638 substringWithRange(self, range: NSRange) -> id639 unsafe fn substringWithRange(self, range: NSRange) -> id { 640 msg_send![self, substringWithRange:range] 641 } 642 } 643 644 pub trait NSDate: Sized { distantPast(_: Self) -> id645 unsafe fn distantPast(_: Self) -> id { 646 msg_send![class!(NSDate), distantPast] 647 } 648 distantFuture(_: Self) -> id649 unsafe fn distantFuture(_: Self) -> id { 650 msg_send![class!(NSDate), distantFuture] 651 } 652 } 653 654 impl NSDate for id { 655 656 } 657 658 #[repr(C)] 659 struct NSFastEnumerationState { 660 pub state: libc::c_ulong, 661 pub items_ptr: *mut id, 662 pub mutations_ptr: *mut libc::c_ulong, 663 pub extra: [libc::c_ulong; 5] 664 } 665 666 const NS_FAST_ENUM_BUF_SIZE: usize = 16; 667 668 pub struct NSFastIterator { 669 state: NSFastEnumerationState, 670 buffer: [id; NS_FAST_ENUM_BUF_SIZE], 671 mut_val: Option<libc::c_ulong>, 672 len: usize, 673 idx: usize, 674 object: id 675 } 676 677 impl Iterator for NSFastIterator { 678 type Item = id; 679 next(&mut self) -> Option<id>680 fn next(&mut self) -> Option<id> { 681 if self.idx >= self.len { 682 self.len = unsafe { 683 msg_send![self.object, countByEnumeratingWithState:&mut self.state objects:self.buffer.as_mut_ptr() count:NS_FAST_ENUM_BUF_SIZE] 684 }; 685 self.idx = 0; 686 } 687 688 let new_mut = unsafe { 689 *self.state.mutations_ptr 690 }; 691 692 if let Some(old_mut) = self.mut_val { 693 assert!(old_mut == new_mut, "The collection was mutated while being enumerated"); 694 } 695 696 if self.idx < self.len { 697 let object = unsafe { 698 *self.state.items_ptr.offset(self.idx as isize) 699 }; 700 self.mut_val = Some(new_mut); 701 self.idx += 1; 702 Some(object) 703 } else { 704 None 705 } 706 } 707 } 708 709 pub trait NSFastEnumeration: Sized { iter(self) -> NSFastIterator710 unsafe fn iter(self) -> NSFastIterator; 711 } 712 713 impl NSFastEnumeration for id { iter(self) -> NSFastIterator714 unsafe fn iter(self) -> NSFastIterator { 715 NSFastIterator { 716 state: NSFastEnumerationState { 717 state: 0, 718 items_ptr: ptr::null_mut(), 719 mutations_ptr: ptr::null_mut(), 720 extra: [0; 5] 721 }, 722 buffer: [nil; NS_FAST_ENUM_BUF_SIZE], 723 mut_val: None, 724 len: 0, 725 idx: 0, 726 object: self 727 } 728 } 729 } 730 731 pub trait NSRunLoop: Sized { currentRunLoop() -> Self732 unsafe fn currentRunLoop() -> Self; 733 performSelector_target_argument_order_modes_(self, aSelector: SEL, target: id, anArgument: id, order: NSUInteger, modes: id)734 unsafe fn performSelector_target_argument_order_modes_(self, 735 aSelector: SEL, 736 target: id, 737 anArgument: id, 738 order: NSUInteger, 739 modes: id); 740 } 741 742 impl NSRunLoop for id { currentRunLoop() -> id743 unsafe fn currentRunLoop() -> id { 744 msg_send![class!(NSRunLoop), currentRunLoop] 745 } 746 performSelector_target_argument_order_modes_(self, aSelector: SEL, target: id, anArgument: id, order: NSUInteger, modes: id)747 unsafe fn performSelector_target_argument_order_modes_(self, 748 aSelector: SEL, 749 target: id, 750 anArgument: id, 751 order: NSUInteger, 752 modes: id) { 753 msg_send![self, performSelector:aSelector 754 target:target 755 argument:anArgument 756 order:order 757 modes:modes] 758 } 759 } 760 761 bitflags! { 762 pub struct NSURLBookmarkCreationOptions: NSUInteger { 763 const NSURLBookmarkCreationPreferFileIDResolution = 1 << 8; 764 const NSURLBookmarkCreationMinimalBookmark = 1 << 9; 765 const NSURLBookmarkCreationSuitableForBookmarkFile = 1 << 10; 766 const NSURLBookmarkCreationWithSecurityScope = 1 << 11; 767 const NSURLBookmarkCreationSecurityScopeAllowOnlyReadAccess = 1 << 12; 768 } 769 } 770 771 pub type NSURLBookmarkFileCreationOptions = NSURLBookmarkCreationOptions; 772 773 bitflags! { 774 pub struct NSURLBookmarkResolutionOptions: NSUInteger { 775 const NSURLBookmarkResolutionWithoutUI = 1 << 8; 776 const NSURLBookmarkResolutionWithoutMounting = 1 << 9; 777 const NSURLBookmarkResolutionWithSecurityScope = 1 << 10; 778 } 779 } 780 781 782 pub trait NSURL: Sized { alloc(_: Self) -> id783 unsafe fn alloc(_: Self) -> id; 784 URLWithString_(_:Self, string: id) -> id785 unsafe fn URLWithString_(_:Self, string: id) -> id; initWithString_(self, string: id) -> id786 unsafe fn initWithString_(self, string: id) -> id; URLWithString_relativeToURL_(_:Self, string: id, url: id) -> id787 unsafe fn URLWithString_relativeToURL_(_:Self, string: id, url: id) -> id; initWithString_relativeToURL_(self, string: id, url: id) -> id788 unsafe fn initWithString_relativeToURL_(self, string: id, url: id) -> id; fileURLWithPath_isDirectory_(_:Self, path: id, is_dir: BOOL) -> id789 unsafe fn fileURLWithPath_isDirectory_(_:Self, path: id, is_dir: BOOL) -> id; initFileURLWithPath_isDirectory_(self, path: id, is_dir: BOOL) -> id790 unsafe fn initFileURLWithPath_isDirectory_(self, path: id, is_dir: BOOL) -> id; fileURLWithPath_relativeToURL_(_:Self, path: id, url: id) -> id791 unsafe fn fileURLWithPath_relativeToURL_(_:Self, path: id, url: id) -> id; initFileURLWithPath_relativeToURL_(self, path: id, url: id) -> id792 unsafe fn initFileURLWithPath_relativeToURL_(self, path: id, url: id) -> id; fileURLWithPath_isDirectory_relativeToURL_(_:Self, path: id, is_dir: BOOL, url: id) -> id793 unsafe fn fileURLWithPath_isDirectory_relativeToURL_(_:Self, path: id, is_dir: BOOL, url: id) -> id; initFileURLWithPath_isDirectory_relativeToURL_(self, path: id, is_dir: BOOL, url: id) -> id794 unsafe fn initFileURLWithPath_isDirectory_relativeToURL_(self, path: id, is_dir: BOOL, url: id) -> id; fileURLWithPath_(_:Self, path: id) -> id795 unsafe fn fileURLWithPath_(_:Self, path: id) -> id; initFileURLWithPath_(self, path: id) -> id796 unsafe fn initFileURLWithPath_(self, path: id) -> id; fileURLWithPathComponents_(_:Self, path_components: id ) -> id797 unsafe fn fileURLWithPathComponents_(_:Self, path_components: id /* (NSArray<NSString*>*) */) -> id; URLByResolvingAliasFileAtURL_options_error_(_:Self, url: id, options: NSURLBookmarkResolutionOptions, error: *mut id ) -> id798 unsafe fn URLByResolvingAliasFileAtURL_options_error_(_:Self, url: id, options: NSURLBookmarkResolutionOptions, error: *mut id /* (NSError _Nullable) */) -> id; URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(_:Self, data: id , options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id ) -> id799 unsafe fn URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(_:Self, data: id /* (NSData) */, options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id /* (NSError _Nullable) */) -> id; initByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(self, data: id , options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id ) -> id800 unsafe fn initByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(self, data: id /* (NSData) */, options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id /* (NSError _Nullable) */) -> id; 801 // unsafe fn fileURLWithFileSystemRepresentation_isDirectory_relativeToURL_ 802 // unsafe fn getFileSystemRepresentation_maxLength_ 803 // unsafe fn initFileURLWithFileSystemRepresentation_isDirectory_relativeToURL_ absoluteURLWithDataRepresentation_relativeToURL_(_:Self, data: id , url: id) -> id804 unsafe fn absoluteURLWithDataRepresentation_relativeToURL_(_:Self, data: id /* (NSData) */, url: id) -> id; initAbsoluteURLWithDataRepresentation_relativeToURL_(self, data: id , url: id) -> id805 unsafe fn initAbsoluteURLWithDataRepresentation_relativeToURL_(self, data: id /* (NSData) */, url: id) -> id; URLWithDataRepresentation_relativeToURL_(_:Self, data: id , url: id) -> id806 unsafe fn URLWithDataRepresentation_relativeToURL_(_:Self, data: id /* (NSData) */, url: id) -> id; initWithDataRepresentation_relativeToURL_(self, data: id , url: id) -> id807 unsafe fn initWithDataRepresentation_relativeToURL_(self, data: id /* (NSData) */, url: id) -> id; dataRepresentation(self) -> id808 unsafe fn dataRepresentation(self) -> id /* (NSData) */; 809 isEqual_(self, id: id) -> BOOL810 unsafe fn isEqual_(self, id: id) -> BOOL; 811 checkResourceIsReachableAndReturnError_(self, error: id ) -> BOOL812 unsafe fn checkResourceIsReachableAndReturnError_(self, error: id /* (NSError _Nullable) */) -> BOOL; isFileReferenceURL(self) -> BOOL813 unsafe fn isFileReferenceURL(self) -> BOOL; isFileURL(self) -> BOOL814 unsafe fn isFileURL(self) -> BOOL; 815 absoluteString(self) -> id816 unsafe fn absoluteString(self) -> id /* (NSString) */; absoluteURL(self) -> id817 unsafe fn absoluteURL(self) -> id /* (NSURL) */; baseURL(self) -> id818 unsafe fn baseURL(self) -> id /* (NSURL) */; 819 // unsafe fn fileSystemRepresentation fragment(self) -> id820 unsafe fn fragment(self) -> id /* (NSString) */; host(self) -> id821 unsafe fn host(self) -> id /* (NSString) */; lastPathComponent(self) -> id822 unsafe fn lastPathComponent(self) -> id /* (NSString) */; parameterString(self) -> id823 unsafe fn parameterString(self) -> id /* (NSString) */; password(self) -> id824 unsafe fn password(self) -> id /* (NSString) */; path(self) -> id825 unsafe fn path(self) -> id /* (NSString) */; pathComponents(self) -> id826 unsafe fn pathComponents(self) -> id /* (NSArray<NSString*>) */; pathExtension(self) -> id827 unsafe fn pathExtension(self) -> id /* (NSString) */; port(self) -> id828 unsafe fn port(self) -> id /* (NSNumber) */; query(self) -> id829 unsafe fn query(self) -> id /* (NSString) */; relativePath(self) -> id830 unsafe fn relativePath(self) -> id /* (NSString) */; relativeString(self) -> id831 unsafe fn relativeString(self) -> id /* (NSString) */; resourceSpecifier(self) -> id832 unsafe fn resourceSpecifier(self) -> id /* (NSString) */; scheme(self) -> id833 unsafe fn scheme(self) -> id /* (NSString) */; standardizedURL(self) -> id834 unsafe fn standardizedURL(self) -> id /* (NSURL) */; user(self) -> id835 unsafe fn user(self) -> id /* (NSString) */; 836 837 // unsafe fn resourceValuesForKeys_error_ 838 // unsafe fn getResourceValue_forKey_error_ 839 // unsafe fn setResourceValue_forKey_error_ 840 // unsafe fn setResourceValues_error_ 841 // unsafe fn removeAllCachedResourceValues 842 // unsafe fn removeCachedResourceValueForKey_ 843 // unsafe fn setTemporaryResourceValue_forKey_ NSURLResourceKey(self) -> id844 unsafe fn NSURLResourceKey(self) -> id /* (NSString) */; 845 filePathURL(self) -> id846 unsafe fn filePathURL(self) -> id; fileReferenceURL(self) -> id847 unsafe fn fileReferenceURL(self) -> id; URLByAppendingPathComponent_(self, path_component: id ) -> id848 unsafe fn URLByAppendingPathComponent_(self, path_component: id /* (NSString) */) -> id; URLByAppendingPathComponent_isDirectory_(self, path_component: id , is_dir: BOOL) -> id849 unsafe fn URLByAppendingPathComponent_isDirectory_(self, path_component: id /* (NSString) */, is_dir: BOOL) -> id; URLByAppendingPathExtension_(self, extension: id ) -> id850 unsafe fn URLByAppendingPathExtension_(self, extension: id /* (NSString) */) -> id; URLByDeletingLastPathComponent(self) -> id851 unsafe fn URLByDeletingLastPathComponent(self) -> id; URLByDeletingPathExtension(self) -> id852 unsafe fn URLByDeletingPathExtension(self) -> id; URLByResolvingSymlinksInPath(self) -> id853 unsafe fn URLByResolvingSymlinksInPath(self) -> id; URLByStandardizingPath(self) -> id854 unsafe fn URLByStandardizingPath(self) -> id; hasDirectoryPath(self) -> BOOL855 unsafe fn hasDirectoryPath(self) -> BOOL; 856 bookmarkDataWithContentsOfURL_error_(_:Self, url: id, error: id ) -> id857 unsafe fn bookmarkDataWithContentsOfURL_error_(_:Self, url: id, error: id /* (NSError _Nullable) */) -> id /* (NSData) */; bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_(self, options: NSURLBookmarkCreationOptions, resource_value_for_keys: id , relative_to_url: id, error: id ) -> id858 unsafe fn bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_(self, options: NSURLBookmarkCreationOptions, resource_value_for_keys: id /* (NSArray<NSURLResourceKey>) */, relative_to_url: id, error: id /* (NSError _Nullable) */) -> id /* (NSData) */; 859 // unsafe fn resourceValuesForKeys_fromBookmarkData_ writeBookmarkData_toURL_options_error_(_:Self, data: id , to_url: id, options: NSURLBookmarkFileCreationOptions, error: id ) -> id860 unsafe fn writeBookmarkData_toURL_options_error_(_:Self, data: id /* (NSData) */, to_url: id, options: NSURLBookmarkFileCreationOptions, error: id /* (NSError _Nullable) */) -> id; startAccessingSecurityScopedResource(self) -> BOOL861 unsafe fn startAccessingSecurityScopedResource(self) -> BOOL; stopAccessingSecurityScopedResource(self)862 unsafe fn stopAccessingSecurityScopedResource(self); NSURLBookmarkFileCreationOptions(self) -> NSURLBookmarkFileCreationOptions863 unsafe fn NSURLBookmarkFileCreationOptions(self) -> NSURLBookmarkFileCreationOptions; NSURLBookmarkCreationOptions(self) -> NSURLBookmarkCreationOptions864 unsafe fn NSURLBookmarkCreationOptions(self) -> NSURLBookmarkCreationOptions; NSURLBookmarkResolutionOptions(self) -> NSURLBookmarkResolutionOptions865 unsafe fn NSURLBookmarkResolutionOptions(self) -> NSURLBookmarkResolutionOptions; 866 867 // unsafe fn checkPromisedItemIsReachableAndReturnError_ 868 // unsafe fn getPromisedItemResourceValue_forKey_error_ 869 // unsafe fn promisedItemResourceValuesForKeys_error_ 870 871 // unsafe fn URLFromPasteboard_ 872 // unsafe fn writeToPasteboard_ 873 } 874 875 impl NSURL for id { alloc(_: Self) -> id876 unsafe fn alloc(_: Self) -> id { 877 msg_send![class!(NSURL), alloc] 878 } 879 URLWithString_(_:Self, string: id) -> id880 unsafe fn URLWithString_(_:Self, string: id) -> id { 881 msg_send![class!(NSURL), URLWithString:string] 882 } initWithString_(self, string: id) -> id883 unsafe fn initWithString_(self, string: id) -> id { 884 msg_send![self, initWithString:string] 885 } URLWithString_relativeToURL_(_:Self, string: id, url: id) -> id886 unsafe fn URLWithString_relativeToURL_(_:Self, string: id, url: id) -> id { 887 msg_send![class!(NSURL), URLWithString: string relativeToURL:url] 888 } initWithString_relativeToURL_(self, string: id, url: id) -> id889 unsafe fn initWithString_relativeToURL_(self, string: id, url: id) -> id { 890 msg_send![self, initWithString:string relativeToURL:url] 891 } fileURLWithPath_isDirectory_(_:Self, path: id, is_dir: BOOL) -> id892 unsafe fn fileURLWithPath_isDirectory_(_:Self, path: id, is_dir: BOOL) -> id { 893 msg_send![class!(NSURL), fileURLWithPath:path isDirectory:is_dir] 894 } initFileURLWithPath_isDirectory_(self, path: id, is_dir: BOOL) -> id895 unsafe fn initFileURLWithPath_isDirectory_(self, path: id, is_dir: BOOL) -> id { 896 msg_send![self, initFileURLWithPath:path isDirectory:is_dir] 897 } fileURLWithPath_relativeToURL_(_:Self, path: id, url: id) -> id898 unsafe fn fileURLWithPath_relativeToURL_(_:Self, path: id, url: id) -> id { 899 msg_send![class!(NSURL), fileURLWithPath:path relativeToURL:url] 900 } initFileURLWithPath_relativeToURL_(self, path: id, url: id) -> id901 unsafe fn initFileURLWithPath_relativeToURL_(self, path: id, url: id) -> id { 902 msg_send![self, initFileURLWithPath:path relativeToURL:url] 903 } fileURLWithPath_isDirectory_relativeToURL_(_:Self, path: id, is_dir: BOOL, url: id) -> id904 unsafe fn fileURLWithPath_isDirectory_relativeToURL_(_:Self, path: id, is_dir: BOOL, url: id) -> id { 905 msg_send![class!(NSURL), fileURLWithPath:path isDirectory:is_dir relativeToURL:url] 906 } initFileURLWithPath_isDirectory_relativeToURL_(self, path: id, is_dir: BOOL, url: id) -> id907 unsafe fn initFileURLWithPath_isDirectory_relativeToURL_(self, path: id, is_dir: BOOL, url: id) -> id { 908 msg_send![self, initFileURLWithPath:path isDirectory:is_dir relativeToURL:url] 909 } fileURLWithPath_(_:Self, path: id) -> id910 unsafe fn fileURLWithPath_(_:Self, path: id) -> id { 911 msg_send![class!(NSURL), fileURLWithPath:path] 912 } initFileURLWithPath_(self, path: id) -> id913 unsafe fn initFileURLWithPath_(self, path: id) -> id { 914 msg_send![self, initFileURLWithPath:path] 915 } fileURLWithPathComponents_(_:Self, path_components: id ) -> id916 unsafe fn fileURLWithPathComponents_(_:Self, path_components: id /* (NSArray<NSString*>*) */) -> id { 917 msg_send![class!(NSURL), fileURLWithPathComponents:path_components] 918 } URLByResolvingAliasFileAtURL_options_error_(_:Self, url: id, options: NSURLBookmarkResolutionOptions, error: *mut id ) -> id919 unsafe fn URLByResolvingAliasFileAtURL_options_error_(_:Self, url: id, options: NSURLBookmarkResolutionOptions, error: *mut id /* (NSError _Nullable) */) -> id { 920 msg_send![class!(NSURL), URLByResolvingAliasFileAtURL:url options:options error:error] 921 } URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(_:Self, data: id , options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id ) -> id922 unsafe fn URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(_:Self, data: id /* (NSData) */, options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id /* (NSError _Nullable) */) -> id { 923 msg_send![class!(NSURL), URLByResolvingBookmarkData:data options:options relativeToURL:relative_to_url bookmarkDataIsStale:is_stale error:error] 924 } initByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(self, data: id , options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id ) -> id925 unsafe fn initByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(self, data: id /* (NSData) */, options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id /* (NSError _Nullable) */) -> id { 926 msg_send![self, initByResolvingBookmarkData:data options:options relativeToURL:relative_to_url bookmarkDataIsStale:is_stale error:error] 927 } 928 // unsafe fn fileURLWithFileSystemRepresentation_isDirectory_relativeToURL_ 929 // unsafe fn getFileSystemRepresentation_maxLength_ 930 // unsafe fn initFileURLWithFileSystemRepresentation_isDirectory_relativeToURL_ absoluteURLWithDataRepresentation_relativeToURL_(_:Self, data: id , url: id) -> id931 unsafe fn absoluteURLWithDataRepresentation_relativeToURL_(_:Self, data: id /* (NSData) */, url: id) -> id { 932 msg_send![class!(NSURL), absoluteURLWithDataRepresentation:data relativeToURL:url] 933 } initAbsoluteURLWithDataRepresentation_relativeToURL_(self, data: id , url: id) -> id934 unsafe fn initAbsoluteURLWithDataRepresentation_relativeToURL_(self, data: id /* (NSData) */, url: id) -> id { 935 msg_send![self, initAbsoluteURLWithDataRepresentation:data relativeToURL:url] 936 } URLWithDataRepresentation_relativeToURL_(_:Self, data: id , url: id) -> id937 unsafe fn URLWithDataRepresentation_relativeToURL_(_:Self, data: id /* (NSData) */, url: id) -> id { 938 msg_send![class!(NSURL), URLWithDataRepresentation:data relativeToURL:url] 939 } initWithDataRepresentation_relativeToURL_(self, data: id , url: id) -> id940 unsafe fn initWithDataRepresentation_relativeToURL_(self, data: id /* (NSData) */, url: id) -> id { 941 msg_send![self, initWithDataRepresentation:data relativeToURL:url] 942 } dataRepresentation(self) -> id943 unsafe fn dataRepresentation(self) -> id /* (NSData) */ { 944 msg_send![self, dataRepresentation] 945 } 946 isEqual_(self, id: id) -> BOOL947 unsafe fn isEqual_(self, id: id) -> BOOL { 948 msg_send![self, isEqual:id] 949 } 950 checkResourceIsReachableAndReturnError_(self, error: id ) -> BOOL951 unsafe fn checkResourceIsReachableAndReturnError_(self, error: id /* (NSError _Nullable) */) -> BOOL { 952 msg_send![self, checkResourceIsReachableAndReturnError:error] 953 } isFileReferenceURL(self) -> BOOL954 unsafe fn isFileReferenceURL(self) -> BOOL { 955 msg_send![self, isFileReferenceURL] 956 } isFileURL(self) -> BOOL957 unsafe fn isFileURL(self) -> BOOL { 958 msg_send![self, isFileURL] 959 } 960 absoluteString(self) -> id961 unsafe fn absoluteString(self) -> id /* (NSString) */ { 962 msg_send![self, absoluteString] 963 } absoluteURL(self) -> id964 unsafe fn absoluteURL(self) -> id /* (NSURL) */ { 965 msg_send![self, absoluteURL] 966 } baseURL(self) -> id967 unsafe fn baseURL(self) -> id /* (NSURL) */ { 968 msg_send![self, baseURL] 969 } 970 // unsafe fn fileSystemRepresentation fragment(self) -> id971 unsafe fn fragment(self) -> id /* (NSString) */ { 972 msg_send![self, fragment] 973 } host(self) -> id974 unsafe fn host(self) -> id /* (NSString) */ { 975 msg_send![self, host] 976 } lastPathComponent(self) -> id977 unsafe fn lastPathComponent(self) -> id /* (NSString) */ { 978 msg_send![self, lastPathComponent] 979 } parameterString(self) -> id980 unsafe fn parameterString(self) -> id /* (NSString) */ { 981 msg_send![self, parameterString] 982 } password(self) -> id983 unsafe fn password(self) -> id /* (NSString) */ { 984 msg_send![self, password] 985 } path(self) -> id986 unsafe fn path(self) -> id /* (NSString) */ { 987 msg_send![self, path] 988 } pathComponents(self) -> id989 unsafe fn pathComponents(self) -> id /* (NSArray<NSString*>) */ { 990 msg_send![self, pathComponents] 991 } pathExtension(self) -> id992 unsafe fn pathExtension(self) -> id /* (NSString) */ { 993 msg_send![self, pathExtension] 994 } port(self) -> id995 unsafe fn port(self) -> id /* (NSNumber) */ { 996 msg_send![self, port] 997 } query(self) -> id998 unsafe fn query(self) -> id /* (NSString) */ { 999 msg_send![self, query] 1000 } relativePath(self) -> id1001 unsafe fn relativePath(self) -> id /* (NSString) */ { 1002 msg_send![self, relativePath] 1003 } relativeString(self) -> id1004 unsafe fn relativeString(self) -> id /* (NSString) */ { 1005 msg_send![self, relativeString] 1006 } resourceSpecifier(self) -> id1007 unsafe fn resourceSpecifier(self) -> id /* (NSString) */ { 1008 msg_send![self, resourceSpecifier] 1009 } scheme(self) -> id1010 unsafe fn scheme(self) -> id /* (NSString) */ { 1011 msg_send![self, scheme] 1012 } standardizedURL(self) -> id1013 unsafe fn standardizedURL(self) -> id /* (NSURL) */ { 1014 msg_send![self, standardizedURL] 1015 } user(self) -> id1016 unsafe fn user(self) -> id /* (NSString) */ { 1017 msg_send![self, user] 1018 } 1019 1020 // unsafe fn resourceValuesForKeys_error_ 1021 // unsafe fn getResourceValue_forKey_error_ 1022 // unsafe fn setResourceValue_forKey_error_ 1023 // unsafe fn setResourceValues_error_ 1024 // unsafe fn removeAllCachedResourceValues 1025 // unsafe fn removeCachedResourceValueForKey_ 1026 // unsafe fn setTemporaryResourceValue_forKey_ NSURLResourceKey(self) -> id1027 unsafe fn NSURLResourceKey(self) -> id /* (NSString) */ { 1028 msg_send![self, NSURLResourceKey] 1029 } 1030 filePathURL(self) -> id1031 unsafe fn filePathURL(self) -> id { 1032 msg_send![self, filePathURL] 1033 } fileReferenceURL(self) -> id1034 unsafe fn fileReferenceURL(self) -> id { 1035 msg_send![self, fileReferenceURL] 1036 } URLByAppendingPathComponent_(self, path_component: id ) -> id1037 unsafe fn URLByAppendingPathComponent_(self, path_component: id /* (NSString) */) -> id { 1038 msg_send![self, URLByAppendingPathComponent:path_component] 1039 } URLByAppendingPathComponent_isDirectory_(self, path_component: id , is_dir: BOOL) -> id1040 unsafe fn URLByAppendingPathComponent_isDirectory_(self, path_component: id /* (NSString) */, is_dir: BOOL) -> id { 1041 msg_send![self, URLByAppendingPathComponent:path_component isDirectory:is_dir] 1042 } URLByAppendingPathExtension_(self, extension: id ) -> id1043 unsafe fn URLByAppendingPathExtension_(self, extension: id /* (NSString) */) -> id { 1044 msg_send![self, URLByAppendingPathExtension:extension] 1045 } URLByDeletingLastPathComponent(self) -> id1046 unsafe fn URLByDeletingLastPathComponent(self) -> id { 1047 msg_send![self, URLByDeletingLastPathComponent] 1048 } URLByDeletingPathExtension(self) -> id1049 unsafe fn URLByDeletingPathExtension(self) -> id { 1050 msg_send![self, URLByDeletingPathExtension] 1051 } URLByResolvingSymlinksInPath(self) -> id1052 unsafe fn URLByResolvingSymlinksInPath(self) -> id { 1053 msg_send![self, URLByResolvingSymlinksInPath] 1054 } URLByStandardizingPath(self) -> id1055 unsafe fn URLByStandardizingPath(self) -> id { 1056 msg_send![self, URLByStandardizingPath] 1057 } hasDirectoryPath(self) -> BOOL1058 unsafe fn hasDirectoryPath(self) -> BOOL { 1059 msg_send![self, hasDirectoryPath] 1060 } 1061 bookmarkDataWithContentsOfURL_error_(_:Self, url: id, error: id ) -> id1062 unsafe fn bookmarkDataWithContentsOfURL_error_(_:Self, url: id, error: id /* (NSError _Nullable) */) -> id /* (NSData) */ { 1063 msg_send![class!(NSURL), bookmarkDataWithContentsOfURL:url error:error] 1064 } bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_(self, options: NSURLBookmarkCreationOptions, resource_value_for_keys: id , relative_to_url: id, error: id ) -> id1065 unsafe fn bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_(self, options: NSURLBookmarkCreationOptions, resource_value_for_keys: id /* (NSArray<NSURLResourceKey>) */, relative_to_url: id, error: id /* (NSError _Nullable) */) -> id /* (NSData) */ { 1066 msg_send![self, bookmarkDataWithOptions:options includingResourceValuesForKeys:resource_value_for_keys relativeToURL:relative_to_url error:error] 1067 } 1068 // unsafe fn resourceValuesForKeys_fromBookmarkData_ writeBookmarkData_toURL_options_error_(_:Self, data: id , to_url: id, options: NSURLBookmarkFileCreationOptions, error: id ) -> id1069 unsafe fn writeBookmarkData_toURL_options_error_(_:Self, data: id /* (NSData) */, to_url: id, options: NSURLBookmarkFileCreationOptions, error: id /* (NSError _Nullable) */) -> id { 1070 msg_send![class!(NSURL), writeBookmarkData:data toURL:to_url options:options error:error] 1071 } startAccessingSecurityScopedResource(self) -> BOOL1072 unsafe fn startAccessingSecurityScopedResource(self) -> BOOL { 1073 msg_send![self, startAccessingSecurityScopedResource] 1074 } stopAccessingSecurityScopedResource(self)1075 unsafe fn stopAccessingSecurityScopedResource(self) { 1076 msg_send![self, stopAccessingSecurityScopedResource] 1077 } NSURLBookmarkFileCreationOptions(self) -> NSURLBookmarkFileCreationOptions1078 unsafe fn NSURLBookmarkFileCreationOptions(self) -> NSURLBookmarkFileCreationOptions { 1079 msg_send![self, NSURLBookmarkFileCreationOptions] 1080 } NSURLBookmarkCreationOptions(self) -> NSURLBookmarkCreationOptions1081 unsafe fn NSURLBookmarkCreationOptions(self) -> NSURLBookmarkCreationOptions { 1082 msg_send![self, NSURLBookmarkCreationOptions] 1083 } NSURLBookmarkResolutionOptions(self) -> NSURLBookmarkResolutionOptions1084 unsafe fn NSURLBookmarkResolutionOptions(self) -> NSURLBookmarkResolutionOptions { 1085 msg_send![self, NSURLBookmarkResolutionOptions] 1086 } 1087 1088 // unsafe fn checkPromisedItemIsReachableAndReturnError_ 1089 // unsafe fn getPromisedItemResourceValue_forKey_error_ 1090 // unsafe fn promisedItemResourceValuesForKeys_error_ 1091 1092 // unsafe fn URLFromPasteboard_ 1093 // unsafe fn writeToPasteboard_ 1094 } 1095 1096 pub trait NSBundle: Sized { mainBundle() -> Self1097 unsafe fn mainBundle() -> Self; 1098 loadNibNamed_owner_topLevelObjects_(self, name: id , owner: id, topLevelObjects: *mut id ) -> BOOL1099 unsafe fn loadNibNamed_owner_topLevelObjects_(self, 1100 name: id /* NSString */, 1101 owner: id, 1102 topLevelObjects: *mut id /* NSArray */) -> BOOL; 1103 } 1104 1105 impl NSBundle for id { mainBundle() -> id1106 unsafe fn mainBundle() -> id { 1107 msg_send![class!(NSBundle), mainBundle] 1108 } 1109 loadNibNamed_owner_topLevelObjects_(self, name: id , owner: id, topLevelObjects: *mut id ) -> BOOL1110 unsafe fn loadNibNamed_owner_topLevelObjects_(self, 1111 name: id /* NSString */, 1112 owner: id, 1113 topLevelObjects: *mut id /* NSArray* */) -> BOOL { 1114 msg_send![self, loadNibNamed:name 1115 owner:owner 1116 topLevelObjects:topLevelObjects] 1117 } 1118 } 1119 1120 pub trait NSData: Sized { data(_: Self) -> id1121 unsafe fn data(_: Self) -> id { 1122 msg_send![class!(NSData), data] 1123 } 1124 dataWithBytes_length_(_: Self, bytes: *const c_void, length: NSUInteger) -> id1125 unsafe fn dataWithBytes_length_(_: Self, bytes: *const c_void, length: NSUInteger) -> id { 1126 msg_send![class!(NSData), dataWithBytes:bytes length:length] 1127 } 1128 dataWithBytesNoCopy_length_(_: Self, bytes: *const c_void, length: NSUInteger) -> id1129 unsafe fn dataWithBytesNoCopy_length_(_: Self, bytes: *const c_void, length: NSUInteger) -> id { 1130 msg_send![class!(NSData), dataWithBytesNoCopy:bytes length:length] 1131 } 1132 dataWithBytesNoCopy_length_freeWhenDone_(_: Self, bytes: *const c_void, length: NSUInteger, freeWhenDone: BOOL) -> id1133 unsafe fn dataWithBytesNoCopy_length_freeWhenDone_(_: Self, bytes: *const c_void, 1134 length: NSUInteger, freeWhenDone: BOOL) -> id { 1135 msg_send![class!(NSData), dataWithBytesNoCopy:bytes length:length freeWhenDone:freeWhenDone] 1136 } 1137 dataWithContentsOfFile_(_: Self, path: id) -> id1138 unsafe fn dataWithContentsOfFile_(_: Self, path: id) -> id { 1139 msg_send![class!(NSData), dataWithContentsOfFile:path] 1140 } 1141 dataWithContentsOfFile_options_error_(_: Self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id1142 unsafe fn dataWithContentsOfFile_options_error_(_: Self, path: id, mask: NSDataReadingOptions, 1143 errorPtr: *mut id) -> id { 1144 msg_send![class!(NSData), dataWithContentsOfFile:path options:mask error:errorPtr] 1145 } 1146 dataWithContentsOfURL_(_: Self, aURL: id) -> id1147 unsafe fn dataWithContentsOfURL_(_: Self, aURL: id) -> id { 1148 msg_send![class!(NSData), dataWithContentsOfURL:aURL] 1149 } 1150 dataWithContentsOfURL_options_error_(_: Self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id1151 unsafe fn dataWithContentsOfURL_options_error_(_: Self, aURL: id, mask: NSDataReadingOptions, 1152 errorPtr: *mut id) -> id { 1153 msg_send![class!(NSData), dataWithContentsOfURL:aURL options:mask error:errorPtr] 1154 } 1155 dataWithData_(_: Self, aData: id) -> id1156 unsafe fn dataWithData_(_: Self, aData: id) -> id { 1157 msg_send![class!(NSData), dataWithData:aData] 1158 } 1159 initWithBase64EncodedData_options_(self, base64Data: id, options: NSDataBase64DecodingOptions) -> id1160 unsafe fn initWithBase64EncodedData_options_(self, base64Data: id, options: NSDataBase64DecodingOptions) 1161 -> id; initWithBase64EncodedString_options_(self, base64String: id, options: NSDataBase64DecodingOptions) -> id1162 unsafe fn initWithBase64EncodedString_options_(self, base64String: id, options: NSDataBase64DecodingOptions) 1163 -> id; initWithBytes_length_(self, bytes: *const c_void, length: NSUInteger) -> id1164 unsafe fn initWithBytes_length_(self, bytes: *const c_void, length: NSUInteger) -> id; initWithBytesNoCopy_length_(self, bytes: *const c_void, length: NSUInteger) -> id1165 unsafe fn initWithBytesNoCopy_length_(self, bytes: *const c_void, length: NSUInteger) -> id; initWithBytesNoCopy_length_deallocator_(self, bytes: *const c_void, length: NSUInteger, deallocator: *mut Block<(*const c_void, NSUInteger), ()>) -> id1166 unsafe fn initWithBytesNoCopy_length_deallocator_(self, bytes: *const c_void, length: NSUInteger, 1167 deallocator: *mut Block<(*const c_void, NSUInteger), ()>) 1168 -> id; initWithBytesNoCopy_length_freeWhenDone_(self, bytes: *const c_void, length: NSUInteger, freeWhenDone: BOOL) -> id1169 unsafe fn initWithBytesNoCopy_length_freeWhenDone_(self, bytes: *const c_void, 1170 length: NSUInteger, freeWhenDone: BOOL) -> id; initWithContentsOfFile_(self, path: id) -> id1171 unsafe fn initWithContentsOfFile_(self, path: id) -> id; initWithContentsOfFile_options_error(self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id1172 unsafe fn initWithContentsOfFile_options_error(self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) 1173 -> id; initWithContentsOfURL_(self, aURL: id) -> id1174 unsafe fn initWithContentsOfURL_(self, aURL: id) -> id; initWithContentsOfURL_options_error_(self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id1175 unsafe fn initWithContentsOfURL_options_error_(self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) 1176 -> id; initWithData_(self, data: id) -> id1177 unsafe fn initWithData_(self, data: id) -> id; 1178 bytes(self) -> *const c_void1179 unsafe fn bytes(self) -> *const c_void; description(self) -> id1180 unsafe fn description(self) -> id; enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut BOOL), ()>)1181 unsafe fn enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut BOOL), ()>); getBytes_length_(self, buffer: *mut c_void, length: NSUInteger)1182 unsafe fn getBytes_length_(self, buffer: *mut c_void, length: NSUInteger); getBytes_range_(self, buffer: *mut c_void, range: NSRange)1183 unsafe fn getBytes_range_(self, buffer: *mut c_void, range: NSRange); subdataWithRange_(self, range: NSRange) -> id1184 unsafe fn subdataWithRange_(self, range: NSRange) -> id; rangeOfData_options_range_(self, dataToFind: id, options: NSDataSearchOptions, searchRange: NSRange) -> NSRange1185 unsafe fn rangeOfData_options_range_(self, dataToFind: id, options: NSDataSearchOptions, searchRange: NSRange) 1186 -> NSRange; 1187 base64EncodedDataWithOptions_(self, options: NSDataBase64EncodingOptions) -> id1188 unsafe fn base64EncodedDataWithOptions_(self, options: NSDataBase64EncodingOptions) -> id; base64EncodedStringWithOptions_(self, options: NSDataBase64EncodingOptions) -> id1189 unsafe fn base64EncodedStringWithOptions_(self, options: NSDataBase64EncodingOptions) -> id; 1190 isEqualToData_(self, otherData: id) -> id1191 unsafe fn isEqualToData_(self, otherData: id) -> id; length(self) -> NSUInteger1192 unsafe fn length(self) -> NSUInteger; 1193 writeToFile_atomically_(self, path: id, atomically: BOOL) -> BOOL1194 unsafe fn writeToFile_atomically_(self, path: id, atomically: BOOL) -> BOOL; writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL1195 unsafe fn writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL; writeToURL_atomically_(self, aURL: id, atomically: BOOL) -> BOOL1196 unsafe fn writeToURL_atomically_(self, aURL: id, atomically: BOOL) -> BOOL; writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL1197 unsafe fn writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL; 1198 } 1199 1200 impl NSData for id { initWithBase64EncodedData_options_(self, base64Data: id, options: NSDataBase64DecodingOptions) -> id1201 unsafe fn initWithBase64EncodedData_options_(self, base64Data: id, options: NSDataBase64DecodingOptions) 1202 -> id { 1203 msg_send![self, initWithBase64EncodedData:base64Data options:options] 1204 } 1205 initWithBase64EncodedString_options_(self, base64String: id, options: NSDataBase64DecodingOptions) -> id1206 unsafe fn initWithBase64EncodedString_options_(self, base64String: id, options: NSDataBase64DecodingOptions) 1207 -> id { 1208 msg_send![self, initWithBase64EncodedString:base64String options:options] 1209 } 1210 initWithBytes_length_(self, bytes: *const c_void, length: NSUInteger) -> id1211 unsafe fn initWithBytes_length_(self, bytes: *const c_void, length: NSUInteger) -> id { 1212 msg_send![self,initWithBytes:bytes length:length] 1213 } 1214 initWithBytesNoCopy_length_(self, bytes: *const c_void, length: NSUInteger) -> id1215 unsafe fn initWithBytesNoCopy_length_(self, bytes: *const c_void, length: NSUInteger) -> id { 1216 msg_send![self, initWithBytesNoCopy:bytes length:length] 1217 } 1218 initWithBytesNoCopy_length_deallocator_(self, bytes: *const c_void, length: NSUInteger, deallocator: *mut Block<(*const c_void, NSUInteger), ()>) -> id1219 unsafe fn initWithBytesNoCopy_length_deallocator_(self, bytes: *const c_void, length: NSUInteger, 1220 deallocator: *mut Block<(*const c_void, NSUInteger), ()>) 1221 -> id { 1222 msg_send![self, initWithBytesNoCopy:bytes length:length deallocator:deallocator] 1223 } 1224 initWithBytesNoCopy_length_freeWhenDone_(self, bytes: *const c_void, length: NSUInteger, freeWhenDone: BOOL) -> id1225 unsafe fn initWithBytesNoCopy_length_freeWhenDone_(self, bytes: *const c_void, 1226 length: NSUInteger, freeWhenDone: BOOL) -> id { 1227 msg_send![self, initWithBytesNoCopy:bytes length:length freeWhenDone:freeWhenDone] 1228 } 1229 initWithContentsOfFile_(self, path: id) -> id1230 unsafe fn initWithContentsOfFile_(self, path: id) -> id { 1231 msg_send![self, initWithContentsOfFile:path] 1232 } 1233 initWithContentsOfFile_options_error(self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id1234 unsafe fn initWithContentsOfFile_options_error(self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) 1235 -> id { 1236 msg_send![self, initWithContentsOfFile:path options:mask error:errorPtr] 1237 } 1238 initWithContentsOfURL_(self, aURL: id) -> id1239 unsafe fn initWithContentsOfURL_(self, aURL: id) -> id { 1240 msg_send![self, initWithContentsOfURL:aURL] 1241 } 1242 initWithContentsOfURL_options_error_(self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id1243 unsafe fn initWithContentsOfURL_options_error_(self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) 1244 -> id { 1245 msg_send![self, initWithContentsOfURL:aURL options:mask error:errorPtr] 1246 } 1247 initWithData_(self, data: id) -> id1248 unsafe fn initWithData_(self, data: id) -> id { 1249 msg_send![self, initWithData:data] 1250 } 1251 bytes(self) -> *const c_void1252 unsafe fn bytes(self) -> *const c_void { 1253 msg_send![self, bytes] 1254 } 1255 description(self) -> id1256 unsafe fn description(self) -> id { 1257 msg_send![self, description] 1258 } 1259 enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut BOOL), ()>)1260 unsafe fn enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut BOOL), ()>) { 1261 msg_send![self, enumerateByteRangesUsingBlock:block] 1262 } 1263 getBytes_length_(self, buffer: *mut c_void, length: NSUInteger)1264 unsafe fn getBytes_length_(self, buffer: *mut c_void, length: NSUInteger) { 1265 msg_send![self, getBytes:buffer length:length] 1266 } 1267 getBytes_range_(self, buffer: *mut c_void, range: NSRange)1268 unsafe fn getBytes_range_(self, buffer: *mut c_void, range: NSRange) { 1269 msg_send![self, getBytes:buffer range:range] 1270 } 1271 subdataWithRange_(self, range: NSRange) -> id1272 unsafe fn subdataWithRange_(self, range: NSRange) -> id { 1273 msg_send![self, subdataWithRange:range] 1274 } 1275 rangeOfData_options_range_(self, dataToFind: id, options: NSDataSearchOptions, searchRange: NSRange) -> NSRange1276 unsafe fn rangeOfData_options_range_(self, dataToFind: id, options: NSDataSearchOptions, searchRange: NSRange) 1277 -> NSRange { 1278 msg_send![self, rangeOfData:dataToFind options:options range:searchRange] 1279 } 1280 base64EncodedDataWithOptions_(self, options: NSDataBase64EncodingOptions) -> id1281 unsafe fn base64EncodedDataWithOptions_(self, options: NSDataBase64EncodingOptions) -> id { 1282 msg_send![self, base64EncodedDataWithOptions:options] 1283 } 1284 base64EncodedStringWithOptions_(self, options: NSDataBase64EncodingOptions) -> id1285 unsafe fn base64EncodedStringWithOptions_(self, options: NSDataBase64EncodingOptions) -> id { 1286 msg_send![self, base64EncodedStringWithOptions:options] 1287 } 1288 isEqualToData_(self, otherData: id) -> id1289 unsafe fn isEqualToData_(self, otherData: id) -> id { 1290 msg_send![self, isEqualToData:otherData] 1291 } 1292 length(self) -> NSUInteger1293 unsafe fn length(self) -> NSUInteger { 1294 msg_send![self, length] 1295 } 1296 writeToFile_atomically_(self, path: id, atomically: BOOL) -> BOOL1297 unsafe fn writeToFile_atomically_(self, path: id, atomically: BOOL) -> BOOL { 1298 msg_send![self, writeToFile:path atomically:atomically] 1299 } 1300 writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL1301 unsafe fn writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL { 1302 msg_send![self, writeToFile:path options:mask error:errorPtr] 1303 } 1304 writeToURL_atomically_(self, aURL: id, atomically: BOOL) -> BOOL1305 unsafe fn writeToURL_atomically_(self, aURL: id, atomically: BOOL) -> BOOL { 1306 msg_send![self, writeToURL:aURL atomically:atomically] 1307 } 1308 writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL1309 unsafe fn writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL { 1310 msg_send![self, writeToURL:aURL options:mask error:errorPtr] 1311 } 1312 } 1313 1314 bitflags! { 1315 pub struct NSDataReadingOptions: libc::c_ulonglong { 1316 const NSDataReadingMappedIfSafe = 1 << 0; 1317 const NSDataReadingUncached = 1 << 1; 1318 const NSDataReadingMappedAlways = 1 << 3; 1319 } 1320 } 1321 1322 bitflags! { 1323 pub struct NSDataBase64EncodingOptions: libc::c_ulonglong { 1324 const NSDataBase64Encoding64CharacterLineLength = 1 << 0; 1325 const NSDataBase64Encoding76CharacterLineLength = 1 << 1; 1326 const NSDataBase64EncodingEndLineWithCarriageReturn = 1 << 4; 1327 const NSDataBase64EncodingEndLineWithLineFeed = 1 << 5; 1328 } 1329 } 1330 1331 bitflags! { 1332 pub struct NSDataBase64DecodingOptions: libc::c_ulonglong { 1333 const NSDataBase64DecodingIgnoreUnknownCharacters = 1 << 0; 1334 } 1335 } 1336 1337 bitflags! { 1338 pub struct NSDataWritingOptions: libc::c_ulonglong { 1339 const NSDataWritingAtomic = 1 << 0; 1340 const NSDataWritingWithoutOverwriting = 1 << 1; 1341 } 1342 } 1343 1344 bitflags! { 1345 pub struct NSDataSearchOptions: libc::c_ulonglong { 1346 const NSDataSearchBackwards = 1 << 0; 1347 const NSDataSearchAnchored = 1 << 1; 1348 } 1349 } 1350 1351 pub trait NSUserDefaults { standardUserDefaults() -> Self1352 unsafe fn standardUserDefaults() -> Self; 1353 setBool_forKey_(self, value: BOOL, key: id)1354 unsafe fn setBool_forKey_(self, value: BOOL, key: id); bool_forKey_(self, key: id) -> BOOL1355 unsafe fn bool_forKey_(self, key: id) -> BOOL; 1356 removeObject_forKey_(self, key: id)1357 unsafe fn removeObject_forKey_(self, key: id); 1358 } 1359 1360 impl NSUserDefaults for id { standardUserDefaults() -> id1361 unsafe fn standardUserDefaults() -> id { 1362 msg_send![class!(NSUserDefaults), standardUserDefaults] 1363 } 1364 setBool_forKey_(self, value: BOOL, key: id)1365 unsafe fn setBool_forKey_(self, value: BOOL, key: id) { 1366 msg_send![self, setBool:value forKey:key] 1367 } 1368 bool_forKey_(self, key: id) -> BOOL1369 unsafe fn bool_forKey_(self, key: id) -> BOOL { 1370 msg_send![self, boolForKey: key] 1371 } 1372 removeObject_forKey_(self, key: id)1373 unsafe fn removeObject_forKey_(self, key: id) { 1374 msg_send![self, removeObjectForKey:key] 1375 } 1376 } 1377