Skip to content

Commit 89dc9b7

Browse files
committed
Fix everything
1 parent 859ed73 commit 89dc9b7

File tree

13 files changed

+141
-87
lines changed

13 files changed

+141
-87
lines changed

atom/src/atoms/scalar.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ impl<A: ScalarAtom> Atom for A {
101101
}
102102
}
103103

104+
impl<A: ScalarAtom> BackAsSpace for A {
105+
fn back_as_space<'a>(handle: <Self::ReadHandle as AtomHandle<'a>>::Handle) -> &'a [u8] {
106+
AlignedSpace::from_slice(::core::slice::from_ref(handle)).as_bytes()
107+
}
108+
}
109+
104110
/// Macro to atomate the definition of scalar atoms.
105111
macro_rules! make_scalar_atom {
106112
($atom:ty, $internal:ty, $uri:expr, $urid:expr) => {

atom/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ pub trait Atom: UriBound {
133133
fn init(writer: AtomSpaceWriter) -> Option<<Self::WriteHandle as AtomHandle>::Handle>;
134134
}
135135

136+
pub trait BackAsSpace: Atom {
137+
fn back_as_space<'a>(handle: <Self::ReadHandle as AtomHandle<'a>>::Handle) -> &'a [u8];
138+
}
139+
136140
/// An atom of yet unknown type.
137141
///
138142
/// This is used by reading handles that have to return a reference to an atom, but can not check it's type. This struct contains a `Space` containing the header and the body of the atom and can identify/read the atom from it.

buf-size/src/buffer_sizes.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ impl BufferSizes {
3333
options: &OptionsList,
3434
urids: &BufferSizesURIDCollection,
3535
) -> Self {
36+
todo!()
37+
/*
3638
BufferSizes {
3739
min_block_length: options
3840
.read(urids.min_block_length, urids.atom_int, ())
@@ -46,6 +48,6 @@ impl BufferSizes {
4648
sequence_size: options
4749
.read(urids.sequence_size, urids.atom_int, ())
4850
.map(|x| x.get()),
49-
}
51+
}*/
5052
}
5153
}

buf-size/src/options.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use lv2_atom::Atom;
1+
use lv2_atom::{Atom, AtomHandle};
22
use urid::UriBound;
33

44
/// A simple macro to automate the definition of the u32 options available in this module
@@ -18,17 +18,19 @@ macro_rules! make_option {
1818
}
1919

2020
impl lv2_options::OptionType for $name {
21-
type AtomType = lv2_atom::scalar::Int;
21+
type AtomType = lv2_atom::atoms::scalar::Int;
2222

2323
#[inline]
24-
fn from_option_value<'a>(
25-
value: <lv2_atom::scalar::Int as Atom<'a, 'a>>::ReadHandle,
24+
fn from_option_value(
25+
value: <<lv2_atom::atoms::scalar::Int as Atom>::ReadHandle as AtomHandle>::Handle,
2626
) -> Option<Self> {
2727
Some(Self((*value)))
2828
}
2929

3030
#[inline]
31-
fn as_option_value<'a>(&'a self) -> <lv2_atom::scalar::Int as Atom<'a, 'a>>::ReadHandle {
31+
fn as_option_value<'a>(
32+
&'a self,
33+
) -> <<lv2_atom::atoms::scalar::Int as Atom>::ReadHandle as AtomHandle>::Handle {
3234
&self.0
3335
}
3436
}

options/src/collection.rs

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,43 @@
1-
use urid::{URIDCollection, Map};
2-
use crate::request::OptionRequestList;
3-
use crate::{OptionsError, OptionValue};
41
use crate::list::OptionsList;
52
use crate::option::request::OptionRequest;
3+
use crate::request::OptionRequestList;
4+
use crate::{OptionValue, OptionsError};
5+
use urid::{Map, URIDCollection};
66

