Use inheritance to remove This data member#347
Conversation
83e6f77 to
125a0cc
Compare
ZXShady
left a comment
There was a problem hiding this comment.
remove unnecessary ternary and static cast
9f12818 to
960142f
Compare
ZXShady
left a comment
There was a problem hiding this comment.
readd assert and remove unnecessary static_cast and ternary
0a60a3d to
600f98d
Compare
|
Could this cause issues from pure C side or a binding using CSFML? We're only returning pointers and have typedefs, but now the fundamental type is no longer just a simple struct 🤔 |
|
the type was never a simple struct to begin with the sf Classes had non standard layout types inside it. and the typedef is to make the pointer opaque. the user has no knowledge of what the pointer is |
600f98d to
091e8e8
Compare
Notice how this PR only touches the |
6f4649d to
9b8a498
Compare
|
I get that, I was just wondering if there's any limit to that. We now had opaque pointers to structs, but now it's a derived type. Can this have any side effect from a C/binding point of view? |
|
No, there’s no way for users to notice anything has changed. |
9b8a498 to
b5d73e3
Compare
It's reasonable to say that, for example, sfImage _is_ an sf::Image. This "is-a" relationship is what inheritance does a very good job modeling. By using inheritance to implement CSFML types in terms of their SFML counterpart, we get code that is simpler and easier to read. We also avoid some of the extra "dancing" required to construct a CSFML type from an SFML type. This improves the encapsulation of our CSFML implementation.
b5d73e3 to
2aaa81f
Compare
Closes #222
It's reasonable to say that, for example,
sfImageis ansf::Image. This "is-a" relationship is what inheritance does a very good job modeling. By using inheritance to implement CSFML types in terms of their SFML counterpart, we get code that is simpler and easier to read.