Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd bindings for `CFFileDescriptor` #84
Conversation
|
Pretty much every function in that PR that takes a raw pointer should be marked unsafe. |
|
I don't know if I'm getting right your point but I changed all(two) functions take raw pointer as unsafe. |
|
|
|
I just updated this PR with rebased/reorganized commits and some changes. |
|
These bindings look like a useful improvement. Thanks! |
| closeOnInvalidate: bool, | ||
| callout: CFFileDescriptorCallBack, | ||
| context: *const CFFileDescriptorContext) -> CFFileDescriptor { | ||
| let fd_ref = CFFileDescriptorCreate(kCFAllocatorDefault, |
This comment has been minimized.
This comment has been minimized.
| fd, | ||
| closeOnInvalidate as Boolean, | ||
| callout, | ||
| if let Some(context) = context { |
This comment has been minimized.
This comment has been minimized.
jdm
Jan 17, 2018
Member
Let's do this instead:
let context = context.map_or(ptr::null(), |c| c as *const _);| impl CFRunLoopSource { | ||
| pub fn from_file_descriptor(fd: &CFFileDescriptor, order: CFIndex) -> CFRunLoopSource { | ||
| unsafe { | ||
| let source_ref = CFFileDescriptorCreateRunLoopSource(kCFAllocatorDefault, fd.0, order); |
This comment has been minimized.
This comment has been minimized.
| _callback_types: CFOptionFlags, | ||
| _info_ptr: *mut c_void) { | ||
| // should never be called | ||
| assert!(false); |
This comment has been minimized.
This comment has been minimized.
| let cf_fd = CFFileDescriptor::new(raw_fd, true, never_callback, None); | ||
|
|
||
| assert!(cf_fd.valid()); | ||
| cf_fd.invalidate(); |
This comment has been minimized.
This comment has been minimized.
| let cf_fd = CFFileDescriptor::new(raw_fd, false, never_callback, None); | ||
|
|
||
| assert!(cf_fd.valid()); | ||
| cf_fd.invalidate(); |
This comment has been minimized.
This comment has been minimized.
| } | ||
|
|
||
| extern "C" fn callback(_f: CFFileDescriptorRef, callback_types: CFOptionFlags, info_ptr: *mut c_void) { | ||
| assert!(info_ptr != ptr::null_mut()); |
This comment has been minimized.
This comment has been minimized.
| assert_eq!(info.value, kCFFileDescriptorWriteCallBack); | ||
|
|
||
| info.value = 0; | ||
| cf_fd.disable_callbacks(kCFFileDescriptorReadCallBack|kCFFileDescriptorWriteCallBack); |
This comment has been minimized.
This comment has been minimized.
|
Applied changes as requested. |
|
@bors-servo r+ |
|
@bors-servo r+ |
|
@bors-servo r+ |
|
|
Add bindings for `CFFileDescriptor` This pull request adds implementation of `CFFileDescriptor` and `CFRunLoopSource` related API. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-foundation-rs/84) <!-- Reviewable:end -->
|
|
Use typed wrap_under_{create,get}_rule() functions
Just some minor cleanup; no functional changes.
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/core-text-rs/84)
<!-- Reviewable:end -->
trlim commentedSep 3, 2016
•
edited by larsbergstrom
This pull request adds implementation of
CFFileDescriptorandCFRunLoopSourcerelated API.This change is