Expose out_is_redirected to rust

This commit is contained in:
Fabian Boehm 2023-04-10 19:49:50 +02:00
parent d02d0f3309
commit 7c37b681b2
3 changed files with 13 additions and 1 deletions

View file

@ -89,14 +89,21 @@ pub struct io_streams_t {
streams: *mut builtins_ffi::io_streams_t,
pub out: output_stream_t,
pub err: output_stream_t,
pub out_is_redirected: bool,
}
impl io_streams_t {
pub fn new(mut streams: Pin<&mut builtins_ffi::io_streams_t>) -> io_streams_t {
let out = output_stream_t(streams.as_mut().get_out().unpin());
let err = output_stream_t(streams.as_mut().get_err().unpin());
let out_is_redirected = streams.as_mut().get_out_redirected();
let streams = streams.unpin();
io_streams_t { streams, out, err }
io_streams_t {
streams,
out,
err,
out_is_redirected,
}
}
pub fn ffi_pin(&mut self) -> Pin<&mut builtins_ffi::io_streams_t> {

View file

@ -25,6 +25,8 @@ include_cpp! {
#include "fallback.h"
#include "fds.h"
#include "flog.h"
#include "function.h"
#include "highlight.h"
#include "io.h"
#include "parse_constants.h"
#include "parser.h"
@ -108,6 +110,8 @@ include_cpp! {
generate!("function_get_annotated_definition")
generate!("function_is_copy")
generate!("function_exists")
generate!("colorize_shell")
}
impl parser_t {

View file

@ -512,6 +512,7 @@ struct io_streams_t : noncopyable_t {
output_stream_t &get_out() { return out; };
output_stream_t &get_err() { return err; };
io_streams_t(const io_streams_t &) = delete;
bool get_out_redirected() { return out_is_redirected; };
};
#endif