Provide a "depth" variable for xacts

This commit is contained in:
John Wiegley 2009-02-15 22:36:12 -04:00
parent e8c90ef96f
commit e32129b25c

View file

@ -204,6 +204,10 @@ namespace {
return string_value(xact.reported_account()->name);
}
value_t get_account_depth(xact_t& xact) {
return long(xact.reported_account()->depth);
}
template <value_t (*Func)(xact_t&)>
value_t get_wrapper(call_scope_t& scope) {
return (*Func)(find_scope<xact_t>(scope));
@ -235,6 +239,11 @@ expr_t::ptr_op_t xact_t::lookup(const string& name)
return WRAP_FUNCTOR(get_wrapper<&get_is_calculated>);
break;
case 'd':
if (name == "depth")
return WRAP_FUNCTOR(get_wrapper<&get_account_depth>);
break;
case 'e':
if (name == "entry")
return WRAP_FUNCTOR(get_wrapper<&get_entry>);