From 3f2f932a557358b3d5cf05e174ca34c24413b0a3 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 25 Jan 2022 19:54:27 +0100 Subject: [PATCH] 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. --- nih_plug/src/params.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nih_plug/src/params.rs b/nih_plug/src/params.rs index ea9d224d..237af635 100644 --- a/nih_plug/src/params.rs +++ b/nih_plug/src/params.rs @@ -144,7 +144,7 @@ impl ParamPtr { } macro_rules! impl_plainparam { - ($ty:ty) => { + ($ty:ident) => { impl $ty { /// Set this parameter based on a string. Returns whether the updating succeeded. That /// 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) { 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) + } } }; }