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
Model: Unify PartialEq #311
Conversation
176b972
to
b0ea397
Compare
b0ea397
to
02dcb06
Compare
I think that while this change is source incompatible, it is good - especially the centralization of the ptr_eq. This sheds a bit of light on the fact that there are quite some ways of constructing a modelhandle :). Is that why you removed the From? |
@tronical: Yes, this definitely needs some thinking before it can go in. Is there some documentation on the cpp_cmake parts somewhere? Looks like I broke those. |
It seems to fail deep in the interpreter api through the cmake build. I’ll try to write something about how that plays together on Monday. Sorry about this can of worms :) |
I think the heart of the error is this:
which indicates that the new |
Ah, but |
Make sure to never export the Value enum. It might drag in all sorts of unrelated types (as it happened in #311). We have ValueOpaque for that, so exclude Value from the export config explicitly. However since we expose the Value *pointers* for the struct iterators, at least provide a forward declaration.
Yeah, somehow this patch triggered that cbindgen thought that |
46fe958
to
c459c58
Compare
@tronical: Ok, just did a fresh push, let's see what happens. |
Yay, it’s green now. Only two things left IMO: (1) typo in the commit message (Hanlde-> Handle) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tagged the change as breaking_change
since this change the public API.
The changes here are overall good. But we haven't decide if the next release of the sixtyfps
crate will be 0.1.1 or 0.2.
I guess we should wait a bit to see if we have other reasons to break the source compatibility before merging this.
Also changes to public API deserve a changelog entry.
(It would be nice if there was a CI check that could tell if we are breaking semver or touching the public API)
#[derive( | ||
PartialEq, derive_more::Deref, derive_more::DerefMut, derive_more::From, derive_more::Into, | ||
)] | ||
pub struct ModelHandle<T>(pub Option<SharedModel<T>>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if there is a way to remove the inner pub
Anyway, this is a public API breakage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I added something about this to the CHANGELOG now.
sixtyfps_runtime/corelib/model.rs
Outdated
// We can get: | ||
// * false positives: Two different `Model`s get considered the same, even though they are not. | ||
// For this the `self` pointer need to point to the same place. That can only happen if | ||
// `Self` is `()`, which does not make sense for a `Model`. So we ignore this case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self could very well be ()
.
We could imagine for example a impl Model for ()
that always returns 0 elements.
or a struct MyStaticModel; impl Model for MyStaticModel { ... }
.
But anyway, this cannot happen that two different model are considered the same, because the Rc adds an allocation for the refcounts and always allocates. so the data pointer will always be different anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ogoffart: You are way deeper in this rabbit hole than me, so did I understand this correctly?
But I think you are right, this lint might actually be wrong: I went ahead and filed rust-lang/rust-clippy#7461 with my current understanding. I am pretty sure I missed something, but maybe some improvement to the explanation of that clippy lint will fall out of this:-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the text, I hope it is a bit better now.
Implement PartialEq for Rc<Model> and use that for ModelHandle as well as Value<Model> Wrap a Rc<Model> into a SharedModel and implement PartialEq for that. Wrap Option<SharedModel> into the ModuleHandle as well as Value::Model.
c459c58
to
533a21f
Compare
Implement PartialEq for Rc and use that for ModelHandle as well
as Value
Wrap a Rc into a SharedModel and implement PartialEq for that.
Wrap Option into the ModuleHandle as well as Value::Model.