77
pub trait OptionsCollection: Sized {
88
type Serializer;
99

1010
#[inline]
1111
fn new_serializer<'a, M: Map + ?Sized>(map: &M) -> Option<OptionsSerializer<Self>>
12-
where Self::Serializer: OptionsSerializationContext<'a, Self> { // FIXME
13-
Some(OptionsSerializer { inner: Self::Serializer::from_map(map)? })
12+
where
13+
Self::Serializer: OptionsSerializationContext<'a, Self>,
14+
{
15+
// FIXME
16+
Some(OptionsSerializer {
17+
inner: Self::Serializer::from_map(map)?,
18+
})
1419
}
1520
}
1621

1722
#[doc(hidden)]
1823
pub mod implementation {
19-
use crate::{OptionType, OptionsError, OptionValue};
20-
use std::marker::PhantomData;
21-
use urid::{URID, URIDCollection, Map};
22-
use crate::collection::{OptionsSerializationContext, OptionsCollection};
24+
use crate::collection::{OptionsCollection, OptionsSerializationContext};
2325
use crate::option::request::OptionRequest;
26+
use crate::{OptionType, OptionValue, OptionsError};
27+
use lv2_atom::atoms::scalar::ScalarAtom;
2428
use lv2_atom::{Atom, BackAsSpace};
25-
use lv2_atom::scalar::ScalarAtom;
29+
use std::marker::PhantomData;
30+
use urid::{Map, URIDCollection, URID};
2631

2732
pub struct OptionTypeSerializationContext<O: OptionType> {
2833
option_urid: URID<O>,
29-
option_type_atom_urid: URID<O::AtomType>
34+
option_type_atom_urid: URID<O::AtomType>,
3035
}
3136

3237
impl<'a, O: OptionType> OptionsCollection for O
33-
where <O as OptionType>::AtomType: BackAsSpace<'a>,
34-
<<O as OptionType>::AtomType as Atom<'a, 'a>>::ReadParameter: Default {
38+
where
39+
<O as OptionType>::AtomType: BackAsSpace,
40+
{
3541
type Serializer = OptionTypeSerializationContext<O>;
3642
}
3743

@@ -46,25 +52,34 @@ pub mod implementation {
4652
}
4753

4854
impl<'a, O: OptionType> OptionsSerializationContext<'a, O> for OptionTypeSerializationContext<O>
49-
where <O as OptionType>::AtomType: BackAsSpace<'a>,
50-
<<O as OptionType>::AtomType as Atom<'a, 'a>>::ReadParameter: Default {
55+
where
56+
<O as OptionType>::AtomType: BackAsSpace,
57+
{
5158
#[inline]
5259
fn deserialize_new(&self, option: &'a OptionValue) -> Option<O> {
53-
option.read(self.option_urid, self.option_type_atom_urid, Default::default())
60+
option.read(self.option_urid, self.option_type_atom_urid)
5461
}
5562

56-
fn deserialize_to(&self, options: &mut O, option: &OptionValue) -> Result<(), OptionsError> {
63+
fn deserialize_to(
64+
&self,
65+
options: &mut O,
66+
option: &OptionValue,
67+
) -> Result<(), OptionsError> {
5768
todo!()
5869
}
5970

60-
fn respond_to_request<'r>(&self, options: &'r O, requests: &'r mut OptionRequest) -> Result<(), OptionsError> {
71+
fn respond_to_request<'r>(
72+
&self,
73+
options: &'r O,
74+
requests: &'r mut OptionRequest,
75+
) -> Result<(), OptionsError> {
6176
todo!()
6277
}
6378
}
6479
}
6580

6681
pub struct OptionsSerializer<T: OptionsCollection> {
67-
inner: T::Serializer
82+
inner: T::Serializer,
6883
}
6984

7085
impl<T: OptionsCollection> OptionsSerializer<T> {
@@ -76,7 +91,11 @@ impl<T: OptionsCollection> OptionsSerializer<T> {
7691
todo!()
7792
}
7893

79-
pub fn respond_to_requests<'a>(&self, options: &T, requests: &mut OptionRequestList) -> Result<(), OptionsError> {
94+
pub fn respond_to_requests<'a>(
95+
&self,
96+
options: &T,
97+
requests: &mut OptionRequestList,
98+
) -> Result<(), OptionsError> {
8099
todo!()
81100
}
82101
}
@@ -86,5 +105,9 @@ pub trait OptionsSerializationContext<'a, T: OptionsCollection>: URIDCollection
86105

87106
fn deserialize_to(&self, options: &mut T, option: &OptionValue) -> Result<(), OptionsError>;
88107

89-
fn respond_to_request<'r>(&self, options: &'r T, request: &'r mut OptionRequest) -> Result<(), OptionsError>;
90-
}
108+
fn respond_to_request<'r>(
109+
&self,
110+
options: &'r T,
111+
request: &'r mut OptionRequest,
112+
) -> Result<(), OptionsError>;
113+
}

