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

Allow most CGContext methods to be usable from a immutable reference and expose several more methods #250

Merged
merged 2 commits into from Aug 30, 2018

Conversation

@mehcode
Copy link
Contributor

mehcode commented Aug 20, 2018

If this is too much to submit at once, please tell me. This is what I've got left to send in and I'm unsure where to break it up more.


This change is Reviewable

@jrmuizel
Copy link
Collaborator

jrmuizel commented Aug 21, 2018

Shouldn't these methods be taking a &mut? They are very much mutating the underlying object.

@mehcode
Copy link
Contributor Author

mehcode commented Aug 21, 2018

I don't disagree with you. I don't think foreign_type! { supports generating a CGContextRefMut structure to use though. Several clearly mutating methods that exist already took &self so I was copying what was there. Properly adding _RefMut and &mut self sounds like a breaking change and a large endeavor.


As a data point, my use case here is:

My use case here is:

let context: *mut Object = msg_send![class!(NSGraphicsContext), currentContext];
let context: *mut c_void = msg_send![context, CGContext];

let context = CGContextRef::from_ptr(context as *mut _);

context.save();
// [...]
context.restore();

Before this PR I was using CGContext::wrap_under_ and mem::forget.

@jrmuizel
Copy link
Collaborator

jrmuizel commented Aug 30, 2018

Ok. Let's take this.
@bors-servo r+

@bors-servo
Copy link
Contributor

bors-servo commented Aug 30, 2018

📌 Commit 8052ba2 has been approved by jrmuizel

@bors-servo
Copy link
Contributor

bors-servo commented Aug 30, 2018

Testing commit 8052ba2 with merge c9616cc...

bors-servo added a commit that referenced this pull request Aug 30, 2018
Allow most CGContext methods to be usable from a immutable reference and expose several more methods

If this is too much to submit at once, please tell me. This is what I've got left to send in and I'm unsure where to break it up more.

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

bors-servo commented Aug 30, 2018

☀️ Test successful - status-travis
Approved by: jrmuizel
Pushing c9616cc to master...

@bors-servo bors-servo merged commit 8052ba2 into servo:master Aug 30, 2018
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
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

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