memoryview: always pass by value

This commit is contained in:
Maxime Coste 2013-07-26 01:17:12 +02:00
parent 3862b5cbb8
commit eedd37c09a
22 changed files with 90 additions and 90 deletions

View File

@ -23,7 +23,7 @@ void CommandManager::register_command(String command_name,
m_commands[command_name] = { std::move(command), std::move(completer) };
}
void CommandManager::register_commands(const memoryview<String>& command_names,
void CommandManager::register_commands(memoryview<String> command_names,
Command command,
CommandCompleter completer)
{
@ -247,7 +247,7 @@ struct command_not_found : runtime_error
: runtime_error(command + " : no such command") {}
};
void CommandManager::execute_single_command(const CommandParameters& params,
void CommandManager::execute_single_command(CommandParameters params,
Context& context) const
{
if (params.empty())
@ -262,7 +262,7 @@ void CommandManager::execute_single_command(const CommandParameters& params,
void CommandManager::execute(const String& command_line,
Context& context,
const memoryview<String>& shell_params,
memoryview<String> shell_params,
const EnvVarMap& env_vars)
{
TokenList tokens = parse(command_line);
@ -368,7 +368,7 @@ Completions CommandManager::complete(const Context& context,
}
CandidateList PerArgumentCommandCompleter::operator()(const Context& context,
const CommandParameters& params,
CommandParameters params,
size_t token_to_complete,
ByteCount pos_in_token) const
{

View File

@ -21,10 +21,10 @@ struct parse_error : runtime_error
struct Context;
using CommandParameters = memoryview<String>;
using Command = std::function<void (const CommandParameters&,
using Command = std::function<void (CommandParameters,
Context& context)>;
using CommandCompleter = std::function<CandidateList (const Context& context,
const CommandParameters&,
CommandParameters,
size_t, ByteCount)>;
class PerArgumentCommandCompleter
@ -34,11 +34,11 @@ public:
const String&, ByteCount)>;
using ArgumentCompleterList = memoryview<ArgumentCompleter>;
PerArgumentCommandCompleter(const ArgumentCompleterList& completers)
PerArgumentCommandCompleter(ArgumentCompleterList completers)
: m_completers(completers.begin(), completers.end()) {}
CandidateList operator()(const Context& context,
const CommandParameters& params,
CommandParameters params,
size_t token_to_complete,
ByteCount pos_in_token) const;
@ -50,7 +50,7 @@ class CommandManager : public Singleton<CommandManager>
{
public:
void execute(const String& command_line, Context& context,
const memoryview<String>& shell_params = {},
memoryview<String> shell_params = {},
const EnvVarMap& env_vars = EnvVarMap{});
Completions complete(const Context& context,
@ -62,12 +62,12 @@ public:
Command command,
CommandCompleter completer = CommandCompleter());
void register_commands(const memoryview<String>& command_names,
void register_commands(memoryview<String> command_names,
Command command,
CommandCompleter completer = CommandCompleter());
private:
void execute_single_command(const CommandParameters& params,
void execute_single_command(CommandParameters params,
Context& context) const;
struct CommandDescriptor
{

View File

@ -86,7 +86,7 @@ Buffer* open_fifo(const String& name , const String& filename, Context& context)
}
template<bool force_reload>
void edit(const CommandParameters& params, Context& context)
void edit(CommandParameters params, Context& context)
{
ParametersParser parser(params, { { "scratch", false },
{ "fifo", true } },
@ -134,7 +134,7 @@ void edit(const CommandParameters& params, Context& context)
}
}
void write_buffer(const CommandParameters& params, Context& context)
void write_buffer(CommandParameters params, Context& context)
{
if (params.size() > 1)
throw wrong_argument_count();
@ -153,7 +153,7 @@ void write_buffer(const CommandParameters& params, Context& context)
buffer.notify_saved();
}
void write_all_buffers(const CommandParameters& params, Context& context)
void write_all_buffers(CommandParameters params, Context& context)
{
if (params.size() != 0)
throw wrong_argument_count();
@ -169,7 +169,7 @@ void write_all_buffers(const CommandParameters& params, Context& context)
}
template<bool force>
void quit(const CommandParameters& params, Context& context)
void quit(CommandParameters params, Context& context)
{
if (params.size() != 0)
throw wrong_argument_count();
@ -200,13 +200,13 @@ void quit(const CommandParameters& params, Context& context)
}
template<bool force>
void write_and_quit(const CommandParameters& params, Context& context)
void write_and_quit(CommandParameters params, Context& context)
{
write_buffer(params, context);
quit<force>(CommandParameters(), context);
}
void show_buffer(const CommandParameters& params, Context& context)
void show_buffer(CommandParameters params, Context& context)
{
if (params.size() != 1)
throw wrong_argument_count();
@ -223,7 +223,7 @@ void show_buffer(const CommandParameters& params, Context& context)
}
template<bool force>
void delete_buffer(const CommandParameters& params, Context& context)
void delete_buffer(CommandParameters params, Context& context)
{
if (params.size() > 1)
throw wrong_argument_count();
@ -239,7 +239,7 @@ void delete_buffer(const CommandParameters& params, Context& context)
manager.delete_buffer(buffer);
}
void set_buffer_name(const CommandParameters& params, Context& context)
void set_buffer_name(CommandParameters params, Context& context)
{
ParametersParser parser(params, OptionMap{},
ParametersParser::Flags::None, 1, 1);
@ -258,7 +258,7 @@ Group& get_group(Group& root, const String& group_path)
return group;
}
void add_highlighter(const CommandParameters& params, Context& context)
void add_highlighter(CommandParameters params, Context& context)
{
ParametersParser parser(params, { { "group", true } }, ParametersParser::Flags::None, 1);
HighlighterRegistry& registry = HighlighterRegistry::instance();
@ -278,7 +278,7 @@ void add_highlighter(const CommandParameters& params, Context& context)
group.append(factory(highlighter_params, window));
}
void rm_highlighter(const CommandParameters& params, Context& context)
void rm_highlighter(CommandParameters params, Context& context)
{
ParametersParser parser(params, { { "group", true } }, ParametersParser::Flags::None, 1, 1);
@ -290,7 +290,7 @@ void rm_highlighter(const CommandParameters& params, Context& context)
group.remove(parser[0]);
}
void add_filter(const CommandParameters& params, Context& context)
void add_filter(CommandParameters params, Context& context)
{
ParametersParser parser(params, { { "group", true } }, ParametersParser::Flags::None, 1);
@ -311,7 +311,7 @@ void add_filter(const CommandParameters& params, Context& context)
group.append(factory(filter_params));
}
void rm_filter(const CommandParameters& params, Context& context)
void rm_filter(CommandParameters params, Context& context)
{
ParametersParser parser(params, { { "group", true } }, ParametersParser::Flags::None, 1, 1);
@ -334,7 +334,7 @@ static HookManager& get_hook_manager(const String& scope, Context& context)
throw runtime_error("error: no such hook container " + scope);
}
void add_hook(const CommandParameters& params, Context& context)
void add_hook(CommandParameters params, Context& context)
{
ParametersParser parser(params, { { "id", true } }, ParametersParser::Flags::None, 4, 4);
// copy so that the lambda gets a copy as well
@ -349,13 +349,13 @@ void add_hook(const CommandParameters& params, Context& context)
get_hook_manager(parser[0], context).add_hook(parser[1], id, hook_func);
}
void rm_hooks(const CommandParameters& params, Context& context)
void rm_hooks(CommandParameters params, Context& context)
{
ParametersParser parser(params, {}, ParametersParser::Flags::None, 2, 2);
get_hook_manager(parser[0], context).remove_hooks(parser[1]);
}
EnvVarMap params_to_env_var_map(const CommandParameters& params)
EnvVarMap params_to_env_var_map(CommandParameters params)
{
std::unordered_map<String, String> vars;
char param_name[] = "param0";
@ -367,7 +367,7 @@ EnvVarMap params_to_env_var_map(const CommandParameters& params)
return vars;
}
void define_command(const CommandParameters& params, Context& context)
void define_command(CommandParameters params, Context& context)
{
ParametersParser parser(params,
{ { "env-params", false },
@ -389,20 +389,20 @@ void define_command(const CommandParameters& params, Context& context)
Command cmd;
if (parser.has_option("env-params"))
{
cmd = [=](const CommandParameters& params, Context& context) {
cmd = [=](CommandParameters params, Context& context) {
CommandManager::instance().execute(commands, context, {},
params_to_env_var_map(params));
};
}
if (parser.has_option("shell-params"))
{
cmd = [=](const CommandParameters& params, Context& context) {
cmd = [=](CommandParameters params, Context& context) {
CommandManager::instance().execute(commands, context, params);
};
}
else
{
cmd = [=](const CommandParameters& params, Context& context) {
cmd = [=](CommandParameters params, Context& context) {
if (not params.empty())
throw wrong_argument_count();
CommandManager::instance().execute(commands, context);
@ -412,7 +412,7 @@ void define_command(const CommandParameters& params, Context& context)
CommandCompleter completer;
if (parser.has_option("file-completion"))
{
completer = [](const Context& context, const CommandParameters& params,
completer = [](const Context& context, CommandParameters params,
size_t token_to_complete, ByteCount pos_in_token)
{
const String& prefix = token_to_complete < params.size() ?
@ -423,7 +423,7 @@ void define_command(const CommandParameters& params, Context& context)
else if (parser.has_option("shell-completion"))
{
String shell_cmd = parser.option_value("shell-completion");
completer = [=](const Context& context, const CommandParameters& params,
completer = [=](const Context& context, CommandParameters params,
size_t token_to_complete, ByteCount pos_in_token)
{
EnvVarMap vars = {
@ -437,7 +437,7 @@ void define_command(const CommandParameters& params, Context& context)
CommandManager::instance().register_command(cmd_name, cmd, completer);
}
void echo_message(const CommandParameters& params, Context& context)
void echo_message(CommandParameters params, Context& context)
{
ParametersParser parser(params, { { "color", true } },
ParametersParser::Flags::OptionsOnlyAtStart);
@ -449,7 +449,7 @@ void echo_message(const CommandParameters& params, Context& context)
context.print_status({ std::move(message), color } );
}
void write_debug_message(const CommandParameters& params, Context&)
void write_debug_message(CommandParameters params, Context&)
{
String message;
for (auto& param : params)
@ -457,7 +457,7 @@ void write_debug_message(const CommandParameters& params, Context&)
write_debug(message);
}
void exec_commands_in_file(const CommandParameters& params,
void exec_commands_in_file(CommandParameters params,
Context& context)
{
if (params.size() != 1)
@ -467,7 +467,7 @@ void exec_commands_in_file(const CommandParameters& params,
CommandManager::instance().execute(file_content, context);
}
void set_global_option(const CommandParameters& params, Context& context)
void set_global_option(CommandParameters params, Context& context)
{
ParametersParser parser(params, { { "add", false } },
ParametersParser::Flags::OptionsOnlyAtStart,
@ -480,7 +480,7 @@ void set_global_option(const CommandParameters& params, Context& context)
opt.set_from_string(parser[1]);
}
void set_buffer_option(const CommandParameters& params, Context& context)
void set_buffer_option(CommandParameters params, Context& context)
{
ParametersParser parser(params, { { "buffer", true}, { "add", false } },
ParametersParser::Flags::OptionsOnlyAtStart,
@ -497,7 +497,7 @@ void set_buffer_option(const CommandParameters& params, Context& context)
opt.set_from_string(parser[1]);
}
void set_window_option(const CommandParameters& params, Context& context)
void set_window_option(CommandParameters params, Context& context)
{
ParametersParser parser(params, { { "add", false } },
ParametersParser::Flags::OptionsOnlyAtStart,
@ -510,7 +510,7 @@ void set_window_option(const CommandParameters& params, Context& context)
opt.set_from_string(parser[1]);
}
void declare_option(const CommandParameters& params, Context& context)
void declare_option(CommandParameters params, Context& context)
{
if (params.size() != 2 and params.size() != 3)
throw wrong_argument_count();
@ -538,7 +538,7 @@ void declare_option(const CommandParameters& params, Context& context)
}
template<typename Func>
void context_wrap(const CommandParameters& params, Context& context, Func func)
void context_wrap(CommandParameters params, Context& context, Func func)
{
ParametersParser parser(params, { { "client", true }, { "draft", false }},
ParametersParser::Flags::OptionsOnlyAtStart, 1);
@ -562,7 +562,7 @@ void context_wrap(const CommandParameters& params, Context& context, Func func)
real_context.window().forget_timestamp();
}
void exec_string(const CommandParameters& params, Context& context)
void exec_string(CommandParameters params, Context& context)
{
context_wrap(params, context, [](const ParametersParser& parser, Context& context) {
KeyList keys;
@ -575,7 +575,7 @@ void exec_string(const CommandParameters& params, Context& context)
});
}
void eval_string(const CommandParameters& params, Context& context)
void eval_string(CommandParameters params, Context& context)
{
context_wrap(params, context, [](const ParametersParser& parser, Context& context) {
String command;
@ -585,7 +585,7 @@ void eval_string(const CommandParameters& params, Context& context)
});
}
void menu(const CommandParameters& params, Context& context)
void menu(CommandParameters params, Context& context)
{
ParametersParser parser(params, { { "auto-single", false },
{ "select-cmds", false } });
@ -694,7 +694,7 @@ static String assist(String message, CharCount maxWidth)
}
void info(const CommandParameters& params, Context& context)
void info(CommandParameters params, Context& context)
{
ParametersParser parser(params, { { "anchor", true }, { "assist", false } },
ParametersParser::Flags::None, 0, 1);
@ -724,7 +724,7 @@ void info(const CommandParameters& params, Context& context)
}
}
void try_catch(const CommandParameters& params, Context& context)
void try_catch(CommandParameters params, Context& context)
{
if (params.size() != 3)
throw wrong_argument_count();
@ -742,7 +742,7 @@ void try_catch(const CommandParameters& params, Context& context)
}
}
void define_color_alias(const CommandParameters& params, Context& context)
void define_color_alias(CommandParameters params, Context& context)
{
ParametersParser parser(params, OptionMap{},
ParametersParser::Flags::None, 2, 2);
@ -750,7 +750,7 @@ void define_color_alias(const CommandParameters& params, Context& context)
parser[0], parser[1], true);
}
void set_client_name(const CommandParameters& params, Context& context)
void set_client_name(CommandParameters params, Context& context)
{
ParametersParser parser(params, OptionMap{},
ParametersParser::Flags::None, 1, 1);
@ -758,7 +758,7 @@ void set_client_name(const CommandParameters& params, Context& context)
manager.set_client_name(manager.get_client(context), params[0]);
}
void set_register(const CommandParameters& params, Context& context)
void set_register(CommandParameters params, Context& context)
{
if (params.size() != 2)
throw wrong_argument_count();
@ -768,7 +768,7 @@ void set_register(const CommandParameters& params, Context& context)
RegisterManager::instance()[params[0][0]] = memoryview<String>(params[1]);
}
void change_working_directory(const CommandParameters& params, Context&)
void change_working_directory(CommandParameters params, Context&)
{
if (params.size() != 1)
throw wrong_argument_count();
@ -780,7 +780,7 @@ void change_working_directory(const CommandParameters& params, Context&)
template<typename GetRootGroup>
CommandCompleter group_rm_completer(GetRootGroup get_root_group)
{
return [=](const Context& context, const CommandParameters& params,
return [=](const Context& context, CommandParameters params,
size_t token_to_complete, ByteCount pos_in_token) {
auto& root_group = get_root_group(context);
const String& arg = token_to_complete < params.size() ?
@ -796,7 +796,7 @@ CommandCompleter group_rm_completer(GetRootGroup get_root_group)
template<typename FactoryRegistry, typename GetRootGroup>
CommandCompleter group_add_completer(GetRootGroup get_root_group)
{
return [=](const Context& context, const CommandParameters& params,
return [=](const Context& context, CommandParameters params,
size_t token_to_complete, ByteCount pos_in_token) {
auto& root_group = get_root_group(context);
const String& arg = token_to_complete < params.size() ?
@ -842,7 +842,7 @@ public:
void print_status(const DisplayLine&) override {}
void draw(const DisplayBuffer&, const DisplayLine&) override {}
void menu_show(const memoryview<String>&,
void menu_show(memoryview<String>,
DisplayCoord, ColorPair, ColorPair, MenuStyle) override {}
void menu_select(int) override {}
void menu_hide() override {}
@ -887,7 +887,7 @@ void register_commands()
{
CommandManager& cm = CommandManager::instance();
cm.register_commands({"nop"}, [](const CommandParameters&, Context&){});
cm.register_commands({"nop"}, [](CommandParameters, Context&){});
PerArgumentCommandCompleter filename_completer({
[](const Context& context, const String& prefix, ByteCount cursor_pos)

View File

@ -93,7 +93,7 @@ void Editor::insert(const String& str, InsertMode mode)
check_invariant();
}
void Editor::insert(const memoryview<String>& strings, InsertMode mode)
void Editor::insert(memoryview<String> strings, InsertMode mode)
{
scoped_edition edition(*this);
if (strings.empty())
@ -542,7 +542,7 @@ void IncrementalInserter::insert(String content)
}
}
void IncrementalInserter::insert(const memoryview<String>& strings)
void IncrementalInserter::insert(memoryview<String> strings)
{
auto& buffer = m_editor.buffer();
for (size_t i = 0; i < m_editor.m_selections.size(); ++i)

View File

@ -50,7 +50,7 @@ public:
void insert(const String& string,
InsertMode mode = InsertMode::Insert);
void insert(const memoryview<String>& strings,
void insert(memoryview<String> strings,
InsertMode mode = InsertMode::Insert);
void move_selections(LineCount move,
@ -126,7 +126,7 @@ public:
~IncrementalInserter();
void insert(String content);
void insert(const memoryview<String>& strings);
void insert(memoryview<String> strings);
void erase();
void move_cursors(CharCount move);
void move_cursors(LineCount move);

View File

@ -184,7 +184,7 @@ Buffer* create_buffer_from_file(String filename)
return buffer;
}
static void write(int fd, const memoryview<char>& data, const String& filename)
static void write(int fd, memoryview<char> data, const String& filename)
{
const char* ptr = data.pointer();
ssize_t count = data.size();
@ -228,7 +228,7 @@ void write_buffer_to_file(const Buffer& buffer, const String& filename)
}
}
String find_file(const String& filename, const memoryview<String>& paths)
String find_file(const String& filename, memoryview<String> paths)
{
for (auto candidate : paths)
{

View File

@ -31,7 +31,7 @@ String compact_path(const String& filename);
String read_file(const String& filename);
Buffer* create_buffer_from_file(String filename);
void write_buffer_to_file(const Buffer& buffer, const String& filename);
String find_file(const String& filename, const memoryview<String>& paths);
String find_file(const String& filename, memoryview<String> paths);
std::vector<String> complete_filename(const String& prefix,
const Regex& ignore_regex,

View File

@ -24,7 +24,7 @@ using FilterAndId = std::pair<String, FilterFunc>;
using FilterGroup = FunctionGroup<Buffer&, Selection&, String&>;
using FilterParameters = memoryview<String>;
using FilterFactory = std::function<FilterAndId (const FilterParameters& params)>;
using FilterFactory = std::function<FilterAndId (FilterParameters params)>;
struct FilterRegistry : FunctionRegistry<FilterFactory>,
Singleton<FilterRegistry>

View File

@ -99,7 +99,7 @@ private:
String m_replacement;
};
FilterAndId regex_filter_factory(const FilterParameters& params)
FilterAndId regex_filter_factory(FilterParameters params)
{
if (params.size() != 3)
throw runtime_error("wrong parameter count");
@ -114,7 +114,7 @@ class SimpleFilterFactory
public:
SimpleFilterFactory(const String& id) : m_id(id) {}
FilterAndId operator()(const FilterParameters& params) const
FilterAndId operator()(FilterParameters params) const
{
return FilterAndId(m_id, FilterFunc(filter_func));
}
@ -122,7 +122,7 @@ private:
String m_id;
};
FilterAndId filter_group_factory(const FilterParameters& params)
FilterAndId filter_group_factory(FilterParameters params)
{
if (params.size() != 1)
throw runtime_error("wrong parameter count");

View File

@ -24,7 +24,7 @@ typedef std::function<void (const Window& window, DisplayBuffer& display_buffer)
typedef std::pair<String, HighlighterFunc> HighlighterAndId;
typedef memoryview<String> HighlighterParameters;
using HighlighterFactory = std::function<HighlighterAndId (const HighlighterParameters& params,
using HighlighterFactory = std::function<HighlighterAndId (HighlighterParameters params,
Window& window)>;
using HighlighterGroup = FunctionGroup<const Window&, DisplayBuffer&>;

View File

@ -117,7 +117,7 @@ private:
}
};
HighlighterAndId colorize_regex_factory(const HighlighterParameters params, const Window&)
HighlighterAndId colorize_regex_factory(HighlighterParameters params, const Window&)
{
if (params.size() < 2)
throw runtime_error("wrong parameter count");
@ -179,7 +179,7 @@ private:
RegexGetter m_regex_getter;
};
HighlighterAndId highlight_search_factory(const HighlighterParameters params, const Window&)
HighlighterAndId highlight_search_factory(HighlighterParameters params, const Window&)
{
if (params.size() != 1)
throw runtime_error("wrong parameter count");
@ -198,7 +198,7 @@ HighlighterAndId highlight_search_factory(const HighlighterParameters params, co
}
}
HighlighterAndId highlight_regex_option_factory(const HighlighterParameters params, const Window& window)
HighlighterAndId highlight_regex_option_factory(HighlighterParameters params, const Window& window)
{
if (params.size() != 2)
throw runtime_error("wrong parameter count");
@ -446,7 +446,7 @@ private:
};
std::unordered_map<const Option*, std::weak_ptr<FlagLines::OptionUpdater>> FlagLines::ms_updaters;
HighlighterAndId flag_lines_factory(const HighlighterParameters& params, Window& window)
HighlighterAndId flag_lines_factory(HighlighterParameters params, Window& window)
{
if (params.size() != 2)
throw runtime_error("wrong parameter count");
@ -460,7 +460,7 @@ class SimpleHighlighterFactory
public:
SimpleHighlighterFactory(const String& id) : m_id(id) {}
HighlighterAndId operator()(const HighlighterParameters& params, const Window&) const
HighlighterAndId operator()(HighlighterParameters params, const Window&) const
{
return HighlighterAndId(m_id, HighlighterFunc(highlighter_func));
}
@ -468,7 +468,7 @@ private:
String m_id;
};
HighlighterAndId highlighter_group_factory(const HighlighterParameters& params, const Window&)
HighlighterAndId highlighter_group_factory(HighlighterParameters params, const Window&)
{
if (params.size() != 1)
throw runtime_error("wrong parameter count");

View File

@ -161,7 +161,7 @@ private:
class Menu : public InputMode
{
public:
Menu(InputHandler& input_handler, const memoryview<String>& choices,
Menu(InputHandler& input_handler, memoryview<String> choices,
MenuCallback callback)
: InputMode(input_handler),
m_callback(callback), m_choices(choices.begin(), choices.end()),
@ -269,7 +269,7 @@ private:
LineEditor m_filter_editor;
};
String common_prefix(const memoryview<String>& strings)
String common_prefix(memoryview<String> strings)
{
String res;
if (strings.empty())
@ -879,7 +879,7 @@ void InputHandler::set_prompt_colors(ColorPair prompt_colors)
prompt->set_prompt_colors(prompt_colors);
}
void InputHandler::menu(const memoryview<String>& choices,
void InputHandler::menu(memoryview<String> choices,
MenuCallback callback)
{
m_mode_trash.emplace_back(std::move(m_mode));

View File

@ -57,7 +57,7 @@ public:
// abort or validation with corresponding MenuEvent value
// returns to normal mode after validation if callback does
// not change the mode itself
void menu(const memoryview<String>& choices,
void menu(memoryview<String> choices,
MenuCallback callback);
// execute callback on next keypress and returns to normal mode

View File

@ -413,7 +413,7 @@ void NCursesUI::draw_menu()
redraw();
}
void NCursesUI::menu_show(const memoryview<String>& choices,
void NCursesUI::menu_show(memoryview<String> choices,
DisplayCoord anchor, ColorPair fg, ColorPair bg,
MenuStyle style)
{

View File

@ -26,7 +26,7 @@ public:
bool is_key_available() override;
Key get_key() override;
void menu_show(const memoryview<String>& choices,
void menu_show(memoryview<String> choices,
DisplayCoord anchor, ColorPair fg, ColorPair bg,
MenuStyle style) override;
void menu_select(int selected) override;

View File

@ -109,7 +109,7 @@ struct TupleOptionDetail
tuple_separator + escape(option_to_string(std::get<I>(opt)), tuple_separator, '\\');
}
static void from_string(const memoryview<String>& elems, std::tuple<Types...>& opt)
static void from_string(memoryview<String> elems, std::tuple<Types...>& opt)
{
option_from_string(elems[I], std::get<I>(opt));
TupleOptionDetail<I-1, Types...>::from_string(elems, opt);
@ -124,7 +124,7 @@ struct TupleOptionDetail<0, Types...>
return option_to_string(std::get<0>(opt));
}
static void from_string(const memoryview<String>& elems, std::tuple<Types...>& opt)
static void from_string(memoryview<String> elems, std::tuple<Types...>& opt)
{
option_from_string(elems[0], std::get<0>(opt));
}

View File

@ -13,7 +13,7 @@ class Register
{
public:
virtual ~Register() {}
virtual Register& operator=(const memoryview<String>& values) = 0;
virtual Register& operator=(memoryview<String> values) = 0;
virtual memoryview<String> values(const Context& context) = 0;
};

View File

@ -11,7 +11,7 @@ namespace Kakoune
class StaticRegister : public Register
{
public:
Register& operator=(const memoryview<String>& values) override
Register& operator=(memoryview<String> values) override
{
m_content = std::vector<String>(values.begin(), values.end());
return *this;
@ -40,7 +40,7 @@ public:
DynamicRegister(RegisterRetriever function)
: m_function(std::move(function)) {}
Register& operator=(const memoryview<String>& values) override
Register& operator=(memoryview<String> values) override
{
throw runtime_error("this register is not assignable");
}

View File

@ -62,7 +62,7 @@ public:
};
template<typename T>
void write(const memoryview<T>& view)
void write(memoryview<T> view)
{
write<uint32_t>(view.size());
for (auto& val : view)
@ -213,7 +213,7 @@ public:
void print_status(const DisplayLine& status) override;
void menu_show(const memoryview<String>& choices,
void menu_show(memoryview<String> choices,
DisplayCoord anchor, ColorPair fg, ColorPair bg,
MenuStyle style) override;
void menu_select(int selected) override;
@ -258,7 +258,7 @@ void RemoteUI::print_status(const DisplayLine& status)
msg.write(status);
}
void RemoteUI::menu_show(const memoryview<String>& choices,
void RemoteUI::menu_show(memoryview<String> choices,
DisplayCoord anchor, ColorPair fg, ColorPair bg,
MenuStyle style)
{

View File

@ -17,7 +17,7 @@ ShellManager::ShellManager()
}
String ShellManager::eval(const String& cmdline, const Context& context,
const memoryview<String>& params,
memoryview<String> params,
const EnvVarMap& env_vars)
{
return pipe("", cmdline, context, params, env_vars);
@ -25,7 +25,7 @@ String ShellManager::eval(const String& cmdline, const Context& context,
String ShellManager::pipe(const String& input,
const String& cmdline, const Context& context,
const memoryview<String>& params,
memoryview<String> params,
const EnvVarMap& env_vars)
{
int write_pipe[2]; // child stdin

View File

@ -19,12 +19,12 @@ public:
ShellManager();
String eval(const String& cmdline, const Context& context,
const memoryview<String>& params,
memoryview<String> params,
const EnvVarMap& env_vars);
String pipe(const String& input,
const String& cmdline, const Context& context,
const memoryview<String>& params,
memoryview<String> params,
const EnvVarMap& env_vars);
void register_env_var(const String& regex, EnvVarRetriever retriever);

View File

@ -28,7 +28,7 @@ public:
virtual ~UserInterface() {}
virtual void print_status(const DisplayLine& status) = 0;
virtual void menu_show(const memoryview<String>& choices,
virtual void menu_show(memoryview<String> choices,
DisplayCoord anchor, ColorPair fg, ColorPair bg,
MenuStyle style) = 0;
virtual void menu_select(int selected) = 0;