options/src/extensions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! Contains the [`OptionsInterface`](crate::extensions::OptionsInterface) extension interface.
22
use crate::features::OptionsList;
3+
use crate::option::request::OptionRequestList;
34
use crate::OptionsError;
45
use lv2_core::feature::Feature;
56
use lv2_core::plugin::PluginInstance;
@@ -9,7 +10,6 @@ use std::ffi::c_void;
910
use std::marker::PhantomData;
1011
use std::panic::AssertUnwindSafe;
1112
use urid::UriBound;
12-
use crate::option::request::OptionRequestList;
1313

1414
/// An interface to allow dynamically setting options from the host.
1515
///

options/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
//! See the [LV2 Options documentation](http://lv2plug.in/ns/ext/options) for more information.
1818
1919
pub use option::error::OptionsError;
20-
pub use option::OptionType;
2120
pub use option::request;
2221
pub use option::subject::Subject;
2322
pub use option::value::OptionValue;
23+
pub use option::OptionType;
2424

25+
pub mod collection;
2526
pub mod extensions;
26-
mod option;
2727
pub mod list;
28-
pub mod collection;
28+
mod option;
2929

3030
/// Contains the [`OptionsList`](features::OptionsList) feature.
3131
pub mod features {
@@ -34,8 +34,8 @@ pub mod features {
3434

3535
/// Prelude of `lv2_options` for wildcard usage.
3636
pub mod prelude {
37+
pub use crate::extensions::{OptionsDescriptor, OptionsInterface};
3738
pub use crate::list::OptionsList;
3839
pub use crate::OptionsError;
3940
pub use crate::Subject;
40-
pub use crate::extensions::{OptionsDescriptor, OptionsInterface};
41-
}
41+
}

options/src/list.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ impl<'f> OptionsList<'f> {
1616
/// Returns an iterator over the slice.
1717
#[inline]
1818
pub fn iter(&self) -> OptionsListIter<'f> {
19-
OptionsListIter { current: self.options_list }
19+
OptionsListIter {
20+
current: self.options_list,
21+
}
2022
}
2123
}
2224

@@ -45,7 +47,7 @@ impl<'a> IntoIterator for &'a OptionsList<'a> {
4547
}
4648

4749
pub struct OptionsListIter<'a> {
48-
current: &'a lv2_sys::LV2_Options_Option
50+
current: &'a lv2_sys::LV2_Options_Option,
4951
}
5052

