summaryrefslogtreecommitdiff
path: root/src/session.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-13 15:04:53 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-13 15:04:53 -0400
commit0c699e4d57fe91fa04c4c2f23f9c2f2a6a5da582 (patch)
tree985c50c080c077fa931ed9bf01c3895cbb851eda /src/session.cc
parent40f553228f5a28034c6635fdcb4c86af28a385ed (diff)
parentcf0147fcd04fc7ec4b3849350430e47169581e64 (diff)
downloadfork-ledger-0c699e4d57fe91fa04c4c2f23f9c2f2a6a5da582.tar.gz
fork-ledger-0c699e4d57fe91fa04c4c2f23f9c2f2a6a5da582.tar.bz2
fork-ledger-0c699e4d57fe91fa04c4c2f23f9c2f2a6a5da582.zip
Merge branch 'next'
Diffstat (limited to 'src/session.cc')
-rw-r--r--src/session.cc24
1 files changed, 22 insertions, 2 deletions
diff --git a/src/session.cc b/src/session.cc
index 8adfef38..df6eaf7d 100644
--- a/src/session.cc
+++ b/src/session.cc
@@ -182,6 +182,16 @@ void session_t::close_journal_files()
amount_t::initialize();
}
+value_t session_t::fn_account(call_scope_t& args)
+{
+ if (args[0].is_string())
+ return scope_value(journal->find_account(args.get<string>(0), false));
+ else if (args[0].is_mask())
+ return scope_value(journal->find_account_re(args.get<mask_t>(0).str()));
+ else
+ return NULL_VALUE;
+}
+
option_t<session_t> * session_t::lookup_option(const char * p)
{
switch (*p) {
@@ -224,15 +234,25 @@ option_t<session_t> * session_t::lookup_option(const char * p)
expr_t::ptr_op_t session_t::lookup(const symbol_t::kind_t kind,
const string& name)
{
+ const char * p = name.c_str();
+
switch (kind) {
case symbol_t::FUNCTION:
+ switch (*p) {
+ case 'a':
+ if (is_eq(p, "account"))
+ return MAKE_FUNCTOR(session_t::fn_account);
+ break;
+ default:
+ break;
+ }
// Check if they are trying to access an option's setting or value.
- if (option_t<session_t> * handler = lookup_option(name.c_str()))
+ if (option_t<session_t> * handler = lookup_option(p))
return MAKE_OPT_FUNCTOR(session_t, handler);
break;
case symbol_t::OPTION:
- if (option_t<session_t> * handler = lookup_option(name.c_str()))
+ if (option_t<session_t> * handler = lookup_option(p))
return MAKE_OPT_HANDLER(session_t, handler);
break;