-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Utility fixups #12977
Utility fixups #12977
Conversation
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.
Maybe create a templated struct overriding operator*() for seemless transision. (returning a memory operations wrapping object) I thought about doing it in vm::ptr in the past.
I think vm::ref is suitable for this, with minor additions. |
1c109be
to
e1ca9ed
Compare
constexpr aref& operator=(const T& value) const | ||
{ | ||
write_to_ptr<T>(value, m_ptr); | ||
} |
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.
Missing return value.
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.
Fixed, thanks
de8dc3e
to
5fc15a4
Compare
I guess I'll repurpose vm::ref in another PR |
rpcs3/util/types.hpp
Outdated
} | ||
|
||
template <typename T, typename U> | ||
constexpr void write_to_ptr(const T& value, U&& array, usz pos = 0) |
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.
Swapping argument places is more consistent with vm::writeX methods.
It can also have an overload which takes a single argument of array referece paired with index. So you can write wtite_to_ptr({array, 1}, data)
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.
That's right, fixed
Tested a handful of games, they work just fine |
Doing std::bit_cast on a "span". Should be usable in constexpr.
Type `aref`: reference wrapper
Implemented some TODOs and some new functionality: tool to avoid UB and able to replace misused reinterpret_cast and utils::bless. Done by avoiding referencing trivial objects in memory or arrays and just use memcpy on reads and writes.