5153
impl<'a> Iterator for OptionsListIter<'a> {

options/src/option.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use lv2_atom::Atom;
1+
use lv2_atom::{Atom, AtomHandle};
22
use urid::UriBound;
33

44
pub mod error;
5+
pub mod request;
56
pub mod subject;
67
pub mod value;
7-
pub mod request;
88

99
/// A trait representing an LV2 Option type.
1010
///
@@ -32,17 +32,21 @@ pub mod request;
3232
/// }
3333
/// ```
3434
pub trait OptionType: UriBound + Sized {
35-
type AtomType: UriBound;
35+
type AtomType: Atom;
3636

3737
/// Creates a new instance of this Option type from a given atom value.
3838
///
3939
/// This method may return `None` if the Atom's value is invalid for this option type.
4040
///
4141
/// This method is used to store option data when received by the host.
42-
fn from_option_value<'a>(value: <Self::AtomType as Atom<'a, 'a>>::ReadHandle) -> Option<Self> where Self::AtomType: Atom<'a, 'a>;
42+
fn from_option_value(
43+
value: <<<Self as OptionType>::AtomType as Atom>::ReadHandle as AtomHandle>::Handle,
44+
) -> Option<Self>;
4345

4446
/// Returns this Option's value as a reference to its Atom type.
4547
///
4648
/// This method is used to send the option's value to the host when it is requested.
47-
fn as_option_value<'a>(&'a self) -> <Self::AtomType as Atom<'a, 'a>>::ReadHandle where Self::AtomType: Atom<'a, 'a>;
49+
fn as_option_value(
50+
&self,
51+
) -> <<<Self as OptionType>::AtomType as Atom>::ReadHandle as AtomHandle>::Handle;
4852
}

options/src/option/error.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ impl OptionsError {
1919
pub(crate) fn result_into_raw(value: Result<(), OptionsError>) -> lv2_sys::LV2_Options_Status {
2020
match value {
2121
Ok(()) => lv2_sys::LV2_Options_Status_LV2_OPTIONS_SUCCESS,
22-
Err(OptionsError::BadSubject) => lv2_sys::LV2_Options_Status_LV2_OPTIONS_ERR_BAD_SUBJECT,
22+
Err(OptionsError::BadSubject) => {
23+
lv2_sys::LV2_Options_Status_LV2_OPTIONS_ERR_BAD_SUBJECT
24+
}
2325
Err(OptionsError::BadKey) => lv2_sys::LV2_Options_Status_LV2_OPTIONS_ERR_BAD_KEY,
2426
Err(OptionsError::BadValue) => lv2_sys::LV2_Options_Status_LV2_OPTIONS_ERR_BAD_VALUE,
2527
Err(_) => lv2_sys::LV2_Options_Status_LV2_OPTIONS_ERR_UNKNOWN,
@@ -30,7 +32,9 @@ impl OptionsError {
3032
pub(crate) fn from_raw(status: lv2_sys::LV2_Options_Status) -> Result<(), OptionsError> {
3133
match status {
3234
lv2_sys::LV2_Options_Status_LV2_OPTIONS_SUCCESS => Ok(()),
33-
lv2_sys::LV2_Options_Status_LV2_OPTIONS_ERR_BAD_SUBJECT => Err(OptionsError::BadSubject),
35+
lv2_sys::LV2_Options_Status_LV2_OPTIONS_ERR_BAD_SUBJECT => {
36+
Err(OptionsError::BadSubject)
37+
}
3438
lv2_sys::LV2_Options_Status_LV2_OPTIONS_ERR_BAD_KEY => Err(OptionsError::BadKey),
3539
lv2_sys::LV2_Options_Status_LV2_OPTIONS_ERR_BAD_VALUE => Err(OptionsError::BadValue),
3640
_ => Err(OptionsError::Unknown),
@@ -44,7 +48,7 @@ impl Display for OptionsError {
4448
OptionsError::Unknown => "Unknown error while reading/writing Option",
4549
OptionsError::BadSubject => "Unknown Option subject",
4650
OptionsError::BadKey => "Unknown Option key",
47-
OptionsError::BadValue => "Invalid Option value"
51+
OptionsError::BadValue => "Invalid Option value",
4852
};
4953

5054
write!(f, "{}", msg)

0 commit comments

Comments
 (0)