Skip to content

Commit

Permalink
[ossia] fixes to accomodate some of the concept updates
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Sep 30, 2024
1 parent 55ddd8c commit b08645e
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 4 deletions.
75 changes: 72 additions & 3 deletions include/avnd/binding/ossia/from_value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,9 +837,77 @@ struct from_ossia_value_impl
return false;
}

template <avnd::list_ish T>
requires(!avnd::string_ish<T> && !avnd::vector_ish<T>)
bool operator()(const ossia::value& src, T& f)
{
switch(src.get_type())
{
case ossia::val_type::VEC2F: {
if constexpr(float_compatible<typename T::value_type>)
{
ossia::vec2f v = *src.target<ossia::vec2f>();
f.clear();
for(auto& val : v)
f.push_back(val);
return true;
}
else
{
return false;
}
break;
}
case ossia::val_type::VEC3F: {
if constexpr(float_compatible<typename T::value_type>)
{
ossia::vec3f v = *src.target<ossia::vec3f>();
f.clear();
for(auto& val : v)
f.push_back(val);
return true;
}
else
{
return false;
}
break;
}
case ossia::val_type::VEC4F: {
if constexpr(float_compatible<typename T::value_type>)
{
ossia::vec4f v = *src.target<ossia::vec4f>();
f.clear();
for(auto& val : v)
f.push_back(val);
return true;
}
else
{
return false;
}
break;
}
case ossia::val_type::LIST: {
const std::vector<ossia::value>& vl = *src.target<std::vector<ossia::value>>();
f.clear();
for(auto& val : vl)
{
typename T::value_type res;
(*this)(val, res);
f.push_back(res);
}
return true;
break;
}
default:
return false;
break;
}
}
template <avnd::vector_ish T>
requires(!avnd::string_ish<T>) bool
operator()(const ossia::value& src, T& f)
requires(!avnd::string_ish<T>)
bool operator()(const ossia::value& src, T& f)
{
switch(src.get_type())
{
Expand Down Expand Up @@ -1177,6 +1245,7 @@ bool from_ossia_value_rec(const ossia::value& src, T& dst)
}

template <typename T>
requires std::is_aggregate_v<T>
bool from_ossia_value(const ossia::value& src, T& dst)
{
using type = std::decay_t<T>;
Expand Down Expand Up @@ -1270,7 +1339,7 @@ from_ossia_value(const ossia::value& src, T<N>& dst)
template <typename T>
requires(
avnd::variant_ish<T> || avnd::set_ish<T> || avnd::map_ish<T> || avnd::bitset_ish<T>
|| avnd::pair_ish<T> || avnd::tuple_ish<T>
|| avnd::pair_ish<T> || avnd::tuple_ish<T> || avnd::iterable_ish<T>
|| (avnd::vector_ish<T> && !avnd::string_ish<T>))
bool from_ossia_value(const ossia::value& src, T& dst)
{
Expand Down
2 changes: 1 addition & 1 deletion include/avnd/concepts/generic.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ template <typename T>
concept pointer = std::is_pointer_v<std::decay_t<T>>;

template <typename T>
concept string_ish = requires(T t, std::string_view v) { v = t; };
concept string_ish = span_ish<T> && requires(T t, std::string_view v) { v = t; };

template <typename T>
concept int_ish = std::is_same_v<std::decay_t<T>, signed int>
Expand Down

0 comments on commit b08645e

Please sign in to comment.