Move VST3 pointer check macros to a module
This commit is contained in:
parent
556bec7c0b
commit
427c7674b9
2 changed files with 35 additions and 17 deletions
|
@ -42,6 +42,9 @@ use vst3_sys::vst::{
|
||||||
use vst3_sys::VST3;
|
use vst3_sys::VST3;
|
||||||
use widestring::U16CStr;
|
use widestring::U16CStr;
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
mod util;
|
||||||
|
|
||||||
use crate::buffer::Buffer;
|
use crate::buffer::Buffer;
|
||||||
use crate::context::{EventLoop, GuiContext, MainThreadExecutor, OsEventLoop, ProcessContext};
|
use crate::context::{EventLoop, GuiContext, MainThreadExecutor, OsEventLoop, ProcessContext};
|
||||||
use crate::param::internals::ParamPtr;
|
use crate::param::internals::ParamPtr;
|
||||||
|
@ -83,23 +86,6 @@ lazy_static! {
|
||||||
static ref BYPASS_PARAM_HASH: u32 = hash_param_id(BYPASS_PARAM_ID);
|
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<T>` so we can safely use our event loop API.
|
/// The actual wrapper bits. We need this as an `Arc<T>` 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
|
/// Since we can't combine that with VST3's interior reference counting this just has to be moved to
|
||||||
/// its own struct.
|
/// its own struct.
|
||||||
|
|
32
src/wrapper/vst3/util.rs
Normal file
32
src/wrapper/vst3/util.rs
Normal file
|
@ -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 <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
/// 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;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue