fish-shell/fish-rust/src/lib.rs

64 lines
1.1 KiB
Rust
Raw Normal View History

2023-01-15 06:56:24 +08:00
#![allow(non_camel_case_types)]
#![allow(dead_code)]
#![allow(non_upper_case_globals)]
#![allow(clippy::needless_return)]
#![allow(clippy::manual_is_ascii_check)]
#![allow(clippy::bool_assert_comparison)]
#![allow(clippy::uninlined_format_args)]
#![allow(clippy::derivable_impls)]
2023-01-15 06:56:24 +08:00
2023-02-26 23:34:03 +08:00
#[macro_use]
2023-02-11 20:31:42 +08:00
mod common;
2023-03-26 01:43:56 +08:00
mod abbrs;
mod builtins;
2023-02-27 04:56:50 +08:00
mod color;
mod compat;
2023-03-26 01:43:56 +08:00
mod env;
mod event;
2023-03-26 01:43:56 +08:00
mod expand;
2023-04-09 19:37:12 +08:00
mod fallback;
Port fd_monitor (and its needed components) I needed to rename some types already ported to rust so they don't clash with their still-extant cpp counterparts. Helper ffi functions added to avoid needing to dynamically allocate an FdMonitorItem for every fd (we use dozens per basic prompt). I ported some functions from cpp to rust that are used only in the backend but without removing their existing cpp counterparts so cpp code can continue to use their version of them (`wperror` and `make_detached_pthread`). I ran into issues porting line-by-line logic because rust inverts the behavior of `std::remove_if(..)` by making it (basically) `Vec::retain_if(..)` so I replaced bools with an explict enum to make everything clearer. I'll port the cpp tests for this separately, for now they're using ffi. Porting closures was ugly. It's nothing hard, but it's very ugly as now each capturing lambda has been changed into an explicit struct that contains its parameters (that needs to be dynamically allocated), a standalone callback (member) function to replace the lambda contents, and a separate trampoline function to call it from rust over the shared C abi (not really relevant to x86_64 w/ its single calling convention but probably needed on other platforms). I don't like that `fd_monitor.rs` has its own `c_void`. I couldn't find a way to move that to `ffi.rs` but still get cxx bridge to consider it a shared POD. Every time I moved it to a different module, it would consider it to be an opaque rust type instead. I worry this means we're going to have multiple `c_void1`, `c_void2`, etc. types as we continue to port code to use function pointers. Also, rust treats raw pointers as foreign so you can't do `impl Send for * const Foo` even if `Foo` is from the same module. That necessitated a wrapper type (`void_ptr`) that implements `Send` and `Sync` so we can move stuff between threads. The code in fd_monitor_t has been split into two objects, one that is used by the caller and a separate one associated with the background thread (this is made nice and clean by rust's ownership model). Objects not needed under the lock (i.e. accessed by the background thread exclusively) were moved to the separate `BackgroundFdMonitor` type.
2023-02-18 09:21:44 +08:00
mod fd_monitor;
2023-01-15 06:56:24 +08:00
mod fd_readable_set;
mod fds;
#[allow(rustdoc::broken_intra_doc_links)]
#[allow(clippy::module_inception)]
#[allow(clippy::new_ret_no_self)]
#[allow(clippy::wrong_self_convention)]
#[allow(clippy::needless_lifetimes)]
2023-01-15 06:56:24 +08:00
mod ffi;
mod ffi_init;
mod ffi_tests;
2023-01-15 06:56:24 +08:00
mod flog;
mod future_feature_flags;
2023-03-28 23:59:51 +08:00
mod global_safety;
2023-04-09 20:06:40 +08:00
mod io;
mod job_group;
mod locale;
2023-02-15 05:54:18 +08:00
mod nix;
2023-02-05 16:35:06 +08:00
mod parse_constants;
2023-03-26 01:43:56 +08:00
mod path;
mod re;
2023-02-04 18:21:42 +08:00
mod redirection;
2023-01-15 06:56:24 +08:00
mod signal;
mod smoke;
mod termsize;
Port fd_monitor (and its needed components) I needed to rename some types already ported to rust so they don't clash with their still-extant cpp counterparts. Helper ffi functions added to avoid needing to dynamically allocate an FdMonitorItem for every fd (we use dozens per basic prompt). I ported some functions from cpp to rust that are used only in the backend but without removing their existing cpp counterparts so cpp code can continue to use their version of them (`wperror` and `make_detached_pthread`). I ran into issues porting line-by-line logic because rust inverts the behavior of `std::remove_if(..)` by making it (basically) `Vec::retain_if(..)` so I replaced bools with an explict enum to make everything clearer. I'll port the cpp tests for this separately, for now they're using ffi. Porting closures was ugly. It's nothing hard, but it's very ugly as now each capturing lambda has been changed into an explicit struct that contains its parameters (that needs to be dynamically allocated), a standalone callback (member) function to replace the lambda contents, and a separate trampoline function to call it from rust over the shared C abi (not really relevant to x86_64 w/ its single calling convention but probably needed on other platforms). I don't like that `fd_monitor.rs` has its own `c_void`. I couldn't find a way to move that to `ffi.rs` but still get cxx bridge to consider it a shared POD. Every time I moved it to a different module, it would consider it to be an opaque rust type instead. I worry this means we're going to have multiple `c_void1`, `c_void2`, etc. types as we continue to port code to use function pointers. Also, rust treats raw pointers as foreign so you can't do `impl Send for * const Foo` even if `Foo` is from the same module. That necessitated a wrapper type (`void_ptr`) that implements `Send` and `Sync` so we can move stuff between threads. The code in fd_monitor_t has been split into two objects, one that is used by the caller and a separate one associated with the background thread (this is made nice and clean by rust's ownership model). Objects not needed under the lock (i.e. accessed by the background thread exclusively) were moved to the separate `BackgroundFdMonitor` type.
2023-02-18 09:21:44 +08:00
mod threads;
2023-02-15 05:54:18 +08:00
mod timer;
2023-02-05 16:35:06 +08:00
mod tokenizer;
2023-01-15 06:56:24 +08:00
mod topic_monitor;
2023-03-28 23:59:51 +08:00
mod trace;
mod util;
mod wait_handle;
2023-01-15 06:56:24 +08:00
mod wchar;
mod wchar_ext;
mod wchar_ffi;
mod wcstringutil;
2023-01-15 06:56:24 +08:00
mod wgetopt;
2023-04-09 00:26:45 +08:00
mod widecharwidth;
mod wildcard;
mod wutil;
// Don't use `#[cfg(test)]` here to make sure ffi tests are built and tested
mod tests;