diff --git a/src/wrapper/vst3.rs b/src/wrapper/vst3.rs index 3edc9833..ee3aa03f 100644 --- a/src/wrapper/vst3.rs +++ b/src/wrapper/vst3.rs @@ -42,6 +42,9 @@ use vst3_sys::vst::{ use vst3_sys::VST3; use widestring::U16CStr; +#[macro_use] +mod util; + use crate::buffer::Buffer; use crate::context::{EventLoop, GuiContext, MainThreadExecutor, OsEventLoop, ProcessContext}; use crate::param::internals::ParamPtr; @@ -83,23 +86,6 @@ lazy_static! { static ref BYPASS_PARAM_HASH: u32 = hash_param_id(BYPASS_PARAM_ID); } -/// Early exit out of a VST3 function when one of the passed pointers is null -macro_rules! check_null_ptr { - ($ptr:expr $(, $ptrs:expr)* $(, )?) => { - check_null_ptr_msg!("Null pointer passed to function", $ptr $(, $ptrs)*) - }; -} - -/// The same as [check_null_ptr!], but with a custom message. -macro_rules! check_null_ptr_msg { - ($msg:expr, $ptr:expr $(, $ptrs:expr)* $(, )?) => { - if $ptr.is_null() $(|| $ptrs.is_null())* { - nih_debug_assert_failure!($msg); - return kInvalidArgument; - } - }; -} - /// The actual wrapper bits. We need this as an `Arc` so we can safely use our event loop API. /// Since we can't combine that with VST3's interior reference counting this just has to be moved to /// its own struct. diff --git a/src/wrapper/vst3/util.rs b/src/wrapper/vst3/util.rs new file mode 100644 index 00000000..a4156e70 --- /dev/null +++ b/src/wrapper/vst3/util.rs @@ -0,0 +1,32 @@ +// nih-plug: plugins, but rewritten in Rust +// Copyright (C) 2022 Robbert van der Helm +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +/// Early exit out of a VST3 function when one of the passed pointers is null +macro_rules! check_null_ptr { + ($ptr:expr $(, $ptrs:expr)* $(, )?) => { + check_null_ptr_msg!("Null pointer passed to function", $ptr $(, $ptrs)*) + }; +} + +/// The same as [check_null_ptr!], but with a custom message. +macro_rules! check_null_ptr_msg { + ($msg:expr, $ptr:expr $(, $ptrs:expr)* $(, )?) => { + if $ptr.is_null() $(|| $ptrs.is_null())* { + nih_debug_assert_failure!($msg); + return kInvalidArgument; + } + }; +}