Added historical support for single-letter valexprs

This commit is contained in:
John Wiegley 2009-11-14 03:11:48 -05:00
parent 7a44791221
commit a461e17eee
4 changed files with 90 additions and 3 deletions

View file

@ -249,7 +249,7 @@ expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind,
switch (name[0]) {
case 'a':
if (name == "amount")
if (name[1] == '\0' || name == "amount")
return WRAP_FUNCTOR(get_wrapper<&get_amount>);
else if (name == "account")
return WRAP_FUNCTOR(get_wrapper<&get_account>);
@ -272,11 +272,20 @@ expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind,
case 'i':
if (name == "is_account")
return WRAP_FUNCTOR(get_wrapper<&get_true>);
else if (name == "is_index")
return WRAP_FUNCTOR(get_wrapper<&get_subcount>);
break;
case 'l':
if (name == "latest_cleared")
return WRAP_FUNCTOR(get_wrapper<&get_latest_cleared>);
else if (name[1] == '\0')
return WRAP_FUNCTOR(get_wrapper<&get_depth>);
break;
case 'n':
if (name[1] == '\0')
return WRAP_FUNCTOR(get_wrapper<&get_subcount>);
break;
case 'p':
@ -300,6 +309,16 @@ expr_t::ptr_op_t account_t::lookup(const symbol_t::kind_t kind,
if (name == "use_direct_amount")
return WRAP_FUNCTOR(get_wrapper<&ignore>);
break;
case 'N':
if (name[1] == '\0')
return WRAP_FUNCTOR(get_wrapper<&get_count>);
break;
case 'O':
if (name[1] == '\0')
return WRAP_FUNCTOR(get_wrapper<&get_total>);
break;
}
return NULL;

View file

@ -395,6 +395,11 @@ expr_t::ptr_op_t item_t::lookup(const symbol_t::kind_t kind,
return WRAP_FUNCTOR(get_wrapper<&get_uncleared>);
break;
case 'L':
if (name[1] == '\0')
return WRAP_FUNCTOR(get_wrapper<&get_actual>);
break;
case 'X':
if (name[1] == '\0')
return WRAP_FUNCTOR(get_wrapper<&get_cleared>);

View file

@ -297,6 +297,11 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
return WRAP_FUNCTOR(get_wrapper<&get_account_base>);
break;
case 'b':
if (name[1] == '\0')
return WRAP_FUNCTOR(get_wrapper<&get_cost>);
break;
case 'c':
if (name == "code")
return WRAP_FUNCTOR(get_wrapper<&get_code>);
@ -325,7 +330,9 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
break;
case 'i':
if (name == "id")
if (name == "index")
return WRAP_FUNCTOR(get_wrapper<&get_count>);
else if (name == "id")
return WRAP_FUNCTOR(get_wrapper<&get_id>);
else if (name == "idstring")
return WRAP_FUNCTOR(get_wrapper<&get_idstring>);
@ -339,6 +346,8 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
case 'n':
if (name == "note")
return WRAP_FUNCTOR(get_wrapper<&get_note>);
else if (name[1] == '\0')
return WRAP_FUNCTOR(get_wrapper<&get_count>);
break;
case 'p':
@ -358,7 +367,7 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
break;
case 't':
if (name[1] == '\0' || name == "total")
if (name == "total")
return WRAP_FUNCTOR(get_wrapper<&get_total>);
break;
@ -376,6 +385,21 @@ expr_t::ptr_op_t post_t::lookup(const symbol_t::kind_t kind,
if (name == "xact")
return WRAP_FUNCTOR(get_wrapper<&get_xact>);
break;
case 'N':
if (name[1] == '\0')
return WRAP_FUNCTOR(get_wrapper<&get_count>);
break;
case 'O':
if (name[1] == '\0')
return WRAP_FUNCTOR(get_wrapper<&get_total>);
break;
case 'R':
if (name[1] == '\0')
return WRAP_FUNCTOR(get_wrapper<&get_real>);
break;
}
return item_t::lookup(kind, name);

View file

@ -915,6 +915,45 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
switch (kind) {
case symbol_t::FUNCTION:
// Support 2.x's single-letter value expression names.
if (*(p + 1) == '\0') {
switch (*p) {
case 'd':
case 'm':
return MAKE_FUNCTOR(report_t::fn_now);
case 'P':
return MAKE_FUNCTOR(report_t::fn_market);
case 't':
return MAKE_FUNCTOR(report_t::fn_display_amount);
case 'T':
return MAKE_FUNCTOR(report_t::fn_display_total);
case 'U':
return MAKE_FUNCTOR(report_t::fn_abs);
case 'S':
return MAKE_FUNCTOR(report_t::fn_strip);
case 'i':
throw_(std::runtime_error,
_("The i value expression variable is no longer supported"));
case 'A':
throw_(std::runtime_error,
_("The A value expression variable is no longer supported"));
case 'v':
case 'V':
throw_(std::runtime_error,
_("The V and v value expression variables are no longer supported"));
case 'I':
case 'B':
throw_(std::runtime_error,
_("The I and B value expression variables are no longer supported"));
case 'g':
case 'G':
throw_(std::runtime_error,
_("The G and g value expression variables are no longer supported"));
default:
return NULL;
}
}
switch (*p) {
case 'a':
if (is_eq(p, "amount_expr"))