2022-03-01 02:53:31 +11:00
|
|
|
use clap_sys::host::clap_host;
|
|
|
|
use clap_sys::plugin::{clap_plugin, clap_plugin_descriptor};
|
2022-03-01 02:31:49 +11:00
|
|
|
use clap_sys::plugin_factory::clap_plugin_factory;
|
|
|
|
use std::marker::PhantomData;
|
2022-03-01 02:53:31 +11:00
|
|
|
use std::os::raw::c_char;
|
2022-03-01 02:31:49 +11:00
|
|
|
|
|
|
|
use crate::ClapPlugin;
|
|
|
|
|
|
|
|
/// The plugin's factory. Initialized using a lazy_static from the entry poiunt's `get_factory()`
|
|
|
|
/// function. From this point onwards we don't need to generate code with macros anymore.
|
|
|
|
#[doc(hidden)]
|
2022-03-01 02:50:16 +11:00
|
|
|
#[repr(C)]
|
2022-03-01 02:31:49 +11:00
|
|
|
pub struct Factory<P: ClapPlugin> {
|
2022-03-01 02:50:16 +11:00
|
|
|
// Keep the vtable as the first field so we can do a simple pointer cast
|
|
|
|
pub clap_plugin_factory: clap_plugin_factory,
|
|
|
|
|
2022-03-01 02:31:49 +11:00
|
|
|
/// The type will be used for constructing plugin instances later.
|
|
|
|
_phantom: PhantomData<P>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<P: ClapPlugin> Default for Factory<P> {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
2022-03-01 02:50:16 +11:00
|
|
|
clap_plugin_factory: clap_plugin_factory {
|
|
|
|
get_plugin_count: Self::get_plugin_count,
|
2022-03-01 02:53:31 +11:00
|
|
|
get_plugin_descriptor: Self::get_plugin_descriptor,
|
|
|
|
create_plugin: Self::create_plugin,
|
2022-03-01 02:50:16 +11:00
|
|
|
},
|
2022-03-01 02:31:49 +11:00
|
|
|
_phantom: PhantomData,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<P: ClapPlugin> Factory<P> {
|
2022-03-01 02:50:16 +11:00
|
|
|
unsafe extern "C" fn get_plugin_count(_factory: *const clap_plugin_factory) -> u32 {
|
|
|
|
1
|
2022-03-01 02:31:49 +11:00
|
|
|
}
|
2022-03-01 02:53:31 +11:00
|
|
|
|
|
|
|
unsafe extern "C" fn get_plugin_descriptor(
|
|
|
|
factory: *const clap_plugin_factory,
|
|
|
|
index: u32,
|
|
|
|
) -> *const clap_plugin_descriptor {
|
|
|
|
todo!()
|
|
|
|
}
|
|
|
|
|
|
|
|
unsafe extern "C" fn create_plugin(
|
|
|
|
factory: *const clap_plugin_factory,
|
|
|
|
host: *const clap_host,
|
|
|
|
plugin_id: *const c_char,
|
|
|
|
) -> *const clap_plugin {
|
|
|
|
todo!()
|
|
|
|
}
|
2022-03-01 02:31:49 +11:00
|
|
|
}
|