Skip to content

Commit

Permalink
[max] Attribute message with no argument: unset it
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Feb 28, 2024
1 parent 2304952 commit b2062a4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions include/avnd/binding/max/attributes_setup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,10 @@ struct attribute_register<Processor, T>
template<std::size_t I>
static t_max_err setter(Processor *x, void*, long ac, t_atom *av)
{
auto& obj = x->implementation.effect;
auto& ins = avnd::get_inputs(obj);
auto& field = avnd::input_introspection<T>::template field<I>(ins);
if (ac && av) {
auto& obj = x->implementation.effect;
auto& ins = avnd::get_inputs(obj);
auto& field = avnd::input_introspection<T>::template field<I>(ins);

if(from_atoms{ac, av}(field.value))
{
if constexpr(requires { field.update(obj); })
Expand All @@ -67,6 +66,15 @@ struct attribute_register<Processor, T>
}
}
}
else
{
// attribute name without argument: unset it
field.value = {};
if constexpr(requires { field.update(obj); })
{
field.update(obj);
}
}
return MAX_ERR_NONE;
}

Expand Down

0 comments on commit b2062a4

Please sign in to comment.