-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
317 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,77 @@ | ||
use crate::options::*; | ||
use lv2_atom::prelude::Int; | ||
use lv2_options::features::OptionsList; | ||
use urid::{Map, URIDCollection, URID}; | ||
|
||
#[derive(URIDCollection)] | ||
pub struct BufferSizesURIDCollection { | ||
pub atom_int: URID<Int>, | ||
pub min_block_length: URID<MinBlockLength>, | ||
pub max_block_length: URID<MaxBlockLength>, | ||
pub nominal_block_length: URID<NominalBlockLength>, | ||
pub sequence_size: URID<SequenceSize>, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, Default)] | ||
pub struct BufferSizes { | ||
min_block_length: Option<u32>, | ||
max_block_length: Option<u32>, | ||
nominal_block_length: Option<u32>, | ||
sequence_size: Option<u32>, | ||
min_block_length: Option<MinBlockLength>, | ||
max_block_length: Option<MaxBlockLength>, | ||
nominal_block_length: Option<NominalBlockLength>, | ||
sequence_size: Option<SequenceSize>, | ||
} | ||
|
||
impl BufferSizes { | ||
pub fn from_options(options: &OptionsList, mapper: &impl Map) -> Self { | ||
let collection = match mapper.populate_collection() { | ||
Some(c) => c, | ||
None => return Default::default(), | ||
}; | ||
BufferSizes::from_options_with_urids(options, &collection) | ||
const _: () = { | ||
extern crate lv2_options as _lv2_options; | ||
extern crate urid as _urid; | ||
use _lv2_options::collection::{OptionsCollection, OptionsSerializationContext}; | ||
use _lv2_options::features::OptionsList; | ||
use _lv2_options::request::OptionRequestList; | ||
use _lv2_options::OptionsError; | ||
|
||
use _urid::*; | ||
|
||
#[derive(_urid::URIDCollection)] | ||
pub struct BufferSizesSerializationContext { | ||
pub min_block_length: <Option<MinBlockLength> as OptionsCollection>::Serializer, | ||
pub max_block_length: <Option<MaxBlockLength> as OptionsCollection>::Serializer, | ||
pub nominal_block_length: <Option<NominalBlockLength> as OptionsCollection>::Serializer, | ||
pub sequence_size: <Option<SequenceSize> as OptionsCollection>::Serializer, | ||
} | ||
|
||
pub fn from_options_with_urids( | ||
options: &OptionsList, | ||
urids: &BufferSizesURIDCollection, | ||
) -> Self { | ||
todo!() | ||
/* | ||
BufferSizes { | ||
min_block_length: options | ||
.read(urids.min_block_length, urids.atom_int, ()) | ||
.map(|x| x.get()), | ||
max_block_length: options | ||
.read(urids.max_block_length, urids.atom_int, ()) | ||
.map(|x| x.get()), | ||
nominal_block_length: options | ||
.read(urids.nominal_block_length, urids.atom_int, ()) | ||
.map(|x| x.get()), | ||
sequence_size: options | ||
.read(urids.sequence_size, urids.atom_int, ()) | ||
.map(|x| x.get()), | ||
}*/ | ||
impl OptionsCollection for BufferSizes { | ||
type Serializer = BufferSizesSerializationContext; | ||
} | ||
} | ||
|
||
impl OptionsSerializationContext<BufferSizes> for BufferSizesSerializationContext { | ||
fn deserialize_new(&self, options: &OptionsList) -> Result<BufferSizes, OptionsError> { | ||
Ok(BufferSizes { | ||
min_block_length: self.min_block_length.deserialize_new(options)?, | ||
max_block_length: self.max_block_length.deserialize_new(options)?, | ||
nominal_block_length: self.nominal_block_length.deserialize_new(options)?, | ||
sequence_size: self.sequence_size.deserialize_new(options)?, | ||
}) | ||
} | ||
|
||
fn deserialize_to( | ||
&self, | ||
destination: &mut BufferSizes, | ||
options: &OptionsList, | ||
) -> Result<(), OptionsError> { | ||
self.min_block_length | ||
.deserialize_to(&mut destination.min_block_length, options)?; | ||
self.max_block_length | ||
.deserialize_to(&mut destination.max_block_length, options)?; | ||
self.nominal_block_length | ||
.deserialize_to(&mut destination.nominal_block_length, options)?; | ||
self.sequence_size | ||
.deserialize_to(&mut destination.sequence_size, options)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
fn respond_to_requests<'a>( | ||
&self, | ||
options: &'a BufferSizes, | ||
requests: &mut OptionRequestList<'a>, | ||
) -> Result<(), OptionsError> { | ||
self.min_block_length | ||
.respond_to_requests(&options.min_block_length, requests)?; | ||
self.max_block_length | ||
.respond_to_requests(&options.max_block_length, requests)?; | ||
self.nominal_block_length | ||
.respond_to_requests(&options.nominal_block_length, requests)?; | ||
self.sequence_size | ||
.respond_to_requests(&options.sequence_size, requests)?; | ||
|
||
Ok(()) | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
mod buffer_sizes; | ||
pub mod options; | ||
|
||
pub use buffer_sizes::{BufferSizes, BufferSizesURIDCollection}; | ||
pub use buffer_sizes::BufferSizes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.