Skip to content

Commit

Permalink
Make array access consistent with other accessors.
Browse files Browse the repository at this point in the history
  • Loading branch information
billyquith committed Nov 29, 2020
1 parent a683c41 commit fd59823
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/ponder/detail/arraypropertyimpl.inl
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ void ArrayPropertyImpl<A>::removeElement(const UserObject& object, size_t index)
template <typename A>
typename ArrayPropertyImpl<A>::ArrayType& ArrayPropertyImpl<A>::array(const UserObject& object) const
{
return m_accessor.m_interface.array(object.get<typename A::ClassType>());
return m_accessor.m_interface.getter(object.get<typename A::ClassType>());
}

} // namespace detail
Expand Down
14 changes: 12 additions & 2 deletions include/ponder/detail/propertyfactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ struct AccessTraits<T, typename std::enable_if<ponder_ext::ArrayMapper<T>::isArr

ReadOnlyBinder(const Binding& a) : m_bound(a) {}

ArrayType& array(ClassType& c) const {return m_bound.access(c);}
const ArrayType& array(const ClassType& c) const {return m_bound.access(c);}
typename Binding::AccessAdapter::OutputType getter(ClassType& c) const {return m_bound.access(c);}

bool setter(ClassType&, const InputType&) const { return false; }
bool setter(ClassType&, InputType&&) const { return false; }
protected:
Binding m_bound;
};
Expand All @@ -167,6 +169,14 @@ struct AccessTraits<T, typename std::enable_if<ponder_ext::ArrayMapper<T>::isArr
typedef ReadOnlyBinder<B> Base;
public:
ReadWriteBinder(const typename Base::Binding& a) : ReadOnlyBinder<B>(a) {}

bool setter(typename Base::ClassType& c, const typename Base::InputType& v) const {
return this->m_bound.access(c) = v, true;
}
bool setter(typename Base::ClassType& c, typename Base::InputType&& v) const {
return this->m_bound.access(c) = std::move(v), true;
}

};

template <typename A>
Expand Down

0 comments on commit fd59823

Please sign in to comment.