diff options
author | John Wiegley <johnw@newartisans.com> | 2010-06-12 22:16:38 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2010-06-13 01:03:48 -0400 |
commit | 536e3e73228b6168437704ede89499406b87391d (patch) | |
tree | eb2193c64f8fb2253eb117eaf1870b52dd34ff1a /src | |
parent | 6ef755c1330c6e11476ea2e63b8388ad29efb4ef (diff) | |
download | fork-ledger-536e3e73228b6168437704ede89499406b87391d.tar.gz fork-ledger-536e3e73228b6168437704ede89499406b87391d.tar.bz2 fork-ledger-536e3e73228b6168437704ede89499406b87391d.zip |
Added a new scope_value() inline helper function
Diffstat (limited to 'src')
-rw-r--r-- | src/account.cc | 8 | ||||
-rw-r--r-- | src/post.cc | 4 | ||||
-rw-r--r-- | src/report.h | 2 | ||||
-rw-r--r-- | src/session.cc | 6 | ||||
-rw-r--r-- | src/value.h | 4 |
5 files changed, 12 insertions, 12 deletions
diff --git a/src/account.cc b/src/account.cc index 33b1ebab..606562b8 100644 --- a/src/account.cc +++ b/src/account.cc @@ -203,11 +203,9 @@ namespace { account_t * acct = account.parent; for (; acct && acct->parent; acct = acct->parent) ; if (scope[0].is_string()) - return value_t(static_cast<scope_t *> - (acct->find_account(args.get<string>(0), false))); + return scope_value(acct->find_account(args.get<string>(0), false)); else if (scope[0].is_mask()) - return value_t(static_cast<scope_t *> - (acct->find_account_re(args.get<mask_t>(0).str()))); + return scope_value(acct->find_account_re(args.get<mask_t>(0).str())); else return NULL_VALUE; } else { @@ -285,7 +283,7 @@ namespace { } value_t get_parent(account_t& account) { - return value_t(static_cast<scope_t *>(account.parent)); + return scope_value(account.parent); } value_t fn_any(call_scope_t& scope) diff --git a/src/post.cc b/src/post.cc index dd489cba..da892062 100644 --- a/src/post.cc +++ b/src/post.cc @@ -126,7 +126,7 @@ optional<date_t> post_t::effective_date() const namespace { value_t get_this(post_t& post) { - return value_t(static_cast<scope_t *>(&post)); + return scope_value(&post); } value_t get_is_calculated(post_t& post) { @@ -146,7 +146,7 @@ namespace { } value_t get_xact(post_t& post) { - return value_t(static_cast<scope_t *>(post.xact)); + return scope_value(post.xact); } value_t get_xact_id(post_t& post) { diff --git a/src/report.h b/src/report.h index 082c204b..00cbec28 100644 --- a/src/report.h +++ b/src/report.h @@ -182,7 +182,7 @@ public: } value_t fn_options(call_scope_t&) { - return value_t(static_cast<scope_t *>(this)); + return scope_value(this); } string report_format(option_t<report_t>& option) { diff --git a/src/session.cc b/src/session.cc index 34cda5ef..b5441766 100644 --- a/src/session.cc +++ b/src/session.cc @@ -186,11 +186,9 @@ value_t session_t::fn_account(call_scope_t& scope) { interactive_t args(scope, "v"); if (scope[0].is_string()) - return value_t(static_cast<scope_t *> - (journal->find_account(args.get<string>(0), false))); + return scope_value(journal->find_account(args.get<string>(0), false)); else if (scope[0].is_mask()) - return value_t(static_cast<scope_t *> - (journal->find_account_re(args.get<mask_t>(0).str()))); + return scope_value(journal->find_account_re(args.get<mask_t>(0).str())); else return NULL_VALUE; } diff --git a/src/value.h b/src/value.h index 4dfd591c..5971535c 100644 --- a/src/value.h +++ b/src/value.h @@ -993,6 +993,10 @@ inline string value_context(const value_t& val) { return buf.str(); } +inline value_t scope_value(scope_t * val) { + return value_t(val); +} + template <typename T> inline value_t& add_or_set_value(value_t& lhs, const T& rhs) { if (lhs.is_null()) |