mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 05:43:11 +00:00
function: Add a bunch of awkward helper functions
This makes function_properties_ref_t not const, in order to work around cxx
This commit is contained in:
parent
d0c2d0c9cf
commit
31d65de26c
3 changed files with 39 additions and 1 deletions
|
@ -100,6 +100,14 @@ include_cpp! {
|
|||
generate!("io_chain_t")
|
||||
|
||||
generate!("env_var_t")
|
||||
|
||||
generate!("function_get_definition_file")
|
||||
generate!("function_get_copy_definition_file")
|
||||
generate!("function_get_definition_lineno")
|
||||
generate!("function_get_copy_definition_lineno")
|
||||
generate!("function_get_annotated_definition")
|
||||
generate!("function_is_copy")
|
||||
generate!("function_exists")
|
||||
}
|
||||
|
||||
impl parser_t {
|
||||
|
|
|
@ -165,6 +165,27 @@ function_properties_ref_t function_get_props(const wcstring &name) {
|
|||
return function_set.acquire()->get_props(name);
|
||||
}
|
||||
|
||||
wcstring function_get_definition_file(const function_properties_t &props) {
|
||||
return props.definition_file ? *props.definition_file : L"";
|
||||
}
|
||||
|
||||
wcstring function_get_copy_definition_file(const function_properties_t &props) {
|
||||
return props.copy_definition_file ? *props.copy_definition_file : L"";
|
||||
}
|
||||
bool function_is_copy(const function_properties_t &props) {
|
||||
return props.is_copy;
|
||||
}
|
||||
int function_get_definition_lineno(const function_properties_t &props) {
|
||||
return props.definition_lineno();
|
||||
}
|
||||
int function_get_copy_definition_lineno(const function_properties_t &props) {
|
||||
return props.copy_definition_lineno;
|
||||
}
|
||||
|
||||
wcstring function_get_annotated_definition(const function_properties_t &props, const wcstring &name) {
|
||||
return props.annotated_definition(name);
|
||||
}
|
||||
|
||||
function_properties_ref_t function_get_props_autoload(const wcstring &name, parser_t &parser) {
|
||||
parser.assert_can_execute();
|
||||
if (parser_keywords_is_reserved(name)) return nullptr;
|
||||
|
|
|
@ -67,7 +67,8 @@ struct function_properties_t {
|
|||
wcstring annotated_definition(const wcstring &name) const;
|
||||
};
|
||||
|
||||
using function_properties_ref_t = std::shared_ptr<const function_properties_t>;
|
||||
// FIXME: Morally, this is const, but cxx doesn't get it
|
||||
using function_properties_ref_t = std::shared_ptr<function_properties_t>;
|
||||
|
||||
/// Add a function. This may mutate \p props to set is_autoload.
|
||||
void function_add(wcstring name, std::shared_ptr<function_properties_t> props);
|
||||
|
@ -78,6 +79,14 @@ void function_remove(const wcstring &name);
|
|||
/// \return the properties for a function, or nullptr if none. This does not trigger autoloading.
|
||||
function_properties_ref_t function_get_props(const wcstring &name);
|
||||
|
||||
/// Guff to work around cxx not getting function_properties_t.
|
||||
wcstring function_get_definition_file(const function_properties_t &props);
|
||||
wcstring function_get_copy_definition_file(const function_properties_t &props);
|
||||
bool function_is_copy(const function_properties_t &props);
|
||||
int function_get_definition_lineno(const function_properties_t &props);
|
||||
int function_get_copy_definition_lineno(const function_properties_t &props);
|
||||
wcstring function_get_annotated_definition(const function_properties_t &props, const wcstring &name);
|
||||
|
||||
/// \return the properties for a function, or nullptr if none, perhaps triggering autoloading.
|
||||
function_properties_ref_t function_get_props_autoload(const wcstring &name, parser_t &parser);
|
||||
|
||||
|
|
Loading…
Reference in a new issue