Migrate some function properties into a shared_ptr

The idea is that we can return the shared pointer directly, avoiding
lots of annoying little getter functions that each need to take locks.
It also helps to pull together the data structures used to initialize
functions versus store them.
This commit is contained in:
ridiculousfish
2018-02-11 16:37:38 -08:00
parent 41ba0dfadb
commit db33ed0fc7
3 changed files with 55 additions and 62 deletions

View File

@@ -249,23 +249,20 @@ int builtin_function(parser_t &parser, io_streams_t &streams, const wcstring_lis
if (!opts.description.empty()) d.description = opts.description;
// d.description = opts.description;
d.events.swap(opts.events);
d.shadow_scope = opts.shadow_scope;
d.named_arguments.swap(opts.named_arguments);
d.inherit_vars.swap(opts.inherit_vars);
d.props.shadow_scope = opts.shadow_scope;
d.props.named_arguments = std::move(opts.named_arguments);
d.inherit_vars = std::move(opts.inherit_vars);
for (size_t i = 0; i < d.events.size(); i++) {
event_t &e = d.events.at(i);
e.function_name = d.name;
}
d.parsed_source = source;
d.body_node = body;
function_add(d, parser);
d.props.parsed_source = source;
d.props.body_node = body;
function_add(std::move(d), parser);
// Handle wrap targets by creating the appropriate completions.
for (size_t w = 0; w < opts.wrap_targets.size(); w++) {
complete_add_wrapper(function_name, opts.wrap_targets.at(w));
}
for (const wcstring &wt : opts.wrap_targets) complete_add_wrapper(function_name, wt);
return STATUS_CMD_OK;
}