summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2011-10-24 15:22:18 -0500
committerJohn Wiegley <johnw@newartisans.com>2011-10-24 15:22:18 -0500
commit8c4e145c57a36a852d49cf416a30a5b86efb0483 (patch)
tree72404e425575307b8100f3e9acae5d4f97c21e50 /src
parentbf2ad7135270c741313d7d79e3cb9de89fe447ff (diff)
downloadfork-ledger-8c4e145c57a36a852d49cf416a30a5b86efb0483.tar.gz
fork-ledger-8c4e145c57a36a852d49cf416a30a5b86efb0483.tar.bz2
fork-ledger-8c4e145c57a36a852d49cf416a30a5b86efb0483.zip
Added round() and unround() valexpr functions
Diffstat (limited to 'src')
-rw-r--r--src/report.cc14
-rw-r--r--src/report.h2
2 files changed, 16 insertions, 0 deletions
diff --git a/src/report.cc b/src/report.cc
index d3a219a0..548d39df 100644
--- a/src/report.cc
+++ b/src/report.cc
@@ -622,6 +622,16 @@ value_t report_t::fn_floor(call_scope_t& args)
return args[0].floored();
}
+value_t report_t::fn_round(call_scope_t& args)
+{
+ return args[0].rounded();
+}
+
+value_t report_t::fn_unround(call_scope_t& args)
+{
+ return args[0].unrounded();
+}
+
value_t report_t::fn_abs(call_scope_t& args)
{
return args[0].abs();
@@ -1281,6 +1291,8 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
return MAKE_FUNCTOR(report_t::fn_rounded);
else if (is_eq(p, "red"))
return WRAP_FUNCTOR(fn_red);
+ else if (is_eq(p, "round"))
+ return MAKE_FUNCTOR(report_t::fn_round);
break;
case 's':
@@ -1333,6 +1345,8 @@ expr_t::ptr_op_t report_t::lookup(const symbol_t::kind_t kind,
case 'u':
if (is_eq(p, "underline"))
return WRAP_FUNCTOR(fn_underline);
+ else if (is_eq(p, "unround"))
+ return MAKE_FUNCTOR(report_t::fn_unround);
else if (is_eq(p, "unrounded"))
return MAKE_FUNCTOR(report_t::fn_unrounded);
break;
diff --git a/src/report.h b/src/report.h
index e142b0dc..58c12f24 100644
--- a/src/report.h
+++ b/src/report.h
@@ -160,6 +160,8 @@ public:
value_t fn_unrounded(call_scope_t& scope);
value_t fn_truncated(call_scope_t& scope);
value_t fn_floor(call_scope_t& scope);
+ value_t fn_round(call_scope_t& scope);
+ value_t fn_unround(call_scope_t& scope);
value_t fn_abs(call_scope_t& scope);
value_t fn_justify(call_scope_t& scope);
value_t fn_quoted(call_scope_t& scope);