Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a type parameter to CFArray #127

Merged
merged 1 commit into from Nov 25, 2017
Merged

Conversation

@jrmuizel
Copy link
Collaborator

jrmuizel commented Nov 17, 2017

This puts us on a path to greater type safety when using CFArrays


This change is Reviewable

@glennw
Copy link
Member

glennw commented Nov 17, 2017

r? @pcwalton or @jdm

impl Drop for CFArray {
/// A trait describing how to convert from the stored *const c_void to the desired T
pub trait FromVoid<T> {
fn from_void(x: *const c_void) -> T;

This comment has been minimized.

@jdm

jdm Nov 17, 2017

Member

The type parameter seems redundant when we could just use Self instead.

This comment has been minimized.

@jrmuizel

jrmuizel Nov 25, 2017

Author Collaborator

Fixed

This puts us on a path to greater type safety when using CFArrays
@jrmuizel jrmuizel force-pushed the jrmuizel:cfarray-type branch from 85310fb to 0253ee2 Nov 25, 2017
@jdm
Copy link
Member

jdm commented Nov 25, 2017

@bors-servo
Copy link
Contributor

bors-servo commented Nov 25, 2017

📌 Commit 0253ee2 has been approved by jdm

@bors-servo
Copy link
Contributor

bors-servo commented Nov 25, 2017

Testing commit 0253ee2 with merge f9e8545...

bors-servo added a commit that referenced this pull request Nov 25, 2017
Add a type parameter to CFArray

This puts us on a path to greater type safety when using CFArrays

<!-- 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/127)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Nov 25, 2017

☀️ Test successful - status-travis
Approved by: jdm
Pushing f9e8545 to master...

@bors-servo bors-servo merged commit 0253ee2 into servo:master Nov 25, 2017
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
impl Drop for CFArray {
/// A trait describing how to convert from the stored *const c_void to the desired T
pub trait FromVoid {
fn from_void(x: *const c_void) -> Self;

This comment has been minimized.

@nox

nox Nov 26, 2017

Member

This should be unsafe.


impl FromVoid for CFType {
fn from_void(x: *const c_void) -> CFType {
unsafe { TCFType::wrap_under_get_rule(mem::transmute(x)) }

This comment has been minimized.

@nox

nox Nov 26, 2017

Member

This is unsound, one can pass 0xdeadbeef as *const c_void or any other arbitrary and trigger UB.

@jrmuizel
Copy link
Collaborator Author

jrmuizel commented Nov 27, 2017

Does #134 address this sufficiently?

bors-servo added a commit to servo/core-graphics-rs that referenced this pull request Nov 27, 2017
Add functions to get font tag information

This depends on servo/core-foundation-rs#127 for CFArray<u32>. I'm just putting it up for reference right now.

<!-- 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-graphics-rs/104)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.