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

Revamp and modernize the Core Foundation APIs. #23

Merged
merged 1 commit into from Nov 15, 2013
Merged

Revamp and modernize the Core Foundation APIs. #23

merged 1 commit into from Nov 15, 2013

Conversation

@pcwalton
Copy link
Contributor

pcwalton commented Nov 2, 2013

This change redoes the way Core Foundation works to make the API
smaller, safer, and easier to use. In particular:

  • Deriving custom types is now based on structs, not on making a
    type alias of CFWrapper.
  • The attempts at type safety for CFArray and CFDictionary were
    removed as not pulling their weight (IMHO).
  • Methods that are really unsafe (in particular wrap_owned and
    wrap_shared) are now marked unsafe.
  • wrap_owned has been renamed to wrap_under_create_rule and
    wrap_shared has been renamed to wrap_under_get_rule, to match
    Apple's documentation.
  • borrow_ref and friends have been simplified into
    as_concrete_TypeRef() and as_TypeRef().
  • Dictionaries, arrays, and sets now assume that their elements are
    Core Foundation objects. The old code tried not to assume that,
    but ended up assuming that anyway in a couple of places.
  • CFStrings can be converted from Rust types with the FromStr
    trait. CFNumbers can be converted to and from Rust types with
    ToPrimitive and FromPrimitive, eliminating the duplication of
    functionality inside this module.

r? @metajack

@pcwalton
Copy link
Contributor Author

pcwalton commented Nov 2, 2013

Oops, sorry, pushed this onto the wrong branch. I'll remove the branch if and when this gets merged.

This change redoes the way Core Foundation works to make the API
smaller, safer, and easier to use. In particular:

* Deriving custom types is now based on `struct`s, not on making a
  type alias of `CFWrapper`.

* The attempts at type safety for `CFArray` and `CFDictionary` were
  removed as not pulling their weight (IMHO).

* Methods that are really unsafe (in particular `wrap_owned` and
  `wrap_shared`) are now marked `unsafe`.

* `wrap_owned` has been renamed to `wrap_under_create_rule` and
  `wrap_shared` has been renamed to `wrap_under_get_rule`, to match
  Apple's documentation.

* `borrow_ref` and friends have been simplified into
  `as_concrete_TypeRef()` and `as_TypeRef()`.

* Dictionaries, arrays, and sets now assume that their elements are
  Core Foundation objects. The old code tried not to assume that,
  but ended up assuming that anyway in a couple of places.

* `CFString`s can be converted from Rust types with the `FromStr`
  trait. `CFNumber`s can be converted to and from Rust types with
  `ToPrimitive` and `FromPrimitive`, eliminating the duplication of
  functionality inside this module.
@metajack

This comment has been minimized.

Copy link
Contributor

metajack commented on dc1184e Nov 15, 2013

r+

metajack added a commit that referenced this pull request Nov 15, 2013
Revamp and modernize the Core Foundation APIs.
@metajack metajack merged commit b41b972 into master Nov 15, 2013
@frewsxcv frewsxcv deleted the revamp branch Apr 20, 2016
jdm pushed a commit that referenced this pull request Feb 1, 2018
jdm pushed a commit that referenced this pull request Feb 1, 2018
jdm pushed a commit that referenced this pull request Feb 1, 2018
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

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