From ddd70fd09adc0c93205bd1b436daace101d773fc Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Sun, 19 Apr 2015 18:47:52 +0100 Subject: [PATCH] Make empty context construction more explicit --- src/context.cc | 3 ++- src/context.hh | 4 +++- src/main.cc | 6 +++--- src/remote.cc | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/context.cc b/src/context.cc index bd67a6b34..df8210f85 100644 --- a/src/context.cc +++ b/src/context.cc @@ -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()) diff --git a/src/context.hh b/src/context.hh index 48b01a875..e2f45cc11 100644 --- a/src/context.hh +++ b/src/context.hh @@ -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; diff --git a/src/main.cc b/src/main.cc index aa16ae5a2..75610ca5e 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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); } diff --git a/src/remote.cc b/src/remote.cc index 273943472..021e1edf3 100644 --- a/src/remote.cc +++ b/src/remote.cc @@ -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)