summaryrefslogtreecommitdiff
path: root/src/global.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/global.cc')
-rw-r--r--src/global.cc44
1 files changed, 24 insertions, 20 deletions
diff --git a/src/global.cc b/src/global.cc
index d9028dd7..97a46cce 100644
--- a/src/global.cc
+++ b/src/global.cc
@@ -314,28 +314,32 @@ option_t<global_scope_t> * global_scope_t::lookup_option(const char * p)
return NULL;
}
-expr_t::ptr_op_t global_scope_t::lookup(const string& name)
+expr_t::ptr_op_t global_scope_t::lookup(const symbol_t::kind_t kind,
+ const string& name)
{
- const char * p = name.c_str();
- switch (*p) {
- case 'o':
- if (WANT_OPT()) { p += OPT_PREFIX_LEN;
- if (option_t<global_scope_t> * handler = lookup_option(p))
- return MAKE_OPT_HANDLER(global_scope_t, handler);
- }
+ switch (kind) {
+ case symbol_t::FUNCTION:
+ if (option_t<global_scope_t> * handler = lookup_option(name.c_str()))
+ return MAKE_OPT_FUNCTOR(global_scope_t, handler);
break;
- case 'p':
- if (WANT_PRECMD()) { const char * q = p + PRECMD_PREFIX_LEN;
- switch (*q) {
- case 'p':
- if (is_eq(q, "push"))
- return MAKE_FUNCTOR(global_scope_t::push_command);
- else if (is_eq(q, "pop"))
- return MAKE_FUNCTOR(global_scope_t::pop_command);
- break;
- }
+ case symbol_t::OPTION:
+ if (option_t<global_scope_t> * handler = lookup_option(name.c_str()))
+ return MAKE_OPT_HANDLER(global_scope_t, handler);
+ break;
+
+ case symbol_t::PRECOMMAND: {
+ const char * p = name.c_str();
+ switch (*p) {
+ case 'p':
+ if (is_eq(p, "push"))
+ return MAKE_FUNCTOR(global_scope_t::push_command);
+ else if (is_eq(p, "pop"))
+ return MAKE_FUNCTOR(global_scope_t::pop_command);
+ break;
}
+ }
+ default:
break;
}
@@ -396,7 +400,7 @@ void global_scope_t::normalize_session_options()
function_t global_scope_t::look_for_precommand(scope_t& scope,
const string& verb)
{
- if (expr_t::ptr_op_t def = scope.lookup(string(PRECMD_PREFIX) + verb))
+ if (expr_t::ptr_op_t def = scope.lookup(symbol_t::PRECOMMAND, verb))
return def->as_function();
else
return function_t();
@@ -405,7 +409,7 @@ function_t global_scope_t::look_for_precommand(scope_t& scope,
function_t global_scope_t::look_for_command(scope_t& scope,
const string& verb)
{
- if (expr_t::ptr_op_t def = scope.lookup(string(CMD_PREFIX) + verb))
+ if (expr_t::ptr_op_t def = scope.lookup(symbol_t::COMMAND, verb))
return def->as_function();
else
return function_t();