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::base::CGFloat; 39 use core_graphics::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 pub trait NSProcessInfo: Sized { processInfo(_: Self) -> id207 unsafe fn processInfo(_: Self) -> id { 208 msg_send![class!(NSProcessInfo), processInfo] 209 } 210 processName(self) -> id211 unsafe fn processName(self) -> id; 212 } 213 214 impl NSProcessInfo for id { processName(self) -> id215 unsafe fn processName(self) -> id { 216 msg_send![self, processName] 217 } 218 } 219 220 pub type NSTimeInterval = libc::c_double; 221 222 pub trait NSArray: Sized { array(_: Self) -> id223 unsafe fn array(_: Self) -> id { 224 msg_send![class!(NSArray), array] 225 } 226 arrayWithObjects(_: Self, objects: &[id]) -> id227 unsafe fn arrayWithObjects(_: Self, objects: &[id]) -> id { 228 msg_send![class!(NSArray), arrayWithObjects:objects.as_ptr() 229 count:objects.len()] 230 } 231 arrayWithObject(_: Self, object: id) -> id232 unsafe fn arrayWithObject(_: Self, object: id) -> id { 233 msg_send![class!(NSArray), arrayWithObject:object] 234 } 235 init(self) -> id236 unsafe fn init(self) -> id; 237 count(self) -> NSUInteger238 unsafe fn count(self) -> NSUInteger; 239 arrayByAddingObjectFromArray(self, object: id) -> id240 unsafe fn arrayByAddingObjectFromArray(self, object: id) -> id; arrayByAddingObjectsFromArray(self, objects: id) -> id241 unsafe fn arrayByAddingObjectsFromArray(self, objects: id) -> id; objectAtIndex(self, index: NSUInteger) -> id242 unsafe fn objectAtIndex(self, index: NSUInteger) -> id; 243 } 244 245 impl NSArray for id { init(self) -> id246 unsafe fn init(self) -> id { 247 msg_send![self, init] 248 } 249 count(self) -> NSUInteger250 unsafe fn count(self) -> NSUInteger { 251 msg_send![self, count] 252 } 253 arrayByAddingObjectFromArray(self, object: id) -> id254 unsafe fn arrayByAddingObjectFromArray(self, object: id) -> id { 255 msg_send![self, arrayByAddingObjectFromArray:object] 256 } 257 arrayByAddingObjectsFromArray(self, objects: id) -> id258 unsafe fn arrayByAddingObjectsFromArray(self, objects: id) -> id { 259 msg_send![self, arrayByAddingObjectsFromArray:objects] 260 } 261 objectAtIndex(self, index: NSUInteger) -> id262 unsafe fn objectAtIndex(self, index: NSUInteger) -> id { 263 msg_send![self, objectAtIndex:index] 264 } 265 } 266 267 pub trait NSDictionary: Sized { dictionary(_: Self) -> id268 unsafe fn dictionary(_: Self) -> id { 269 msg_send![class!(NSDictionary), dictionary] 270 } 271 dictionaryWithContentsOfFile_(_: Self, path: id) -> id272 unsafe fn dictionaryWithContentsOfFile_(_: Self, path: id) -> id { 273 msg_send![class!(NSDictionary), dictionaryWithContentsOfFile:path] 274 } 275 dictionaryWithContentsOfURL_(_: Self, aURL: id) -> id276 unsafe fn dictionaryWithContentsOfURL_(_: Self, aURL: id) -> id { 277 msg_send![class!(NSDictionary), dictionaryWithContentsOfURL:aURL] 278 } 279 dictionaryWithDictionary_(_: Self, otherDictionary: id) -> id280 unsafe fn dictionaryWithDictionary_(_: Self, otherDictionary: id) -> id { 281 msg_send![class!(NSDictionary), dictionaryWithDictionary:otherDictionary] 282 } 283 dictionaryWithObject_forKey_(_: Self, anObject: id, aKey: id) -> id284 unsafe fn dictionaryWithObject_forKey_(_: Self, anObject: id, aKey: id) -> id { 285 msg_send![class!(NSDictionary), dictionaryWithObject:anObject forKey:aKey] 286 } 287 dictionaryWithObjects_forKeys_(_: Self, objects: id, keys: id) -> id288 unsafe fn dictionaryWithObjects_forKeys_(_: Self, objects: id, keys: id) -> id { 289 msg_send![class!(NSDictionary), dictionaryWithObjects:objects forKeys:keys] 290 } 291 dictionaryWithObjects_forKeys_count_(_: Self, objects: *const id, keys: *const id, count: NSUInteger) -> id292 unsafe fn dictionaryWithObjects_forKeys_count_(_: Self, objects: *const id, keys: *const id, count: NSUInteger) -> id { 293 msg_send![class!(NSDictionary), dictionaryWithObjects:objects forKeys:keys count:count] 294 } 295 dictionaryWithObjectsAndKeys_(_: Self, firstObject: id) -> id296 unsafe fn dictionaryWithObjectsAndKeys_(_: Self, firstObject: id) -> id { 297 msg_send![class!(NSDictionary), dictionaryWithObjectsAndKeys:firstObject] 298 } 299 init(self) -> id300 unsafe fn init(self) -> id; initWithContentsOfFile_(self, path: id) -> id301 unsafe fn initWithContentsOfFile_(self, path: id) -> id; initWithContentsOfURL_(self, aURL: id) -> id302 unsafe fn initWithContentsOfURL_(self, aURL: id) -> id; initWithDictionary_(self, otherDicitonary: id) -> id303 unsafe fn initWithDictionary_(self, otherDicitonary: id) -> id; initWithDictionary_copyItems_(self, otherDicitonary: id, flag: BOOL) -> id304 unsafe fn initWithDictionary_copyItems_(self, otherDicitonary: id, flag: BOOL) -> id; initWithObjects_forKeys_(self, objects: id, keys: id) -> id305 unsafe fn initWithObjects_forKeys_(self, objects: id, keys: id) -> id; initWithObjects_forKeys_count_(self, objects: id, keys: id, count: NSUInteger) -> id306 unsafe fn initWithObjects_forKeys_count_(self, objects: id, keys: id, count: NSUInteger) -> id; initWithObjectsAndKeys_(self, firstObject: id) -> id307 unsafe fn initWithObjectsAndKeys_(self, firstObject: id) -> id; 308 sharedKeySetForKeys_(_: Self, keys: id) -> id309 unsafe fn sharedKeySetForKeys_(_: Self, keys: id) -> id { 310 msg_send![class!(NSDictionary), sharedKeySetForKeys:keys] 311 } 312 count(self) -> NSUInteger313 unsafe fn count(self) -> NSUInteger; 314 isEqualToDictionary_(self, otherDictionary: id) -> BOOL315 unsafe fn isEqualToDictionary_(self, otherDictionary: id) -> BOOL; 316 allKeys(self) -> id317 unsafe fn allKeys(self) -> id; allKeysForObject_(self, anObject: id) -> id318 unsafe fn allKeysForObject_(self, anObject: id) -> id; allValues(self) -> id319 unsafe fn allValues(self) -> id; objectForKey_(self, aKey: id) -> id320 unsafe fn objectForKey_(self, aKey: id) -> id; objectForKeyedSubscript_(self, key: id) -> id321 unsafe fn objectForKeyedSubscript_(self, key: id) -> id; objectsForKeys_notFoundMarker_(self, keys: id, anObject: id) -> id322 unsafe fn objectsForKeys_notFoundMarker_(self, keys: id, anObject: id) -> id; valueForKey_(self, key: id) -> id323 unsafe fn valueForKey_(self, key: id) -> id; 324 keyEnumerator(self) -> id325 unsafe fn keyEnumerator(self) -> id; objectEnumerator(self) -> id326 unsafe fn objectEnumerator(self) -> id; enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut BOOL), ()>)327 unsafe fn enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut BOOL), ()>); enumerateKeysAndObjectsWithOptions_usingBlock_(self, opts: NSEnumerationOptions, block: *mut Block<(id, id, *mut BOOL), ()>)328 unsafe fn enumerateKeysAndObjectsWithOptions_usingBlock_(self, opts: NSEnumerationOptions, 329 block: *mut Block<(id, id, *mut BOOL), ()>); 330 keysSortedByValueUsingSelector_(self, comparator: SEL) -> id331 unsafe fn keysSortedByValueUsingSelector_(self, comparator: SEL) -> id; keysSortedByValueUsingComparator_(self, cmptr: NSComparator) -> id332 unsafe fn keysSortedByValueUsingComparator_(self, cmptr: NSComparator) -> id; keysSortedByValueWithOptions_usingComparator_(self, opts: NSEnumerationOptions, cmptr: NSComparator) -> id333 unsafe fn keysSortedByValueWithOptions_usingComparator_(self, opts: NSEnumerationOptions, cmptr: NSComparator) -> id; 334 keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id335 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>) -> id336 unsafe fn keysOfEntriesWithOptions_PassingTest_(self, opts: NSEnumerationOptions, 337 predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id; 338 writeToFile_atomically_(self, path: id, flag: BOOL) -> BOOL339 unsafe fn writeToFile_atomically_(self, path: id, flag: BOOL) -> BOOL; writeToURL_atomically_(self, aURL: id, flag: BOOL) -> BOOL340 unsafe fn writeToURL_atomically_(self, aURL: id, flag: BOOL) -> BOOL; 341 fileCreationDate(self) -> id342 unsafe fn fileCreationDate(self) -> id; fileExtensionHidden(self) -> BOOL343 unsafe fn fileExtensionHidden(self) -> BOOL; fileGroupOwnerAccountID(self) -> id344 unsafe fn fileGroupOwnerAccountID(self) -> id; fileGroupOwnerAccountName(self) -> id345 unsafe fn fileGroupOwnerAccountName(self) -> id; fileIsAppendOnly(self) -> BOOL346 unsafe fn fileIsAppendOnly(self) -> BOOL; fileIsImmutable(self) -> BOOL347 unsafe fn fileIsImmutable(self) -> BOOL; fileModificationDate(self) -> id348 unsafe fn fileModificationDate(self) -> id; fileOwnerAccountID(self) -> id349 unsafe fn fileOwnerAccountID(self) -> id; fileOwnerAccountName(self) -> id350 unsafe fn fileOwnerAccountName(self) -> id; filePosixPermissions(self) -> NSUInteger351 unsafe fn filePosixPermissions(self) -> NSUInteger; fileSize(self) -> libc::c_ulonglong352 unsafe fn fileSize(self) -> libc::c_ulonglong; fileSystemFileNumber(self) -> NSUInteger353 unsafe fn fileSystemFileNumber(self) -> NSUInteger; fileSystemNumber(self) -> NSInteger354 unsafe fn fileSystemNumber(self) -> NSInteger; fileType(self) -> id355 unsafe fn fileType(self) -> id; 356 description(self) -> id357 unsafe fn description(self) -> id; descriptionInStringsFileFormat(self) -> id358 unsafe fn descriptionInStringsFileFormat(self) -> id; descriptionWithLocale_(self, locale: id) -> id359 unsafe fn descriptionWithLocale_(self, locale: id) -> id; descriptionWithLocale_indent_(self, locale: id, indent: NSUInteger) -> id360 unsafe fn descriptionWithLocale_indent_(self, locale: id, indent: NSUInteger) -> id; 361 } 362 363 impl NSDictionary for id { init(self) -> id364 unsafe fn init(self) -> id { 365 msg_send![self, init] 366 } 367 initWithContentsOfFile_(self, path: id) -> id368 unsafe fn initWithContentsOfFile_(self, path: id) -> id { 369 msg_send![self, initWithContentsOfFile:path] 370 } 371 initWithContentsOfURL_(self, aURL: id) -> id372 unsafe fn initWithContentsOfURL_(self, aURL: id) -> id { 373 msg_send![self, initWithContentsOfURL:aURL] 374 } 375 initWithDictionary_(self, otherDictionary: id) -> id376 unsafe fn initWithDictionary_(self, otherDictionary: id) -> id { 377 msg_send![self, initWithDictionary:otherDictionary] 378 } 379 initWithDictionary_copyItems_(self, otherDictionary: id, flag: BOOL) -> id380 unsafe fn initWithDictionary_copyItems_(self, otherDictionary: id, flag: BOOL) -> id { 381 msg_send![self, initWithDictionary:otherDictionary copyItems:flag] 382 } 383 initWithObjects_forKeys_(self, objects: id, keys: id) -> id384 unsafe fn initWithObjects_forKeys_(self, objects: id, keys: id) -> id { 385 msg_send![self, initWithObjects:objects forKeys:keys] 386 } 387 initWithObjects_forKeys_count_(self, objects: id, keys: id, count: NSUInteger) -> id388 unsafe fn initWithObjects_forKeys_count_(self, objects: id, keys: id, count: NSUInteger) -> id { 389 msg_send![self, initWithObjects:objects forKeys:keys count:count] 390 } 391 initWithObjectsAndKeys_(self, firstObject: id) -> id392 unsafe fn initWithObjectsAndKeys_(self, firstObject: id) -> id { 393 msg_send![self, initWithObjectsAndKeys:firstObject] 394 } 395 count(self) -> NSUInteger396 unsafe fn count(self) -> NSUInteger { 397 msg_send![self, count] 398 } 399 isEqualToDictionary_(self, otherDictionary: id) -> BOOL400 unsafe fn isEqualToDictionary_(self, otherDictionary: id) -> BOOL { 401 msg_send![self, isEqualToDictionary:otherDictionary] 402 } 403 allKeys(self) -> id404 unsafe fn allKeys(self) -> id { 405 msg_send![self, allKeys] 406 } 407 allKeysForObject_(self, anObject: id) -> id408 unsafe fn allKeysForObject_(self, anObject: id) -> id { 409 msg_send![self, allKeysForObject:anObject] 410 } 411 allValues(self) -> id412 unsafe fn allValues(self) -> id { 413 msg_send![self, allValues] 414 } 415 objectForKey_(self, aKey: id) -> id416 unsafe fn objectForKey_(self, aKey: id) -> id { 417 msg_send![self, objectForKey:aKey] 418 } 419 objectForKeyedSubscript_(self, key: id) -> id420 unsafe fn objectForKeyedSubscript_(self, key: id) -> id { 421 msg_send![self, objectForKeyedSubscript:key] 422 } 423 objectsForKeys_notFoundMarker_(self, keys: id, anObject: id) -> id424 unsafe fn objectsForKeys_notFoundMarker_(self, keys: id, anObject: id) -> id { 425 msg_send![self, objectsForKeys:keys notFoundMarker:anObject] 426 } 427 valueForKey_(self, key: id) -> id428 unsafe fn valueForKey_(self, key: id) -> id { 429 msg_send![self, valueForKey:key] 430 } 431 keyEnumerator(self) -> id432 unsafe fn keyEnumerator(self) -> id { 433 msg_send![self, keyEnumerator] 434 } 435 objectEnumerator(self) -> id436 unsafe fn objectEnumerator(self) -> id { 437 msg_send![self, objectEnumerator] 438 } 439 enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut BOOL), ()>)440 unsafe fn enumerateKeysAndObjectsUsingBlock_(self, block: *mut Block<(id, id, *mut BOOL), ()>) { 441 msg_send![self, enumerateKeysAndObjectsUsingBlock:block] 442 } 443 enumerateKeysAndObjectsWithOptions_usingBlock_(self, opts: NSEnumerationOptions, block: *mut Block<(id, id, *mut BOOL), ()>)444 unsafe fn enumerateKeysAndObjectsWithOptions_usingBlock_(self, opts: NSEnumerationOptions, 445 block: *mut Block<(id, id, *mut BOOL), ()>) { 446 msg_send![self, enumerateKeysAndObjectsWithOptions:opts usingBlock:block] 447 } 448 keysSortedByValueUsingSelector_(self, comparator: SEL) -> id449 unsafe fn keysSortedByValueUsingSelector_(self, comparator: SEL) -> id { 450 msg_send![self, keysSortedByValueUsingSelector:comparator] 451 } 452 keysSortedByValueUsingComparator_(self, cmptr: NSComparator) -> id453 unsafe fn keysSortedByValueUsingComparator_(self, cmptr: NSComparator) -> id { 454 msg_send![self, keysSortedByValueUsingComparator:cmptr] 455 } 456 keysSortedByValueWithOptions_usingComparator_(self, opts: NSEnumerationOptions, cmptr: NSComparator) -> id457 unsafe fn keysSortedByValueWithOptions_usingComparator_(self, opts: NSEnumerationOptions, cmptr: NSComparator) -> id { 458 let rv: id = msg_send![self, keysSortedByValueWithOptions:opts usingComparator:cmptr]; 459 rv 460 } 461 keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id462 unsafe fn keysOfEntriesPassingTest_(self, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id { 463 msg_send![self, keysOfEntriesPassingTest:predicate] 464 } 465 keysOfEntriesWithOptions_PassingTest_(self, opts: NSEnumerationOptions, predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id466 unsafe fn keysOfEntriesWithOptions_PassingTest_(self, opts: NSEnumerationOptions, 467 predicate: *mut Block<(id, id, *mut BOOL), BOOL>) -> id { 468 msg_send![self, keysOfEntriesWithOptions:opts PassingTest:predicate] 469 } 470 writeToFile_atomically_(self, path: id, flag: BOOL) -> BOOL471 unsafe fn writeToFile_atomically_(self, path: id, flag: BOOL) -> BOOL { 472 msg_send![self, writeToFile:path atomically:flag] 473 } 474 writeToURL_atomically_(self, aURL: id, flag: BOOL) -> BOOL475 unsafe fn writeToURL_atomically_(self, aURL: id, flag: BOOL) -> BOOL { 476 msg_send![self, writeToURL:aURL atomically:flag] 477 } 478 fileCreationDate(self) -> id479 unsafe fn fileCreationDate(self) -> id { 480 msg_send![self, fileCreationDate] 481 } 482 fileExtensionHidden(self) -> BOOL483 unsafe fn fileExtensionHidden(self) -> BOOL { 484 msg_send![self, fileExtensionHidden] 485 } 486 fileGroupOwnerAccountID(self) -> id487 unsafe fn fileGroupOwnerAccountID(self) -> id { 488 msg_send![self, fileGroupOwnerAccountID] 489 } 490 fileGroupOwnerAccountName(self) -> id491 unsafe fn fileGroupOwnerAccountName(self) -> id { 492 msg_send![self, fileGroupOwnerAccountName] 493 } 494 fileIsAppendOnly(self) -> BOOL495 unsafe fn fileIsAppendOnly(self) -> BOOL { 496 msg_send![self, fileIsAppendOnly] 497 } 498 fileIsImmutable(self) -> BOOL499 unsafe fn fileIsImmutable(self) -> BOOL { 500 msg_send![self, fileIsImmutable] 501 } 502 fileModificationDate(self) -> id503 unsafe fn fileModificationDate(self) -> id { 504 msg_send![self, fileModificationDate] 505 } 506 fileOwnerAccountID(self) -> id507 unsafe fn fileOwnerAccountID(self) -> id { 508 msg_send![self, fileOwnerAccountID] 509 } 510 fileOwnerAccountName(self) -> id511 unsafe fn fileOwnerAccountName(self) -> id { 512 msg_send![self, fileOwnerAccountName] 513 } 514 filePosixPermissions(self) -> NSUInteger515 unsafe fn filePosixPermissions(self) -> NSUInteger { 516 msg_send![self, filePosixPermissions] 517 } 518 fileSize(self) -> libc::c_ulonglong519 unsafe fn fileSize(self) -> libc::c_ulonglong { 520 msg_send![self, fileSize] 521 } 522 fileSystemFileNumber(self) -> NSUInteger523 unsafe fn fileSystemFileNumber(self) -> NSUInteger { 524 msg_send![self, fileSystemFileNumber] 525 } 526 fileSystemNumber(self) -> NSInteger527 unsafe fn fileSystemNumber(self) -> NSInteger { 528 msg_send![self, fileSystemNumber] 529 } 530 fileType(self) -> id531 unsafe fn fileType(self) -> id { 532 msg_send![self, fileType] 533 } 534 description(self) -> id535 unsafe fn description(self) -> id { 536 msg_send![self, description] 537 } 538 descriptionInStringsFileFormat(self) -> id539 unsafe fn descriptionInStringsFileFormat(self) -> id { 540 msg_send![self, descriptionInStringsFileFormat] 541 } 542 descriptionWithLocale_(self, locale: id) -> id543 unsafe fn descriptionWithLocale_(self, locale: id) -> id { 544 msg_send![self, descriptionWithLocale:locale] 545 } 546 descriptionWithLocale_indent_(self, locale: id, indent: NSUInteger) -> id547 unsafe fn descriptionWithLocale_indent_(self, locale: id, indent: NSUInteger) -> id { 548 msg_send![self, descriptionWithLocale:locale indent:indent] 549 } 550 } 551 552 bitflags! { 553 pub struct NSEnumerationOptions: libc::c_ulonglong { 554 const NSEnumerationConcurrent = 1 << 0; 555 const NSEnumerationReverse = 1 << 1; 556 } 557 } 558 559 pub type NSComparator = *mut Block<(id, id), NSComparisonResult>; 560 561 #[repr(isize)] 562 #[derive(Clone, Copy, Debug, Eq, PartialEq)] 563 pub enum NSComparisonResult { 564 NSOrderedAscending = -1, 565 NSOrderedSame = 0, 566 NSOrderedDescending = 1 567 } 568 569 pub trait NSString: Sized { alloc(_: Self) -> id570 unsafe fn alloc(_: Self) -> id { 571 msg_send![class!(NSString), alloc] 572 } 573 stringByAppendingString_(self, other: id) -> id574 unsafe fn stringByAppendingString_(self, other: id) -> id; init_str(self, string: &str) -> Self575 unsafe fn init_str(self, string: &str) -> Self; UTF8String(self) -> *const libc::c_char576 unsafe fn UTF8String(self) -> *const libc::c_char; len(self) -> usize577 unsafe fn len(self) -> usize; isEqualToString(self, &str) -> bool578 unsafe fn isEqualToString(self, &str) -> bool; substringWithRange(self, range: NSRange) -> id579 unsafe fn substringWithRange(self, range: NSRange) -> id; 580 } 581 582 impl NSString for id { isEqualToString(self, other: &str) -> bool583 unsafe fn isEqualToString(self, other: &str) -> bool { 584 let other = NSString::alloc(nil).init_str(other); 585 let rv: BOOL = msg_send![self, isEqualToString:other]; 586 rv != NO 587 } 588 stringByAppendingString_(self, other: id) -> id589 unsafe fn stringByAppendingString_(self, other: id) -> id { 590 msg_send![self, stringByAppendingString:other] 591 } 592 init_str(self, string: &str) -> id593 unsafe fn init_str(self, string: &str) -> id { 594 return msg_send![self, 595 initWithBytes:string.as_ptr() 596 length:string.len() 597 encoding:UTF8_ENCODING as id]; 598 } 599 len(self) -> usize600 unsafe fn len(self) -> usize { 601 msg_send![self, lengthOfBytesUsingEncoding:UTF8_ENCODING] 602 } 603 UTF8String(self) -> *const libc::c_char604 unsafe fn UTF8String(self) -> *const libc::c_char { 605 msg_send![self, UTF8String] 606 } 607 substringWithRange(self, range: NSRange) -> id608 unsafe fn substringWithRange(self, range: NSRange) -> id { 609 msg_send![self, substringWithRange:range] 610 } 611 } 612 613 pub trait NSDate: Sized { distantPast(_: Self) -> id614 unsafe fn distantPast(_: Self) -> id { 615 msg_send![class!(NSDate), distantPast] 616 } 617 distantFuture(_: Self) -> id618 unsafe fn distantFuture(_: Self) -> id { 619 msg_send![class!(NSDate), distantFuture] 620 } 621 } 622 623 impl NSDate for id { 624 625 } 626 627 #[repr(C)] 628 struct NSFastEnumerationState { 629 pub state: libc::c_ulong, 630 pub items_ptr: *mut id, 631 pub mutations_ptr: *mut libc::c_ulong, 632 pub extra: [libc::c_ulong; 5] 633 } 634 635 const NS_FAST_ENUM_BUF_SIZE: usize = 16; 636 637 pub struct NSFastIterator { 638 state: NSFastEnumerationState, 639 buffer: [id; NS_FAST_ENUM_BUF_SIZE], 640 mut_val: Option<libc::c_ulong>, 641 len: usize, 642 idx: usize, 643 object: id 644 } 645 646 impl Iterator for NSFastIterator { 647 type Item = id; 648 next(&mut self) -> Option<id>649 fn next(&mut self) -> Option<id> { 650 if self.idx >= self.len { 651 self.len = unsafe { 652 msg_send![self.object, countByEnumeratingWithState:&mut self.state objects:self.buffer.as_mut_ptr() count:NS_FAST_ENUM_BUF_SIZE] 653 }; 654 self.idx = 0; 655 } 656 657 let new_mut = unsafe { 658 *self.state.mutations_ptr 659 }; 660 661 if let Some(old_mut) = self.mut_val { 662 assert!(old_mut == new_mut, "The collection was mutated while being enumerated"); 663 } 664 665 if self.idx < self.len { 666 let object = unsafe { 667 *self.state.items_ptr.offset(self.idx as isize) 668 }; 669 self.mut_val = Some(new_mut); 670 self.idx += 1; 671 Some(object) 672 } else { 673 None 674 } 675 } 676 } 677 678 pub trait NSFastEnumeration: Sized { iter(self) -> NSFastIterator679 unsafe fn iter(self) -> NSFastIterator; 680 } 681 682 impl NSFastEnumeration for id { iter(self) -> NSFastIterator683 unsafe fn iter(self) -> NSFastIterator { 684 NSFastIterator { 685 state: NSFastEnumerationState { 686 state: 0, 687 items_ptr: ptr::null_mut(), 688 mutations_ptr: ptr::null_mut(), 689 extra: [0; 5] 690 }, 691 buffer: [nil; NS_FAST_ENUM_BUF_SIZE], 692 mut_val: None, 693 len: 0, 694 idx: 0, 695 object: self 696 } 697 } 698 } 699 700 pub trait NSRunLoop: Sized { currentRunLoop() -> Self701 unsafe fn currentRunLoop() -> Self; 702 performSelector_target_argument_order_modes_(self, aSelector: SEL, target: id, anArgument: id, order: NSUInteger, modes: id)703 unsafe fn performSelector_target_argument_order_modes_(self, 704 aSelector: SEL, 705 target: id, 706 anArgument: id, 707 order: NSUInteger, 708 modes: id); 709 } 710 711 impl NSRunLoop for id { currentRunLoop() -> id712 unsafe fn currentRunLoop() -> id { 713 msg_send![class!(NSRunLoop), currentRunLoop] 714 } 715 performSelector_target_argument_order_modes_(self, aSelector: SEL, target: id, anArgument: id, order: NSUInteger, modes: id)716 unsafe fn performSelector_target_argument_order_modes_(self, 717 aSelector: SEL, 718 target: id, 719 anArgument: id, 720 order: NSUInteger, 721 modes: id) { 722 msg_send![self, performSelector:aSelector 723 target:target 724 argument:anArgument 725 order:order 726 modes:modes] 727 } 728 } 729 730 bitflags! { 731 pub struct NSURLBookmarkCreationOptions: NSUInteger { 732 const NSURLBookmarkCreationPreferFileIDResolution = 1 << 8; 733 const NSURLBookmarkCreationMinimalBookmark = 1 << 9; 734 const NSURLBookmarkCreationSuitableForBookmarkFile = 1 << 10; 735 const NSURLBookmarkCreationWithSecurityScope = 1 << 11; 736 const NSURLBookmarkCreationSecurityScopeAllowOnlyReadAccess = 1 << 12; 737 } 738 } 739 740 pub type NSURLBookmarkFileCreationOptions = NSURLBookmarkCreationOptions; 741 742 bitflags! { 743 pub struct NSURLBookmarkResolutionOptions: NSUInteger { 744 const NSURLBookmarkResolutionWithoutUI = 1 << 8; 745 const NSURLBookmarkResolutionWithoutMounting = 1 << 9; 746 const NSURLBookmarkResolutionWithSecurityScope = 1 << 10; 747 } 748 } 749 750 751 pub trait NSURL: Sized { alloc(_: Self) -> id752 unsafe fn alloc(_: Self) -> id; 753 URLWithString_(_:Self, string: id) -> id754 unsafe fn URLWithString_(_:Self, string: id) -> id; initWithString_(self, string: id) -> id755 unsafe fn initWithString_(self, string: id) -> id; URLWithString_relativeToURL_(_:Self, string: id, url: id) -> id756 unsafe fn URLWithString_relativeToURL_(_:Self, string: id, url: id) -> id; initWithString_relativeToURL_(self, string: id, url: id) -> id757 unsafe fn initWithString_relativeToURL_(self, string: id, url: id) -> id; fileURLWithPath_isDirectory_(_:Self, path: id, is_dir: BOOL) -> id758 unsafe fn fileURLWithPath_isDirectory_(_:Self, path: id, is_dir: BOOL) -> id; initFileURLWithPath_isDirectory_(self, path: id, is_dir: BOOL) -> id759 unsafe fn initFileURLWithPath_isDirectory_(self, path: id, is_dir: BOOL) -> id; fileURLWithPath_relativeToURL_(_:Self, path: id, url: id) -> id760 unsafe fn fileURLWithPath_relativeToURL_(_:Self, path: id, url: id) -> id; initFileURLWithPath_relativeToURL_(self, path: id, url: id) -> id761 unsafe fn initFileURLWithPath_relativeToURL_(self, path: id, url: id) -> id; fileURLWithPath_isDirectory_relativeToURL_(_:Self, path: id, is_dir: BOOL, url: id) -> id762 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) -> id763 unsafe fn initFileURLWithPath_isDirectory_relativeToURL_(self, path: id, is_dir: BOOL, url: id) -> id; fileURLWithPath_(_:Self, path: id) -> id764 unsafe fn fileURLWithPath_(_:Self, path: id) -> id; initFileURLWithPath_(self, path: id) -> id765 unsafe fn initFileURLWithPath_(self, path: id) -> id; fileURLWithPathComponents_(_:Self, path_components: id ) -> id766 unsafe fn fileURLWithPathComponents_(_:Self, path_components: id /* (NSArray<NSString*>*) */) -> id; URLByResolvingAliasFileAtURL_options_error_(_:Self, url: id, options: NSURLBookmarkResolutionOptions, error: *mut id ) -> id767 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 ) -> id768 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 ) -> id769 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; 770 // unsafe fn fileURLWithFileSystemRepresentation_isDirectory_relativeToURL_ 771 // unsafe fn getFileSystemRepresentation_maxLength_ 772 // unsafe fn initFileURLWithFileSystemRepresentation_isDirectory_relativeToURL_ absoluteURLWithDataRepresentation_relativeToURL_(_:Self, data: id , url: id) -> id773 unsafe fn absoluteURLWithDataRepresentation_relativeToURL_(_:Self, data: id /* (NSData) */, url: id) -> id; initAbsoluteURLWithDataRepresentation_relativeToURL_(self, data: id , url: id) -> id774 unsafe fn initAbsoluteURLWithDataRepresentation_relativeToURL_(self, data: id /* (NSData) */, url: id) -> id; URLWithDataRepresentation_relativeToURL_(_:Self, data: id , url: id) -> id775 unsafe fn URLWithDataRepresentation_relativeToURL_(_:Self, data: id /* (NSData) */, url: id) -> id; initWithDataRepresentation_relativeToURL_(self, data: id , url: id) -> id776 unsafe fn initWithDataRepresentation_relativeToURL_(self, data: id /* (NSData) */, url: id) -> id; dataRepresentation(self) -> id777 unsafe fn dataRepresentation(self) -> id /* (NSData) */; 778 isEqual_(self, id: id) -> BOOL779 unsafe fn isEqual_(self, id: id) -> BOOL; 780 checkResourceIsReachableAndReturnError_(self, error: id ) -> BOOL781 unsafe fn checkResourceIsReachableAndReturnError_(self, error: id /* (NSError _Nullable) */) -> BOOL; isFileReferenceURL(self) -> BOOL782 unsafe fn isFileReferenceURL(self) -> BOOL; isFileURL(self) -> BOOL783 unsafe fn isFileURL(self) -> BOOL; 784 absoluteString(self) -> id785 unsafe fn absoluteString(self) -> id /* (NSString) */; absoluteURL(self) -> id786 unsafe fn absoluteURL(self) -> id /* (NSURL) */; baseURL(self) -> id787 unsafe fn baseURL(self) -> id /* (NSURL) */; 788 // unsafe fn fileSystemRepresentation fragment(self) -> id789 unsafe fn fragment(self) -> id /* (NSString) */; host(self) -> id790 unsafe fn host(self) -> id /* (NSString) */; lastPathComponent(self) -> id791 unsafe fn lastPathComponent(self) -> id /* (NSString) */; parameterString(self) -> id792 unsafe fn parameterString(self) -> id /* (NSString) */; password(self) -> id793 unsafe fn password(self) -> id /* (NSString) */; path(self) -> id794 unsafe fn path(self) -> id /* (NSString) */; pathComponents(self) -> id795 unsafe fn pathComponents(self) -> id /* (NSArray<NSString*>) */; pathExtension(self) -> id796 unsafe fn pathExtension(self) -> id /* (NSString) */; port(self) -> id797 unsafe fn port(self) -> id /* (NSNumber) */; query(self) -> id798 unsafe fn query(self) -> id /* (NSString) */; relativePath(self) -> id799 unsafe fn relativePath(self) -> id /* (NSString) */; relativeString(self) -> id800 unsafe fn relativeString(self) -> id /* (NSString) */; resourceSpecifier(self) -> id801 unsafe fn resourceSpecifier(self) -> id /* (NSString) */; scheme(self) -> id802 unsafe fn scheme(self) -> id /* (NSString) */; standardizedURL(self) -> id803 unsafe fn standardizedURL(self) -> id /* (NSURL) */; user(self) -> id804 unsafe fn user(self) -> id /* (NSString) */; 805 806 // unsafe fn resourceValuesForKeys_error_ 807 // unsafe fn getResourceValue_forKey_error_ 808 // unsafe fn setResourceValue_forKey_error_ 809 // unsafe fn setResourceValues_error_ 810 // unsafe fn removeAllCachedResourceValues 811 // unsafe fn removeCachedResourceValueForKey_ 812 // unsafe fn setTemporaryResourceValue_forKey_ NSURLResourceKey(self) -> id813 unsafe fn NSURLResourceKey(self) -> id /* (NSString) */; 814 filePathURL(self) -> id815 unsafe fn filePathURL(self) -> id; fileReferenceURL(self) -> id816 unsafe fn fileReferenceURL(self) -> id; URLByAppendingPathComponent_(self, path_component: id ) -> id817 unsafe fn URLByAppendingPathComponent_(self, path_component: id /* (NSString) */) -> id; URLByAppendingPathComponent_isDirectory_(self, path_component: id , is_dir: BOOL) -> id818 unsafe fn URLByAppendingPathComponent_isDirectory_(self, path_component: id /* (NSString) */, is_dir: BOOL) -> id; URLByAppendingPathExtension_(self, extension: id ) -> id819 unsafe fn URLByAppendingPathExtension_(self, extension: id /* (NSString) */) -> id; URLByDeletingLastPathComponent(self) -> id820 unsafe fn URLByDeletingLastPathComponent(self) -> id; URLByDeletingPathExtension(self) -> id821 unsafe fn URLByDeletingPathExtension(self) -> id; URLByResolvingSymlinksInPath(self) -> id822 unsafe fn URLByResolvingSymlinksInPath(self) -> id; URLByStandardizingPath(self) -> id823 unsafe fn URLByStandardizingPath(self) -> id; hasDirectoryPath(self) -> BOOL824 unsafe fn hasDirectoryPath(self) -> BOOL; 825 bookmarkDataWithContentsOfURL_error_(_:Self, url: id, error: id ) -> id826 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 ) -> id827 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) */; 828 // unsafe fn resourceValuesForKeys_fromBookmarkData_ writeBookmarkData_toURL_options_error_(_:Self, data: id , to_url: id, options: NSURLBookmarkFileCreationOptions, error: id ) -> id829 unsafe fn writeBookmarkData_toURL_options_error_(_:Self, data: id /* (NSData) */, to_url: id, options: NSURLBookmarkFileCreationOptions, error: id /* (NSError _Nullable) */) -> id; startAccessingSecurityScopedResource(self) -> BOOL830 unsafe fn startAccessingSecurityScopedResource(self) -> BOOL; stopAccessingSecurityScopedResource(self)831 unsafe fn stopAccessingSecurityScopedResource(self); NSURLBookmarkFileCreationOptions(self) -> NSURLBookmarkFileCreationOptions832 unsafe fn NSURLBookmarkFileCreationOptions(self) -> NSURLBookmarkFileCreationOptions; NSURLBookmarkCreationOptions(self) -> NSURLBookmarkCreationOptions833 unsafe fn NSURLBookmarkCreationOptions(self) -> NSURLBookmarkCreationOptions; NSURLBookmarkResolutionOptions(self) -> NSURLBookmarkResolutionOptions834 unsafe fn NSURLBookmarkResolutionOptions(self) -> NSURLBookmarkResolutionOptions; 835 836 // unsafe fn checkPromisedItemIsReachableAndReturnError_ 837 // unsafe fn getPromisedItemResourceValue_forKey_error_ 838 // unsafe fn promisedItemResourceValuesForKeys_error_ 839 840 // unsafe fn URLFromPasteboard_ 841 // unsafe fn writeToPasteboard_ 842 } 843 844 impl NSURL for id { alloc(_: Self) -> id845 unsafe fn alloc(_: Self) -> id { 846 msg_send![class!(NSURL), alloc] 847 } 848 URLWithString_(_:Self, string: id) -> id849 unsafe fn URLWithString_(_:Self, string: id) -> id { 850 msg_send![class!(NSURL), URLWithString:string] 851 } initWithString_(self, string: id) -> id852 unsafe fn initWithString_(self, string: id) -> id { 853 msg_send![self, initWithString:string] 854 } URLWithString_relativeToURL_(_:Self, string: id, url: id) -> id855 unsafe fn URLWithString_relativeToURL_(_:Self, string: id, url: id) -> id { 856 msg_send![class!(NSURL), URLWithString: string relativeToURL:url] 857 } initWithString_relativeToURL_(self, string: id, url: id) -> id858 unsafe fn initWithString_relativeToURL_(self, string: id, url: id) -> id { 859 msg_send![self, initWithString:string relativeToURL:url] 860 } fileURLWithPath_isDirectory_(_:Self, path: id, is_dir: BOOL) -> id861 unsafe fn fileURLWithPath_isDirectory_(_:Self, path: id, is_dir: BOOL) -> id { 862 msg_send![class!(NSURL), fileURLWithPath:path isDirectory:is_dir] 863 } initFileURLWithPath_isDirectory_(self, path: id, is_dir: BOOL) -> id864 unsafe fn initFileURLWithPath_isDirectory_(self, path: id, is_dir: BOOL) -> id { 865 msg_send![self, initFileURLWithPath:path isDirectory:is_dir] 866 } fileURLWithPath_relativeToURL_(_:Self, path: id, url: id) -> id867 unsafe fn fileURLWithPath_relativeToURL_(_:Self, path: id, url: id) -> id { 868 msg_send![class!(NSURL), fileURLWithPath:path relativeToURL:url] 869 } initFileURLWithPath_relativeToURL_(self, path: id, url: id) -> id870 unsafe fn initFileURLWithPath_relativeToURL_(self, path: id, url: id) -> id { 871 msg_send![self, initFileURLWithPath:path relativeToURL:url] 872 } fileURLWithPath_isDirectory_relativeToURL_(_:Self, path: id, is_dir: BOOL, url: id) -> id873 unsafe fn fileURLWithPath_isDirectory_relativeToURL_(_:Self, path: id, is_dir: BOOL, url: id) -> id { 874 msg_send![class!(NSURL), fileURLWithPath:path isDirectory:is_dir relativeToURL:url] 875 } initFileURLWithPath_isDirectory_relativeToURL_(self, path: id, is_dir: BOOL, url: id) -> id876 unsafe fn initFileURLWithPath_isDirectory_relativeToURL_(self, path: id, is_dir: BOOL, url: id) -> id { 877 msg_send![self, initFileURLWithPath:path isDirectory:is_dir relativeToURL:url] 878 } fileURLWithPath_(_:Self, path: id) -> id879 unsafe fn fileURLWithPath_(_:Self, path: id) -> id { 880 msg_send![class!(NSURL), fileURLWithPath:path] 881 } initFileURLWithPath_(self, path: id) -> id882 unsafe fn initFileURLWithPath_(self, path: id) -> id { 883 msg_send![self, initFileURLWithPath:path] 884 } fileURLWithPathComponents_(_:Self, path_components: id ) -> id885 unsafe fn fileURLWithPathComponents_(_:Self, path_components: id /* (NSArray<NSString*>*) */) -> id { 886 msg_send![class!(NSURL), fileURLWithPathComponents:path_components] 887 } URLByResolvingAliasFileAtURL_options_error_(_:Self, url: id, options: NSURLBookmarkResolutionOptions, error: *mut id ) -> id888 unsafe fn URLByResolvingAliasFileAtURL_options_error_(_:Self, url: id, options: NSURLBookmarkResolutionOptions, error: *mut id /* (NSError _Nullable) */) -> id { 889 msg_send![class!(NSURL), URLByResolvingAliasFileAtURL:url options:options error:error] 890 } URLByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(_:Self, data: id , options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id ) -> id891 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 { 892 msg_send![class!(NSURL), URLByResolvingBookmarkData:data options:options relativeToURL:relative_to_url bookmarkDataIsStale:is_stale error:error] 893 } initByResolvingBookmarkData_options_relativeToURL_bookmarkDataIsStale_error_(self, data: id , options: NSURLBookmarkResolutionOptions, relative_to_url: id, is_stale: *mut BOOL, error: *mut id ) -> id894 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 { 895 msg_send![self, initByResolvingBookmarkData:data options:options relativeToURL:relative_to_url bookmarkDataIsStale:is_stale error:error] 896 } 897 // unsafe fn fileURLWithFileSystemRepresentation_isDirectory_relativeToURL_ 898 // unsafe fn getFileSystemRepresentation_maxLength_ 899 // unsafe fn initFileURLWithFileSystemRepresentation_isDirectory_relativeToURL_ absoluteURLWithDataRepresentation_relativeToURL_(_:Self, data: id , url: id) -> id900 unsafe fn absoluteURLWithDataRepresentation_relativeToURL_(_:Self, data: id /* (NSData) */, url: id) -> id { 901 msg_send![class!(NSURL), absoluteURLWithDataRepresentation:data relativeToURL:url] 902 } initAbsoluteURLWithDataRepresentation_relativeToURL_(self, data: id , url: id) -> id903 unsafe fn initAbsoluteURLWithDataRepresentation_relativeToURL_(self, data: id /* (NSData) */, url: id) -> id { 904 msg_send![self, initAbsoluteURLWithDataRepresentation:data relativeToURL:url] 905 } URLWithDataRepresentation_relativeToURL_(_:Self, data: id , url: id) -> id906 unsafe fn URLWithDataRepresentation_relativeToURL_(_:Self, data: id /* (NSData) */, url: id) -> id { 907 msg_send![class!(NSURL), URLWithDataRepresentation:data relativeToURL:url] 908 } initWithDataRepresentation_relativeToURL_(self, data: id , url: id) -> id909 unsafe fn initWithDataRepresentation_relativeToURL_(self, data: id /* (NSData) */, url: id) -> id { 910 msg_send![self, initWithDataRepresentation:data relativeToURL:url] 911 } dataRepresentation(self) -> id912 unsafe fn dataRepresentation(self) -> id /* (NSData) */ { 913 msg_send![self, dataRepresentation] 914 } 915 isEqual_(self, id: id) -> BOOL916 unsafe fn isEqual_(self, id: id) -> BOOL { 917 msg_send![self, isEqual:id] 918 } 919 checkResourceIsReachableAndReturnError_(self, error: id ) -> BOOL920 unsafe fn checkResourceIsReachableAndReturnError_(self, error: id /* (NSError _Nullable) */) -> BOOL { 921 msg_send![self, checkResourceIsReachableAndReturnError:error] 922 } isFileReferenceURL(self) -> BOOL923 unsafe fn isFileReferenceURL(self) -> BOOL { 924 msg_send![self, isFileReferenceURL] 925 } isFileURL(self) -> BOOL926 unsafe fn isFileURL(self) -> BOOL { 927 msg_send![self, isFileURL] 928 } 929 absoluteString(self) -> id930 unsafe fn absoluteString(self) -> id /* (NSString) */ { 931 msg_send![self, absoluteString] 932 } absoluteURL(self) -> id933 unsafe fn absoluteURL(self) -> id /* (NSURL) */ { 934 msg_send![self, absoluteURL] 935 } baseURL(self) -> id936 unsafe fn baseURL(self) -> id /* (NSURL) */ { 937 msg_send![self, baseURL] 938 } 939 // unsafe fn fileSystemRepresentation fragment(self) -> id940 unsafe fn fragment(self) -> id /* (NSString) */ { 941 msg_send![self, fragment] 942 } host(self) -> id943 unsafe fn host(self) -> id /* (NSString) */ { 944 msg_send![self, host] 945 } lastPathComponent(self) -> id946 unsafe fn lastPathComponent(self) -> id /* (NSString) */ { 947 msg_send![self, lastPathComponent] 948 } parameterString(self) -> id949 unsafe fn parameterString(self) -> id /* (NSString) */ { 950 msg_send![self, parameterString] 951 } password(self) -> id952 unsafe fn password(self) -> id /* (NSString) */ { 953 msg_send![self, password] 954 } path(self) -> id955 unsafe fn path(self) -> id /* (NSString) */ { 956 msg_send![self, path] 957 } pathComponents(self) -> id958 unsafe fn pathComponents(self) -> id /* (NSArray<NSString*>) */ { 959 msg_send![self, pathComponents] 960 } pathExtension(self) -> id961 unsafe fn pathExtension(self) -> id /* (NSString) */ { 962 msg_send![self, pathExtension] 963 } port(self) -> id964 unsafe fn port(self) -> id /* (NSNumber) */ { 965 msg_send![self, port] 966 } query(self) -> id967 unsafe fn query(self) -> id /* (NSString) */ { 968 msg_send![self, query] 969 } relativePath(self) -> id970 unsafe fn relativePath(self) -> id /* (NSString) */ { 971 msg_send![self, relativePath] 972 } relativeString(self) -> id973 unsafe fn relativeString(self) -> id /* (NSString) */ { 974 msg_send![self, relativeString] 975 } resourceSpecifier(self) -> id976 unsafe fn resourceSpecifier(self) -> id /* (NSString) */ { 977 msg_send![self, resourceSpecifier] 978 } scheme(self) -> id979 unsafe fn scheme(self) -> id /* (NSString) */ { 980 msg_send![self, scheme] 981 } standardizedURL(self) -> id982 unsafe fn standardizedURL(self) -> id /* (NSURL) */ { 983 msg_send![self, standardizedURL] 984 } user(self) -> id985 unsafe fn user(self) -> id /* (NSString) */ { 986 msg_send![self, user] 987 } 988 989 // unsafe fn resourceValuesForKeys_error_ 990 // unsafe fn getResourceValue_forKey_error_ 991 // unsafe fn setResourceValue_forKey_error_ 992 // unsafe fn setResourceValues_error_ 993 // unsafe fn removeAllCachedResourceValues 994 // unsafe fn removeCachedResourceValueForKey_ 995 // unsafe fn setTemporaryResourceValue_forKey_ NSURLResourceKey(self) -> id996 unsafe fn NSURLResourceKey(self) -> id /* (NSString) */ { 997 msg_send![self, NSURLResourceKey] 998 } 999 filePathURL(self) -> id1000 unsafe fn filePathURL(self) -> id { 1001 msg_send![self, filePathURL] 1002 } fileReferenceURL(self) -> id1003 unsafe fn fileReferenceURL(self) -> id { 1004 msg_send![self, fileReferenceURL] 1005 } URLByAppendingPathComponent_(self, path_component: id ) -> id1006 unsafe fn URLByAppendingPathComponent_(self, path_component: id /* (NSString) */) -> id { 1007 msg_send![self, URLByAppendingPathComponent:path_component] 1008 } URLByAppendingPathComponent_isDirectory_(self, path_component: id , is_dir: BOOL) -> id1009 unsafe fn URLByAppendingPathComponent_isDirectory_(self, path_component: id /* (NSString) */, is_dir: BOOL) -> id { 1010 msg_send![self, URLByAppendingPathComponent:path_component isDirectory:is_dir] 1011 } URLByAppendingPathExtension_(self, extension: id ) -> id1012 unsafe fn URLByAppendingPathExtension_(self, extension: id /* (NSString) */) -> id { 1013 msg_send![self, URLByAppendingPathExtension:extension] 1014 } URLByDeletingLastPathComponent(self) -> id1015 unsafe fn URLByDeletingLastPathComponent(self) -> id { 1016 msg_send![self, URLByDeletingLastPathComponent] 1017 } URLByDeletingPathExtension(self) -> id1018 unsafe fn URLByDeletingPathExtension(self) -> id { 1019 msg_send![self, URLByDeletingPathExtension] 1020 } URLByResolvingSymlinksInPath(self) -> id1021 unsafe fn URLByResolvingSymlinksInPath(self) -> id { 1022 msg_send![self, URLByResolvingSymlinksInPath] 1023 } URLByStandardizingPath(self) -> id1024 unsafe fn URLByStandardizingPath(self) -> id { 1025 msg_send![self, URLByStandardizingPath] 1026 } hasDirectoryPath(self) -> BOOL1027 unsafe fn hasDirectoryPath(self) -> BOOL { 1028 msg_send![self, hasDirectoryPath] 1029 } 1030 bookmarkDataWithContentsOfURL_error_(_:Self, url: id, error: id ) -> id1031 unsafe fn bookmarkDataWithContentsOfURL_error_(_:Self, url: id, error: id /* (NSError _Nullable) */) -> id /* (NSData) */ { 1032 msg_send![class!(NSURL), bookmarkDataWithContentsOfURL:url error:error] 1033 } bookmarkDataWithOptions_includingResourceValuesForKeys_relativeToURL_error_(self, options: NSURLBookmarkCreationOptions, resource_value_for_keys: id , relative_to_url: id, error: id ) -> id1034 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) */ { 1035 msg_send![self, bookmarkDataWithOptions:options includingResourceValuesForKeys:resource_value_for_keys relativeToURL:relative_to_url error:error] 1036 } 1037 // unsafe fn resourceValuesForKeys_fromBookmarkData_ writeBookmarkData_toURL_options_error_(_:Self, data: id , to_url: id, options: NSURLBookmarkFileCreationOptions, error: id ) -> id1038 unsafe fn writeBookmarkData_toURL_options_error_(_:Self, data: id /* (NSData) */, to_url: id, options: NSURLBookmarkFileCreationOptions, error: id /* (NSError _Nullable) */) -> id { 1039 msg_send![class!(NSURL), writeBookmarkData:data toURL:to_url options:options error:error] 1040 } startAccessingSecurityScopedResource(self) -> BOOL1041 unsafe fn startAccessingSecurityScopedResource(self) -> BOOL { 1042 msg_send![self, startAccessingSecurityScopedResource] 1043 } stopAccessingSecurityScopedResource(self)1044 unsafe fn stopAccessingSecurityScopedResource(self) { 1045 msg_send![self, stopAccessingSecurityScopedResource] 1046 } NSURLBookmarkFileCreationOptions(self) -> NSURLBookmarkFileCreationOptions1047 unsafe fn NSURLBookmarkFileCreationOptions(self) -> NSURLBookmarkFileCreationOptions { 1048 msg_send![self, NSURLBookmarkFileCreationOptions] 1049 } NSURLBookmarkCreationOptions(self) -> NSURLBookmarkCreationOptions1050 unsafe fn NSURLBookmarkCreationOptions(self) -> NSURLBookmarkCreationOptions { 1051 msg_send![self, NSURLBookmarkCreationOptions] 1052 } NSURLBookmarkResolutionOptions(self) -> NSURLBookmarkResolutionOptions1053 unsafe fn NSURLBookmarkResolutionOptions(self) -> NSURLBookmarkResolutionOptions { 1054 msg_send![self, NSURLBookmarkResolutionOptions] 1055 } 1056 1057 // unsafe fn checkPromisedItemIsReachableAndReturnError_ 1058 // unsafe fn getPromisedItemResourceValue_forKey_error_ 1059 // unsafe fn promisedItemResourceValuesForKeys_error_ 1060 1061 // unsafe fn URLFromPasteboard_ 1062 // unsafe fn writeToPasteboard_ 1063 } 1064 1065 pub trait NSBundle: Sized { mainBundle() -> Self1066 unsafe fn mainBundle() -> Self; 1067 loadNibNamed_owner_topLevelObjects_(self, name: id , owner: id, topLevelObjects: *mut id ) -> BOOL1068 unsafe fn loadNibNamed_owner_topLevelObjects_(self, 1069 name: id /* NSString */, 1070 owner: id, 1071 topLevelObjects: *mut id /* NSArray */) -> BOOL; 1072 } 1073 1074 impl NSBundle for id { mainBundle() -> id1075 unsafe fn mainBundle() -> id { 1076 msg_send![class!(NSBundle), mainBundle] 1077 } 1078 loadNibNamed_owner_topLevelObjects_(self, name: id , owner: id, topLevelObjects: *mut id ) -> BOOL1079 unsafe fn loadNibNamed_owner_topLevelObjects_(self, 1080 name: id /* NSString */, 1081 owner: id, 1082 topLevelObjects: *mut id /* NSArray* */) -> BOOL { 1083 msg_send![self, loadNibNamed:name 1084 owner:owner 1085 topLevelObjects:topLevelObjects] 1086 } 1087 } 1088 1089 pub trait NSData: Sized { data(_: Self) -> id1090 unsafe fn data(_: Self) -> id { 1091 msg_send![class!(NSData), data] 1092 } 1093 dataWithBytes_length_(_: Self, bytes: *const c_void, length: NSUInteger) -> id1094 unsafe fn dataWithBytes_length_(_: Self, bytes: *const c_void, length: NSUInteger) -> id { 1095 msg_send![class!(NSData), dataWithBytes:bytes length:length] 1096 } 1097 dataWithBytesNoCopy_length_(_: Self, bytes: *const c_void, length: NSUInteger) -> id1098 unsafe fn dataWithBytesNoCopy_length_(_: Self, bytes: *const c_void, length: NSUInteger) -> id { 1099 msg_send![class!(NSData), dataWithBytesNoCopy:bytes length:length] 1100 } 1101 dataWithBytesNoCopy_length_freeWhenDone_(_: Self, bytes: *const c_void, length: NSUInteger, freeWhenDone: BOOL) -> id1102 unsafe fn dataWithBytesNoCopy_length_freeWhenDone_(_: Self, bytes: *const c_void, 1103 length: NSUInteger, freeWhenDone: BOOL) -> id { 1104 msg_send![class!(NSData), dataWithBytesNoCopy:bytes length:length freeWhenDone:freeWhenDone] 1105 } 1106 dataWithContentsOfFile_(_: Self, path: id) -> id1107 unsafe fn dataWithContentsOfFile_(_: Self, path: id) -> id { 1108 msg_send![class!(NSData), dataWithContentsOfFile:path] 1109 } 1110 dataWithContentsOfFile_options_error_(_: Self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id1111 unsafe fn dataWithContentsOfFile_options_error_(_: Self, path: id, mask: NSDataReadingOptions, 1112 errorPtr: *mut id) -> id { 1113 msg_send![class!(NSData), dataWithContentsOfFile:path options:mask error:errorPtr] 1114 } 1115 dataWithContentsOfURL_(_: Self, aURL: id) -> id1116 unsafe fn dataWithContentsOfURL_(_: Self, aURL: id) -> id { 1117 msg_send![class!(NSData), dataWithContentsOfURL:aURL] 1118 } 1119 dataWithContentsOfURL_options_error_(_: Self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id1120 unsafe fn dataWithContentsOfURL_options_error_(_: Self, aURL: id, mask: NSDataReadingOptions, 1121 errorPtr: *mut id) -> id { 1122 msg_send![class!(NSData), dataWithContentsOfURL:aURL options:mask error:errorPtr] 1123 } 1124 dataWithData_(_: Self, aData: id) -> id1125 unsafe fn dataWithData_(_: Self, aData: id) -> id { 1126 msg_send![class!(NSData), dataWithData:aData] 1127 } 1128 initWithBase64EncodedData_options_(self, base64Data: id, options: NSDataBase64DecodingOptions) -> id1129 unsafe fn initWithBase64EncodedData_options_(self, base64Data: id, options: NSDataBase64DecodingOptions) 1130 -> id; initWithBase64EncodedString_options_(self, base64String: id, options: NSDataBase64DecodingOptions) -> id1131 unsafe fn initWithBase64EncodedString_options_(self, base64String: id, options: NSDataBase64DecodingOptions) 1132 -> id; initWithBytes_length_(self, bytes: *const c_void, length: NSUInteger) -> id1133 unsafe fn initWithBytes_length_(self, bytes: *const c_void, length: NSUInteger) -> id; initWithBytesNoCopy_length_(self, bytes: *const c_void, length: NSUInteger) -> id1134 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), ()>) -> id1135 unsafe fn initWithBytesNoCopy_length_deallocator_(self, bytes: *const c_void, length: NSUInteger, 1136 deallocator: *mut Block<(*const c_void, NSUInteger), ()>) 1137 -> id; initWithBytesNoCopy_length_freeWhenDone_(self, bytes: *const c_void, length: NSUInteger, freeWhenDone: BOOL) -> id1138 unsafe fn initWithBytesNoCopy_length_freeWhenDone_(self, bytes: *const c_void, 1139 length: NSUInteger, freeWhenDone: BOOL) -> id; initWithContentsOfFile_(self, path: id) -> id1140 unsafe fn initWithContentsOfFile_(self, path: id) -> id; initWithContentsOfFile_options_error(self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id1141 unsafe fn initWithContentsOfFile_options_error(self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) 1142 -> id; initWithContentsOfURL_(self, aURL: id) -> id1143 unsafe fn initWithContentsOfURL_(self, aURL: id) -> id; initWithContentsOfURL_options_error_(self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id1144 unsafe fn initWithContentsOfURL_options_error_(self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) 1145 -> id; initWithData_(self, data: id) -> id1146 unsafe fn initWithData_(self, data: id) -> id; 1147 bytes(self) -> *const c_void1148 unsafe fn bytes(self) -> *const c_void; description(self) -> id1149 unsafe fn description(self) -> id; enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut BOOL), ()>)1150 unsafe fn enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut BOOL), ()>); getBytes_length_(self, buffer: *mut c_void, length: NSUInteger)1151 unsafe fn getBytes_length_(self, buffer: *mut c_void, length: NSUInteger); getBytes_range_(self, buffer: *mut c_void, range: NSRange)1152 unsafe fn getBytes_range_(self, buffer: *mut c_void, range: NSRange); subdataWithRange_(self, range: NSRange) -> id1153 unsafe fn subdataWithRange_(self, range: NSRange) -> id; rangeOfData_options_range_(self, dataToFind: id, options: NSDataSearchOptions, searchRange: NSRange) -> NSRange1154 unsafe fn rangeOfData_options_range_(self, dataToFind: id, options: NSDataSearchOptions, searchRange: NSRange) 1155 -> NSRange; 1156 base64EncodedDataWithOptions_(self, options: NSDataBase64EncodingOptions) -> id1157 unsafe fn base64EncodedDataWithOptions_(self, options: NSDataBase64EncodingOptions) -> id; base64EncodedStringWithOptions_(self, options: NSDataBase64EncodingOptions) -> id1158 unsafe fn base64EncodedStringWithOptions_(self, options: NSDataBase64EncodingOptions) -> id; 1159 isEqualToData_(self, otherData: id) -> id1160 unsafe fn isEqualToData_(self, otherData: id) -> id; length(self) -> NSUInteger1161 unsafe fn length(self) -> NSUInteger; 1162 writeToFile_atomically_(self, path: id, atomically: BOOL) -> BOOL1163 unsafe fn writeToFile_atomically_(self, path: id, atomically: BOOL) -> BOOL; writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL1164 unsafe fn writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL; writeToURL_atomically_(self, aURL: id, atomically: BOOL) -> BOOL1165 unsafe fn writeToURL_atomically_(self, aURL: id, atomically: BOOL) -> BOOL; writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL1166 unsafe fn writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL; 1167 } 1168 1169 impl NSData for id { initWithBase64EncodedData_options_(self, base64Data: id, options: NSDataBase64DecodingOptions) -> id1170 unsafe fn initWithBase64EncodedData_options_(self, base64Data: id, options: NSDataBase64DecodingOptions) 1171 -> id { 1172 msg_send![self, initWithBase64EncodedData:base64Data options:options] 1173 } 1174 initWithBase64EncodedString_options_(self, base64String: id, options: NSDataBase64DecodingOptions) -> id1175 unsafe fn initWithBase64EncodedString_options_(self, base64String: id, options: NSDataBase64DecodingOptions) 1176 -> id { 1177 msg_send![self, initWithBase64EncodedString:base64String options:options] 1178 } 1179 initWithBytes_length_(self, bytes: *const c_void, length: NSUInteger) -> id1180 unsafe fn initWithBytes_length_(self, bytes: *const c_void, length: NSUInteger) -> id { 1181 msg_send![self,initWithBytes:bytes length:length] 1182 } 1183 initWithBytesNoCopy_length_(self, bytes: *const c_void, length: NSUInteger) -> id1184 unsafe fn initWithBytesNoCopy_length_(self, bytes: *const c_void, length: NSUInteger) -> id { 1185 msg_send![self, initWithBytesNoCopy:bytes length:length] 1186 } 1187 initWithBytesNoCopy_length_deallocator_(self, bytes: *const c_void, length: NSUInteger, deallocator: *mut Block<(*const c_void, NSUInteger), ()>) -> id1188 unsafe fn initWithBytesNoCopy_length_deallocator_(self, bytes: *const c_void, length: NSUInteger, 1189 deallocator: *mut Block<(*const c_void, NSUInteger), ()>) 1190 -> id { 1191 msg_send![self, initWithBytesNoCopy:bytes length:length deallocator:deallocator] 1192 } 1193 initWithBytesNoCopy_length_freeWhenDone_(self, bytes: *const c_void, length: NSUInteger, freeWhenDone: BOOL) -> id1194 unsafe fn initWithBytesNoCopy_length_freeWhenDone_(self, bytes: *const c_void, 1195 length: NSUInteger, freeWhenDone: BOOL) -> id { 1196 msg_send![self, initWithBytesNoCopy:bytes length:length freeWhenDone:freeWhenDone] 1197 } 1198 initWithContentsOfFile_(self, path: id) -> id1199 unsafe fn initWithContentsOfFile_(self, path: id) -> id { 1200 msg_send![self, initWithContentsOfFile:path] 1201 } 1202 initWithContentsOfFile_options_error(self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id1203 unsafe fn initWithContentsOfFile_options_error(self, path: id, mask: NSDataReadingOptions, errorPtr: *mut id) 1204 -> id { 1205 msg_send![self, initWithContentsOfFile:path options:mask error:errorPtr] 1206 } 1207 initWithContentsOfURL_(self, aURL: id) -> id1208 unsafe fn initWithContentsOfURL_(self, aURL: id) -> id { 1209 msg_send![self, initWithContentsOfURL:aURL] 1210 } 1211 initWithContentsOfURL_options_error_(self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) -> id1212 unsafe fn initWithContentsOfURL_options_error_(self, aURL: id, mask: NSDataReadingOptions, errorPtr: *mut id) 1213 -> id { 1214 msg_send![self, initWithContentsOfURL:aURL options:mask error:errorPtr] 1215 } 1216 initWithData_(self, data: id) -> id1217 unsafe fn initWithData_(self, data: id) -> id { 1218 msg_send![self, initWithData:data] 1219 } 1220 bytes(self) -> *const c_void1221 unsafe fn bytes(self) -> *const c_void { 1222 msg_send![self, bytes] 1223 } 1224 description(self) -> id1225 unsafe fn description(self) -> id { 1226 msg_send![self, description] 1227 } 1228 enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut BOOL), ()>)1229 unsafe fn enumerateByteRangesUsingBlock_(self, block: *mut Block<(*const c_void, NSRange, *mut BOOL), ()>) { 1230 msg_send![self, enumerateByteRangesUsingBlock:block] 1231 } 1232 getBytes_length_(self, buffer: *mut c_void, length: NSUInteger)1233 unsafe fn getBytes_length_(self, buffer: *mut c_void, length: NSUInteger) { 1234 msg_send![self, getBytes:buffer length:length] 1235 } 1236 getBytes_range_(self, buffer: *mut c_void, range: NSRange)1237 unsafe fn getBytes_range_(self, buffer: *mut c_void, range: NSRange) { 1238 msg_send![self, getBytes:buffer range:range] 1239 } 1240 subdataWithRange_(self, range: NSRange) -> id1241 unsafe fn subdataWithRange_(self, range: NSRange) -> id { 1242 msg_send![self, subdataWithRange:range] 1243 } 1244 rangeOfData_options_range_(self, dataToFind: id, options: NSDataSearchOptions, searchRange: NSRange) -> NSRange1245 unsafe fn rangeOfData_options_range_(self, dataToFind: id, options: NSDataSearchOptions, searchRange: NSRange) 1246 -> NSRange { 1247 msg_send![self, rangeOfData:dataToFind options:options range:searchRange] 1248 } 1249 base64EncodedDataWithOptions_(self, options: NSDataBase64EncodingOptions) -> id1250 unsafe fn base64EncodedDataWithOptions_(self, options: NSDataBase64EncodingOptions) -> id { 1251 msg_send![self, base64EncodedDataWithOptions:options] 1252 } 1253 base64EncodedStringWithOptions_(self, options: NSDataBase64EncodingOptions) -> id1254 unsafe fn base64EncodedStringWithOptions_(self, options: NSDataBase64EncodingOptions) -> id { 1255 msg_send![self, base64EncodedStringWithOptions:options] 1256 } 1257 isEqualToData_(self, otherData: id) -> id1258 unsafe fn isEqualToData_(self, otherData: id) -> id { 1259 msg_send![self, isEqualToData:otherData] 1260 } 1261 length(self) -> NSUInteger1262 unsafe fn length(self) -> NSUInteger { 1263 msg_send![self, length] 1264 } 1265 writeToFile_atomically_(self, path: id, atomically: BOOL) -> BOOL1266 unsafe fn writeToFile_atomically_(self, path: id, atomically: BOOL) -> BOOL { 1267 msg_send![self, writeToFile:path atomically:atomically] 1268 } 1269 writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL1270 unsafe fn writeToFile_options_error_(self, path: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL { 1271 msg_send![self, writeToFile:path options:mask error:errorPtr] 1272 } 1273 writeToURL_atomically_(self, aURL: id, atomically: BOOL) -> BOOL1274 unsafe fn writeToURL_atomically_(self, aURL: id, atomically: BOOL) -> BOOL { 1275 msg_send![self, writeToURL:aURL atomically:atomically] 1276 } 1277 writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL1278 unsafe fn writeToURL_options_error_(self, aURL: id, mask: NSDataWritingOptions, errorPtr: *mut id) -> BOOL { 1279 msg_send![self, writeToURL:aURL options:mask error:errorPtr] 1280 } 1281 } 1282 1283 bitflags! { 1284 pub struct NSDataReadingOptions: libc::c_ulonglong { 1285 const NSDataReadingMappedIfSafe = 1 << 0; 1286 const NSDataReadingUncached = 1 << 1; 1287 const NSDataReadingMappedAlways = 1 << 3; 1288 } 1289 } 1290 1291 bitflags! { 1292 pub struct NSDataBase64EncodingOptions: libc::c_ulonglong { 1293 const NSDataBase64Encoding64CharacterLineLength = 1 << 0; 1294 const NSDataBase64Encoding76CharacterLineLength = 1 << 1; 1295 const NSDataBase64EncodingEndLineWithCarriageReturn = 1 << 4; 1296 const NSDataBase64EncodingEndLineWithLineFeed = 1 << 5; 1297 } 1298 } 1299 1300 bitflags! { 1301 pub struct NSDataBase64DecodingOptions: libc::c_ulonglong { 1302 const NSDataBase64DecodingIgnoreUnknownCharacters = 1 << 0; 1303 } 1304 } 1305 1306 bitflags! { 1307 pub struct NSDataWritingOptions: libc::c_ulonglong { 1308 const NSDataWritingAtomic = 1 << 0; 1309 const NSDataWritingWithoutOverwriting = 1 << 1; 1310 } 1311 } 1312 1313 bitflags! { 1314 pub struct NSDataSearchOptions: libc::c_ulonglong { 1315 const NSDataSearchBackwards = 1 << 0; 1316 const NSDataSearchAnchored = 1 << 1; 1317 } 1318 } 1319