diff options
-rw-r--r-- | project2/common/variables.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/project2/common/variables.cpp b/project2/common/variables.cpp index 591a03e..d3e7254 100644 --- a/project2/common/variables.cpp +++ b/project2/common/variables.cpp @@ -46,13 +46,16 @@ class VariableParent : public VariableImplDyn { VariableType value(ExecContext * ec) const { try { - if (!getValue) { - if (depth > RowState::Stack().size()) { - throw RowSet::ParentOutOfRange(depth); - } - bind(ec, RowState::Stack()[RowState::Stack().size() - depth]); + if (depth > RowState::Stack().size()) { + throw RowSet::ParentOutOfRange(depth); + } + const auto & row = RowState::Stack()[RowState::Stack().size() - depth]; + if (attr) { + return row->resolveAttr(name)(); + } + else { + return row->getCurrentValue(ec, name); } - return getValue(); } catch (RowSet::ParentOutOfRange) { if (!defaultValue) { @@ -68,19 +71,9 @@ class VariableParent : public VariableImplDyn { } } protected: - void bind(ExecContext * ec, const RowState * row) const - { - if (attr) { - getValue = boost::bind(row->resolveAttr(name)); - } - else { - getValue = boost::bind(&RowState::getCurrentValue, row, ec, name); - } - } const size_t depth; const bool attr; const Glib::ustring name; - mutable boost::function0<VariableType> getValue; }; DECLARE_COMPONENT_LOADER("parent", VariableParent, VariableLoader); |