A number of callback functions associated with the CFRunLoop types are
allowed to be NULL to evoke default behavior.
Prior to this commit the definition of those structs prevented passing
in null which meant resorting to transmute or other tricks to
effectively set null, but with recent compiler versions the compiler
emits `ud2` instructions and triggers a fault at runtime.
The correct resolution for this is to define these fields as `Option`al
callbacks and that is what this commit does.
I've used this approach successfully here in another project:
Refs: https://github.com/wez/wezterm/commit/398f333c32fb1ff4ccd9cc001a66ae22522eb60c
I've bumped up the version for the crate as part of this commit
because it effectively changes the API around these structs.
Properly make core_text::font::Font be Send and Sync
The Apple documentation says:
> All individual functions in Core Text are thread-safe. Font objects (CTFont,
> CTFontDescriptor, and associated objects) can be used simultaneously by
> multiple operations, work queues, or threads. However, the layout objects
> (CTTypesetter, CTFramesetter, CTRun, CTLine, CTFrame, and associated objects)
> should be used in a single operation, work queue, or thread.
https://developer.apple.com/documentation/coretext
The Apple documentation says:
> All individual functions in Core Text are thread-safe. Font objects (CTFont,
> CTFontDescriptor, and associated objects) can be used simultaneously by
> multiple operations, work queues, or threads. However, the layout objects
> (CTTypesetter, CTFramesetter, CTRun, CTLine, CTFrame, and associated objects)
> should be used in a single operation, work queue, or thread.
https://developer.apple.com/documentation/coretext
Add CGConfigureDisplayMirrorOfDisplay
Hi there,
One more for Core Graphics from me. This time adds [`CGConfigureDisplayMirrorOfDisplay`](https://developer.apple.com/documentation/coregraphics/1454531-cgconfiguredisplaymirrorofdispla) and [`kCGNullDirectDisplay`](https://developer.apple.com/documentation/coregraphics/kcgnulldirectdisplay) APIs.
`CGConfigureDisplayMirrorOfDisplay`:
``` objc
func CGConfigureDisplayMirrorOfDisplay(_ config: CGDisplayConfigRef?,
_ display: CGDirectDisplayID,
_ master: CGDirectDisplayID) -> CGError
```
`kCGNullDirectDisplay`:
``` objc
#define kCGNullDirectDisplay
```
Not sure about the `null_display` function, but at least it kind of aligns with `main`. Maybe I should just call it `null`.
Let me know what do you think.
Add CGConfigureDisplayOrigin
Adds a wrapper for [CGConfigureDisplayOrigin](https://developer.apple.com/documentation/coregraphics/1454090-cgconfiguredisplayorigin) which has the following signature:
``` c
func CGConfigureDisplayOrigin(_ config: CGDisplayConfigRef?,
_ display: CGDirectDisplayID,
_ x: Int32,
_ y: Int32) -> CGError
```
Please let me know if there is anything I can improve here.
I'm currently working on the small utility heavily relying on CoreGraphics API, so expect more of those to come as I go. :)
Fixes so the compiler can infer msg_send! return types
Currently, due to a quirk in Rust's type inference interacting with the structure of the `msg_send!` macro, a `()` return type will be inferred when the compiler cannot otherwise determine the return type. This behavior is expected to change, and in the future could resolve to a `!` return type, which results in undefined behavior.
Linting has previously been added for this in rust-lang/rust#39216, but it did not catch these cases due to SSheldon/rust-objc#62. An upcoming version of objc will be fixed to stop hiding these errors, at which point they will become compile errors.
This change fixes these errors and allows cocoa to compile with the fixed version of objc.
Currently, due to a quirk in Rust's type inference interacting with the
structure of the msg_send! macro, a () return type will be inferred when
the compiler cannot otherwise determine the return type. This behavior
is expected to change, and in the future could resolve to a ! return
type, which results in undefined behavior.
Linting has previously been added for this in rust-lang/rust#39216, but
it did not catch these cases due to SSheldon/rust-objc#62. An upcoming
version of objc will be fixed to stop hiding these errors, at which
point they will become compile errors.
This change fixes these errors and allows cocoa to compile with the
fixed version of objc.