Make empty context construction more explicit

This commit is contained in:
Maxime Coste 2015-04-19 18:47:52 +01:00
parent f714766854
commit ddd70fd09a
4 changed files with 9 additions and 6 deletions

View File

@ -9,7 +9,6 @@
namespace Kakoune
{
Context::Context() = default;
Context::~Context() = default;
Context::Context(InputHandler& input_handler, SelectionList selections,
@ -20,6 +19,8 @@ Context::Context(InputHandler& input_handler, SelectionList selections,
m_name(std::move(name))
{}
Context::Context(EmptyContextFlag) {}
Buffer& Context::buffer() const
{
if (not has_buffer())

View File

@ -63,9 +63,11 @@ public:
Transient = 1,
};
Context();
Context(InputHandler& input_handler, SelectionList selections,
Flags flags, String name = "");
struct EmptyContextFlag {};
explicit Context(EmptyContextFlag);
~Context();
Context(const Context&) = delete;

View File

@ -385,7 +385,7 @@ int run_server(StringView session, StringView init_command,
if (not ignore_kakrc) try
{
Context initialisation_context;
Context initialisation_context{Context::EmptyContextFlag{}};
command_manager.execute("source " + runtime_directory() + "/kakrc",
initialisation_context);
}
@ -399,7 +399,7 @@ int run_server(StringView session, StringView init_command,
}
{
Context empty_context;
Context empty_context{Context::EmptyContextFlag{}};
global_scope.hooks().run_hook("KakBegin", "", empty_context);
}
@ -439,7 +439,7 @@ int run_server(StringView session, StringView init_command,
}
{
Context empty_context;
Context empty_context{Context::EmptyContextFlag{}};
global_scope.hooks().run_hook("KakEnd", "", empty_context);
}

View File

@ -580,7 +580,7 @@ private:
{
if (not m_buffer.empty()) try
{
Context context{};
Context context{Context::EmptyContextFlag{}};
CommandManager::instance().execute(m_buffer, context);
}
catch (runtime_error& e)