Johannes Altmanninger
915db44fbd
Implement printf formatting for some parser types
2023-04-16 17:46:56 +02:00
Johannes Altmanninger
dc4cb84ffc
Derive Debug for some parser types
2023-04-16 17:46:56 +02:00
Johannes Altmanninger
912f10ceb0
Port io
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
ecb0ab5f34
common.rs: remove G_ prefix from globals
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
238d9bf3a5
Minor cleanup of JobId::acquire
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
4036b1ab95
Make Event::caller_exit take a JobId, not an i32
...
A JobId is not supposed to convert to other types.
Since this type is defined as NonZeroU32 (which cannot be -1), we need to
add some conversion functions to match the C++ behavior.
Overall, it would have been better to keep using the C++ type.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
37a7fe6738
event.rs: use libc::c_int for signal numbers, not usize
...
This makes porting easier. Once everything is done, we can apply such
changes globally.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
f5d8087bc6
job_group.rs: use our canonical string type
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
da45bfab6b
wait_handle.rs: implement Rusty set_status_and_complete
...
This function didn't exists in LastC++11 but given that "status" is private
I did not see an obvious alternative.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
141dcde498
signal.rs: crash a bit earlier when signal number is negative
...
The conversion to usize is used for array accesses, so negative values
would cause crashes either way. Let's do it earlier so we can get rid of
the suspect C-style cast.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
11df0bf54b
signal.rs: use wide strings for string conversion
...
This makes it play better with the rest of the system,
in particular summary_command() from proc.h.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
f9a48dc946
flog.rs: allow trailing commas
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
91008acd3e
fd_monitor.rs: make NativeCallback public
...
The upcoming io.rs calls "FdMonitorItem::new". We cannot pass a closure,
we must pass an object of type NativeCallback.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
7069455e68
topic_monitor.rs: minor touch-up
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
483f893613
fds.rs: port the open_cloexec family
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
a5cae59082
Replace ScopedPush with scoped_push which is underpinned by ScopeGuard
...
This allows us to use the scoped push in more scenarios by appeasing the
borrow checker.
Use it in a couple of places instead of ScopeGuard. Hopefully this is makes
porting easier.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
2d4fbc290b
Teach ScopeGuard to expose a custom view on deref()
...
This allows the upcoming scoped_push to stuff internal data into the context,
but not expose it to the user.
(This change is a bit ugly, needs polish)
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
a696f16aa1
compat.c: wrapper to access ncurses cur_term
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
9d436ee5e9
common.rs: port get_by_sorted_name()
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
c6b8b7548f
common.rs: add fwprintf and fwputs for convenience
...
We should get rid of them but this helps with porting.
Not sure if they are fully correct.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
f53aa6f2e3
Port the rest of wutil
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
d3a7e3ffd9
Allow to call join_strings with a &[WString]
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
8e972dbab0
Move wrealpath and normalize_path to match C++ structure
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
b7638b50e4
common.rs: convenience function to convert to OsString
...
Even though we generally dont' want to use this type (because it's immutable),
it can be advantageous when working with the std::fs API. This is because
it implements "AsRef<Path>" which neither of CString and Vec<u8> do.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
bfe68e6a83
common.rs: helper to convert from C-string of unknown length to wide
...
On the C++ side we have an overload that called std::wcslen(), this is the
equivalent one.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
3163efb87f
Port most of fallback
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
1426d1bcb0
Port widecharwidth
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
8bbf663dee
common.rs: make some functions public
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
bff0caf1d8
common.rs: remove typedefs that have been ported to elsewhere
...
In general we should keep the existing structure, to minimize surprise.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
8ae1ba3432
wutil: remove unused locale handling code that has been ported already
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
77ae80f842
wutil.cpp: remove unused function
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
d47590b864
proc.h: remove unused declaration
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
16ea4380c5
redirection.rs: don't leak FFI type into Rust code
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
807d1578c3
redirection.rs: make redirection spec fields public like in C++
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
11e16ef6df
env.rs: rename flags::EnvMode to EnvMode
...
The "flags" module was introduced when these where standalone constants.
Now that we define them as bitflags, we no longer need the extra namespace.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
8e5adbf237
Use borrowing syntax instead of std::ptr::addr_of where possible
...
We usually don't need to cast; this looks simpler.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
ed2b98dd9a
lib.rs: group common.rs before other modules, because it exports macros
...
This allows us to keep the next group sorted.
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
a848877e65
Remove an overload in io, to prepare for Rust
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
85ae1861fa
common.rs: fix leftover comment
2023-04-16 17:21:54 +02:00
Johannes Altmanninger
df6525e770
Make RustBuiltin a scoped enum
...
This prevents name clashes. It already is used as scoped enum.
2023-04-16 17:21:54 +02:00
Xiretza
61028f020c
cargo update
...
This fixes an issue with rust-analyzer always rebuilding even without changes,
which was introduced by b8189da011
.
2023-04-16 17:21:54 +02:00
Fabian Boehm
bf0ebd3967
Actually add builtin.rs
2023-04-16 11:41:41 +02:00
Fabian Boehm
72a32f1a12
Rewrite "builtin" builtin in Rust
...
This is very simple and basically a subset of type.
2023-04-16 11:30:31 +02:00
Fabian Boehm
b65a53a2a6
Rewrite "command" builtin in Rust
...
This is basically a subset of type, so we might as well.
To be clear this is `command -s` and friends, if you do `command grep` that's
handled as a keyword.
One issue here is that we can't get "one path or not" because I don't
know how to translate a maybe_t? Do we need to make it a shared_ptr instead?
2023-04-16 11:27:08 +02:00
Fabian Boehm
662a4740e2
Rewrite the type builtin in rust
2023-04-16 11:27:08 +02:00
Fabian Boehm
7c37b681b2
Expose out_is_redirected to rust
2023-04-16 11:27:08 +02:00
Fabian Boehm
d02d0f3309
highlight: Add colorize_shell wrapper
...
Since we don't reuse the vector anyway, this allows us to keep the
highlighting on the C++-side.
2023-04-16 11:27:08 +02:00
Fabian Boehm
31d65de26c
function: Add a bunch of awkward helper functions
...
This makes function_properties_ref_t not const, in order to work
around cxx
2023-04-16 11:27:08 +02:00
Fabian Boehm
d0c2d0c9cf
path: Add method to return wcstring_list_ffi_t
...
This is palatable to Cxx
2023-04-16 11:27:08 +02:00
ridiculousfish
15c8f08458
Eliminate to_rust_string_vec
...
This can just use wcstring_list_ffi_t now.
2023-04-15 18:15:37 -07:00