This creates a VstPtr type which wraps a raw vtable pointer, and replaces the method calls and types that return pointers to interfaces with it. Consumers are required to do a nullptr check by upgrading to ComRc using VstPtr::upgrade(&self), which returns Option<ComRc>. For example, in the again example:
let param_changes: &VstPtr<IParameterChanges> = &(*data).input_param_changes;
if let Some(param_changes) = param_changes.upgrade() {
let num_params_changed: VstPtr<IParamValueQueue> = param_changes.get_parameter_count();
for i in 0..num_params_changed {
let param_queue = param_changes.get_parameter_data(i);
if let Some(param_queue) = param_queue.upgrade() {
// ...
The implementation is a transparent wrapper around a pointer to a vtable, which maintains the ABI.
This creates a
VstPtr
type which wraps a raw vtable pointer, and replaces the method calls and types that return pointers to interfaces with it. Consumers are required to do anullptr
check by upgrading toComRc
usingVstPtr::upgrade(&self)
, which returnsOption<ComRc>
. For example, in theagain
example:The implementation is a transparent wrapper around a pointer to a vtable, which maintains the ABI.
The only difference between this and
ComPtr
is that we allow VstPtrs to be null, and check when upgrading.