1
0
Fork 0

Add a function for getting pointers from params

So we don't need to implement this ad-hoc. That would even be impossible
to do correctly inside of the proc macro.
This commit is contained in:
Robbert van der Helm 2022-01-25 19:54:27 +01:00
parent 4cd9c6d3d3
commit 3f2f932a55

View file

@ -144,7 +144,7 @@ impl ParamPtr {
} }
macro_rules! impl_plainparam { macro_rules! impl_plainparam {
($ty:ty) => { ($ty:ident) => {
impl $ty { impl $ty {
/// Set this parameter based on a string. Returns whether the updating succeeded. That /// Set this parameter based on a string. Returns whether the updating succeeded. That
/// can fail if the string cannot be parsed. /// can fail if the string cannot be parsed.
@ -176,6 +176,11 @@ macro_rules! impl_plainparam {
pub fn set_normalized_value(&mut self, normalized: f32) { pub fn set_normalized_value(&mut self, normalized: f32) {
self.value = self.range.unnormalize(normalized); self.value = self.range.unnormalize(normalized);
} }
/// Implementation detail for implementing [Params]. This should not be used directly.
pub fn as_ptr(&self) -> ParamPtr {
ParamPtr::$ty(self as *const $ty as *mut $ty)
}
} }
}; };
} }