Skip to content

Commit

Permalink
Fix str overrun issue, see dtolnay/cxx#224.
Browse files Browse the repository at this point in the history
  • Loading branch information
tychedelia committed May 6, 2023
1 parent 4664c58 commit c1c928c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
10 changes: 5 additions & 5 deletions plugins/sin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ struct SinChopParams {
/// Struct representing our CHOP's state
pub struct SinChop {
execute_count: u64,
// params: SinChopParams,
params: SinChopParams,
}

/// Impl block providing default constructor for plugin
impl SinChop {
pub(crate) fn new() -> Self {
Self { execute_count: 0,
// params: Default::default()
params: Default::default()
}
}
}
Expand All @@ -29,9 +29,9 @@ impl ChopInfo for SinChop {
}

impl Chop for SinChop {
// fn get_params_mut(&mut self) -> Option<Box<&mut dyn OperatorParams>> {
// Some(Box::new(&mut self.params))
// }
fn get_params_mut(&mut self) -> Option<Box<&mut dyn OperatorParams>> {
Some(Box::new(&mut self.params))
}

fn get_output_info(&self, info: &mut ChopOutputInfo, input: &OperatorInput) -> bool {
info.num_channels = 3;
Expand Down
2 changes: 0 additions & 2 deletions td-rs-param/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,10 @@ macro_rules! impl_param_float {
( $t:ty ) => {
impl Param for $t {
fn register(&self, options: ParamOptions, parameter_manager: &mut ParameterManager) {
println!("Registering {} with {}", options.name, self);
parameter_manager.append_float(options.into());
}

fn update(&mut self, name: &str, input: &OperatorInput) {
println!("Updating {} with {}", name, input.get_float(name, 0));
*self = input.get_float(name, 0) as $t;
}
}
Expand Down
3 changes: 1 addition & 2 deletions td-rs-param/src/operator_input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ impl<'execute> OperatorInput<'execute> {
}

pub fn get_float(&self, name: &str, index: usize) -> f64 {
println!("get_float: {} {}", name, index);
self.input.getParDouble(name, index as i32)
self.input.getParDouble(&(name.to_string()), index as i32)
}

pub fn get_int(&self, name: &str, index: usize) -> i32 {
Expand Down

0 comments on commit c1c928c

Please sign in to comment.