Revert "BuiltinData to use const constructor function"

Unfortunately, this does not work with rust 1.70.

This reverts commit 7e516925e9.
This commit is contained in:
Fabian Boehm 2024-12-08 07:52:57 +01:00
parent 7e516925e9
commit 004953a3b2

View File

@ -109,77 +109,254 @@ struct BuiltinData {
func: BuiltinCmd, func: BuiltinCmd,
} }
impl BuiltinData {
const fn new(name: &'static wstr, func: BuiltinCmd) -> Self {
Self { name, func }
}
}
// Data about all the builtin commands in fish. // Data about all the builtin commands in fish.
// Functions that are bound to builtin_generic are handled directly by the parser. // Functions that are bound to builtin_generic are handled directly by the parser.
// NOTE: These must be kept in sorted order! // NOTE: These must be kept in sorted order!
const BUILTIN_DATAS: &[BuiltinData] = &[ const BUILTIN_DATAS: &[BuiltinData] = &[
BuiltinData::new(L!("."), source::source), BuiltinData {
BuiltinData::new(L!(":"), builtin_true), name: L!("."),
BuiltinData::new(L!("["), test::test), // ] func: source::source,
BuiltinData::new(L!("_"), builtin_gettext), },
BuiltinData::new(L!("abbr"), abbr::abbr), BuiltinData {
BuiltinData::new(L!("and"), builtin_generic), name: L!(":"),
BuiltinData::new(L!("argparse"), argparse::argparse), func: builtin_true,
BuiltinData::new(L!("begin"), builtin_generic), },
BuiltinData::new(L!("bg"), bg::bg), BuiltinData {
BuiltinData::new(L!("bind"), bind::bind), name: L!("["), // ]
BuiltinData::new(L!("block"), block::block), func: test::test,
BuiltinData::new(L!("break"), builtin_break_continue), },
BuiltinData::new(L!("breakpoint"), builtin_breakpoint), BuiltinData {
BuiltinData::new(L!("builtin"), builtin::builtin), name: L!("_"),
BuiltinData::new(L!("case"), builtin_generic), func: builtin_gettext,
BuiltinData::new(L!("cd"), cd::cd), },
BuiltinData::new(L!("command"), command::command), BuiltinData {
BuiltinData::new(L!("commandline"), commandline::commandline), name: L!("abbr"),
BuiltinData::new(L!("complete"), complete::complete), func: abbr::abbr,
BuiltinData::new(L!("contains"), contains::contains), },
BuiltinData::new(L!("continue"), builtin_break_continue), BuiltinData {
BuiltinData::new(L!("count"), count::count), name: L!("and"),
BuiltinData::new(L!("disown"), disown::disown), func: builtin_generic,
BuiltinData::new(L!("echo"), echo::echo), },
BuiltinData::new(L!("else"), builtin_generic), BuiltinData {
BuiltinData::new(L!("emit"), emit::emit), name: L!("argparse"),
BuiltinData::new(L!("end"), builtin_generic), func: argparse::argparse,
BuiltinData::new(L!("eval"), eval::eval), },
BuiltinData::new(L!("exec"), builtin_generic), BuiltinData {
BuiltinData::new(L!("exit"), exit::exit), name: L!("begin"),
BuiltinData::new(L!("false"), builtin_false), func: builtin_generic,
BuiltinData::new(L!("fg"), fg::fg), },
BuiltinData::new(L!("for"), builtin_generic), BuiltinData {
BuiltinData::new(L!("function"), builtin_generic), name: L!("bg"),
BuiltinData::new(L!("functions"), functions::functions), func: bg::bg,
BuiltinData::new(L!("history"), history::history), },
BuiltinData::new(L!("if"), builtin_generic), BuiltinData {
BuiltinData::new(L!("jobs"), jobs::jobs), name: L!("bind"),
BuiltinData::new(L!("math"), math::math), func: bind::bind,
BuiltinData::new(L!("not"), builtin_generic), },
BuiltinData::new(L!("or"), builtin_generic), BuiltinData {
BuiltinData::new(L!("path"), path::path), name: L!("block"),
BuiltinData::new(L!("printf"), printf::printf), func: block::block,
BuiltinData::new(L!("pwd"), pwd::pwd), },
BuiltinData::new(L!("random"), random::random), BuiltinData {
BuiltinData::new(L!("read"), read::read), name: L!("break"),
BuiltinData::new(L!("realpath"), realpath::realpath), func: builtin_break_continue,
BuiltinData::new(L!("return"), r#return::r#return), },
BuiltinData::new(L!("set"), set::set), BuiltinData {
BuiltinData::new(L!("set_color"), set_color::set_color), name: L!("breakpoint"),
BuiltinData::new(L!("source"), source::source), func: builtin_breakpoint,
BuiltinData::new(L!("status"), status::status), },
BuiltinData::new(L!("string"), string::string), BuiltinData {
BuiltinData::new(L!("switch"), builtin_generic), name: L!("builtin"),
BuiltinData::new(L!("test"), test::test), func: builtin::builtin,
BuiltinData::new(L!("time"), builtin_generic), },
BuiltinData::new(L!("true"), builtin_true), BuiltinData {
BuiltinData::new(L!("type"), r#type::r#type), name: L!("case"),
BuiltinData::new(L!("ulimit"), ulimit::ulimit), func: builtin_generic,
BuiltinData::new(L!("wait"), wait::wait), },
BuiltinData::new(L!("while"), builtin_generic), BuiltinData {
name: L!("cd"),
func: cd::cd,
},
BuiltinData {
name: L!("command"),
func: command::command,
},
BuiltinData {
name: L!("commandline"),
func: commandline::commandline,
},
BuiltinData {
name: L!("complete"),
func: complete::complete,
},
BuiltinData {
name: L!("contains"),
func: contains::contains,
},
BuiltinData {
name: L!("continue"),
func: builtin_break_continue,
},
BuiltinData {
name: L!("count"),
func: count::count,
},
BuiltinData {
name: L!("disown"),
func: disown::disown,
},
BuiltinData {
name: L!("echo"),
func: echo::echo,
},
BuiltinData {
name: L!("else"),
func: builtin_generic,
},
BuiltinData {
name: L!("emit"),
func: emit::emit,
},
BuiltinData {
name: L!("end"),
func: builtin_generic,
},
BuiltinData {
name: L!("eval"),
func: eval::eval,
},
BuiltinData {
name: L!("exec"),
func: builtin_generic,
},
BuiltinData {
name: L!("exit"),
func: exit::exit,
},
BuiltinData {
name: L!("false"),
func: builtin_false,
},
BuiltinData {
name: L!("fg"),
func: fg::fg,
},
BuiltinData {
name: L!("for"),
func: builtin_generic,
},
BuiltinData {
name: L!("function"),
func: builtin_generic,
},
BuiltinData {
name: L!("functions"),
func: functions::functions,
},
BuiltinData {
name: L!("history"),
func: history::history,
},
BuiltinData {
name: L!("if"),
func: builtin_generic,
},
BuiltinData {
name: L!("jobs"),
func: jobs::jobs,
},
BuiltinData {
name: L!("math"),
func: math::math,
},
BuiltinData {
name: L!("not"),
func: builtin_generic,
},
BuiltinData {
name: L!("or"),
func: builtin_generic,
},
BuiltinData {
name: L!("path"),
func: path::path,
},
BuiltinData {
name: L!("printf"),
func: printf::printf,
},
BuiltinData {
name: L!("pwd"),
func: pwd::pwd,
},
BuiltinData {
name: L!("random"),
func: random::random,
},
BuiltinData {
name: L!("read"),
func: read::read,
},
BuiltinData {
name: L!("realpath"),
func: realpath::realpath,
},
BuiltinData {
name: L!("return"),
func: r#return::r#return,
},
BuiltinData {
name: L!("set"),
func: set::set,
},
BuiltinData {
name: L!("set_color"),
func: set_color::set_color,
},
BuiltinData {
name: L!("source"),
func: source::source,
},
BuiltinData {
name: L!("status"),
func: status::status,
},
BuiltinData {
name: L!("string"),
func: string::string,
},
BuiltinData {
name: L!("switch"),
func: builtin_generic,
},
BuiltinData {
name: L!("test"),
func: test::test,
},
BuiltinData {
name: L!("time"),
func: builtin_generic,
},
BuiltinData {
name: L!("true"),
func: builtin_true,
},
BuiltinData {
name: L!("type"),
func: r#type::r#type,
},
BuiltinData {
name: L!("ulimit"),
func: ulimit::ulimit,
},
BuiltinData {
name: L!("wait"),
func: wait::wait,
},
BuiltinData {
name: L!("while"),
func: builtin_generic,
},
]; ];
assert_sorted_by_name!(BUILTIN_DATAS); assert_sorted_by_name!(BUILTIN_DATAS);