Scopes can now provide a description of themselves
This isn't being used yet, but it likely will to improve the information presented to users if their value expressions fail to compile or evaluate.
This commit is contained in:
parent
bc51cd4651
commit
2f50e30b89
8 changed files with 88 additions and 0 deletions
|
|
@ -89,6 +89,10 @@ public:
|
|||
}
|
||||
~account_t();
|
||||
|
||||
virtual string description() {
|
||||
return string(_("account ")) + fullname();
|
||||
}
|
||||
|
||||
operator string() const {
|
||||
return fullname();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,10 @@ public:
|
|||
global_scope_t(char ** envp);
|
||||
~global_scope_t();
|
||||
|
||||
virtual string description() {
|
||||
return _("global scope");
|
||||
}
|
||||
|
||||
void read_init();
|
||||
void read_environment_settings(char * envp[]);
|
||||
strings_list read_command_arguments(scope_t& scope, strings_list args);
|
||||
|
|
|
|||
10
src/post.h
10
src/post.h
|
|
@ -99,6 +99,16 @@ public:
|
|||
TRACE_DTOR(post_t);
|
||||
}
|
||||
|
||||
virtual string description() {
|
||||
if (pos) {
|
||||
std::ostringstream buf;
|
||||
buf << _("posting at line %1") << pos->beg_line;
|
||||
return buf.str();
|
||||
} else {
|
||||
return string(_("generated posting"));
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool has_tag(const string& tag,
|
||||
bool inherit = true) const;
|
||||
virtual bool has_tag(const mask_t& tag_mask,
|
||||
|
|
|
|||
|
|
@ -125,6 +125,10 @@ public:
|
|||
output_stream.close();
|
||||
}
|
||||
|
||||
virtual string description() {
|
||||
return _("current report");
|
||||
}
|
||||
|
||||
void normalize_options(const string& verb);
|
||||
void normalize_period();
|
||||
void parse_query_args(const value_t& args, const string& whence);
|
||||
|
|
|
|||
28
src/scope.h
28
src/scope.h
|
|
@ -109,6 +109,8 @@ public:
|
|||
TRACE_DTOR(scope_t);
|
||||
}
|
||||
|
||||
virtual string description() = 0;
|
||||
|
||||
virtual void define(const symbol_t::kind_t, const string&,
|
||||
expr_t::ptr_op_t) {}
|
||||
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
|
||||
|
|
@ -191,6 +193,10 @@ public:
|
|||
TRACE_DTOR(bind_scope_t);
|
||||
}
|
||||
|
||||
virtual string description() {
|
||||
return grandchild.description();
|
||||
}
|
||||
|
||||
virtual void define(const symbol_t::kind_t kind, const string& name,
|
||||
expr_t::ptr_op_t def) {
|
||||
parent->define(kind, name, def);
|
||||
|
|
@ -262,6 +268,16 @@ public:
|
|||
TRACE_DTOR(symbol_scope_t);
|
||||
}
|
||||
|
||||
virtual string description() {
|
||||
if (parent)
|
||||
return parent->description();
|
||||
#if !defined(NO_ASSERTS)
|
||||
else
|
||||
assert(false);
|
||||
#endif
|
||||
return empty_string;
|
||||
}
|
||||
|
||||
virtual void define(const symbol_t::kind_t kind, const string& name,
|
||||
expr_t::ptr_op_t def);
|
||||
|
||||
|
|
@ -299,6 +315,10 @@ public:
|
|||
TRACE_DTOR(context_scope_t);
|
||||
}
|
||||
|
||||
virtual string description() {
|
||||
return parent->description();
|
||||
}
|
||||
|
||||
virtual value_t::type_t type_context() const {
|
||||
return value_type_context;
|
||||
}
|
||||
|
|
@ -351,6 +371,10 @@ public:
|
|||
TRACE_DTOR(call_scope_t);
|
||||
}
|
||||
|
||||
virtual string description() {
|
||||
return context_scope_t::description();
|
||||
}
|
||||
|
||||
void set_args(const value_t& _args) {
|
||||
args = _args;
|
||||
}
|
||||
|
|
@ -617,6 +641,10 @@ public:
|
|||
value_scope_t(scope_t& _parent, const value_t& _value)
|
||||
: child_scope_t(_parent), value(_value) {}
|
||||
|
||||
virtual string description() {
|
||||
return parent->description();
|
||||
}
|
||||
|
||||
virtual expr_t::ptr_op_t lookup(const symbol_t::kind_t kind,
|
||||
const string& name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@ public:
|
|||
TRACE_DTOR(session_t);
|
||||
}
|
||||
|
||||
virtual string description() {
|
||||
return _("current session");
|
||||
}
|
||||
|
||||
void set_flush_on_next_data_file(const bool truth) {
|
||||
flush_on_next_data_file = truth;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,6 +112,10 @@ namespace {
|
|||
|
||||
~instance_t();
|
||||
|
||||
virtual string description() {
|
||||
return _("textual parser");
|
||||
}
|
||||
|
||||
void parse();
|
||||
std::streamsize read_line(char *& line);
|
||||
bool peek_whitespace_line() {
|
||||
|
|
|
|||
30
src/xact.h
30
src/xact.h
|
|
@ -117,6 +117,16 @@ public:
|
|||
TRACE_DTOR(xact_t);
|
||||
}
|
||||
|
||||
virtual string description() {
|
||||
if (pos) {
|
||||
std::ostringstream buf;
|
||||
buf << _("transaction at line %1") << pos->beg_line;
|
||||
return buf.str();
|
||||
} else {
|
||||
return string(_("generated transaction"));
|
||||
}
|
||||
}
|
||||
|
||||
virtual void add_post(post_t * post);
|
||||
|
||||
string idstring() const;
|
||||
|
|
@ -194,6 +204,16 @@ public:
|
|||
TRACE_DTOR(auto_xact_t);
|
||||
}
|
||||
|
||||
virtual string description() {
|
||||
if (pos) {
|
||||
std::ostringstream buf;
|
||||
buf << _("automated transaction at line %1") << pos->beg_line;
|
||||
return buf.str();
|
||||
} else {
|
||||
return string(_("generated automated transaction"));
|
||||
}
|
||||
}
|
||||
|
||||
virtual void parse_tags(const char * p,
|
||||
scope_t&,
|
||||
bool overwrite_existing = true) {
|
||||
|
|
@ -242,6 +262,16 @@ class period_xact_t : public xact_base_t
|
|||
TRACE_DTOR(period_xact_t);
|
||||
}
|
||||
|
||||
virtual string description() {
|
||||
if (pos) {
|
||||
std::ostringstream buf;
|
||||
buf << _("periodic transaction at line %1") << pos->beg_line;
|
||||
return buf.str();
|
||||
} else {
|
||||
return string(_("generated periodic transaction"));
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue