Remove some obsolete bridged C++ functions

Most of these were doubled and the C++ variant is obsolete.
This commit is contained in:
Johannes Altmanninger 2024-01-01 19:22:35 +01:00
parent c758765503
commit 5d299d21a1
6 changed files with 12 additions and 24 deletions

View file

@ -10,7 +10,6 @@ use crate::env::{EnvMode, EnvStackSetResult, EnvVar, Statuses};
use crate::env_dispatch::{env_dispatch_init, env_dispatch_var_change};
use crate::env_universal_common::{CallbackDataList, EnvUniversal};
use crate::event::Event;
use crate::ffi;
use crate::flog::FLOG;
use crate::global_safety::RelaxedAtomicBool;
use crate::input::init_input;
@ -576,7 +575,6 @@ pub fn env_init(paths: Option<&ConfigPaths>, do_uvars: bool, default_paths: bool
INHERITED_VARS
.set(inherited_vars)
.expect("env_init is being called multiple times");
ffi::set_inheriteds_ffi();
if let Some(paths) = paths {
vars.set_one(

View file

@ -39,14 +39,6 @@ include_cpp! {
generate_pod!("wcharz_t")
generate!("wcstring_list_ffi_t")
generate!("set_inheriteds_ffi")
generate!("set_profiling_active")
generate!("set_flog_output_file_ffi")
generate!("flog_setlinebuf_ffi")
generate!("activate_flog_categories_by_pattern")
generate!("log_extra_to_flog_file")
generate!("wgettext_ptr")

View file

@ -27,6 +27,7 @@ use crate::{
restore_term_foreground_process_group_for_exit, save_term_foreground_process_group,
scoped_push_replacer, str2wcstring, wcs2string, PROFILING_ACTIVE, PROGRAM_NAME,
},
compat::setlinebuf,
env::Statuses,
env::{
environment::{env_init, EnvStack, Environment},
@ -34,7 +35,6 @@ use crate::{
},
event::{self, Event},
fds::set_cloexec,
ffi::{self},
flog::{self, activate_flog_categories_by_pattern, set_flog_file_fd, FLOG, FLOGF},
function, future_feature_flags as features, history,
history::start_private_mode,
@ -387,7 +387,6 @@ fn fish_parse_opt(args: &mut [WString], opts: &mut FishCmdOpts) -> usize {
.postconfig_cmds
.push(OsString::from_vec(wcs2string(w.woptarg.unwrap()))),
'd' => {
ffi::activate_flog_categories_by_pattern(w.woptarg.unwrap());
activate_flog_categories_by_pattern(w.woptarg.unwrap());
for cat in flog::categories::all_categories() {
if cat.enabled.load(Ordering::Relaxed) {
@ -432,7 +431,6 @@ fn fish_parse_opt(args: &mut [WString], opts: &mut FishCmdOpts) -> usize {
opts.profile_startup_output =
Some(OsString::from_vec(wcs2string(w.woptarg.unwrap())));
PROFILING_ACTIVE.store(true);
ffi::set_profiling_active(true);
}
'P' => opts.enable_private_mode = true,
'v' => {
@ -525,7 +523,6 @@ fn main() -> i32 {
if let Some(debug_categories) = env::var_os("FISH_DEBUG") {
let s = str2wcstring(debug_categories.as_bytes());
activate_flog_categories_by_pattern(&s);
ffi::activate_flog_categories_by_pattern(s);
}
let mut opts = FishCmdOpts::default();
@ -552,8 +549,7 @@ fn main() -> i32 {
}
set_cloexec(unsafe { libc::fileno(debug_file) }, true);
ffi::flog_setlinebuf_ffi(debug_file as *mut _);
ffi::set_flog_output_file_ffi(debug_file as *mut _);
unsafe { setlinebuf(debug_file) };
set_flog_file_fd(unsafe { libc::fileno(debug_file) });
debug_output = debug_file;
@ -675,7 +671,6 @@ fn main() -> i32 {
}
PROFILING_ACTIVE.store(opts.profile_output.is_some());
ffi::set_profiling_active(opts.profile_output.is_some());
// Run post-config commands specified as arguments, if any.
if !opts.postconfig_cmds.is_empty() {

View file

@ -28,16 +28,15 @@ use crate::highlight::{colorize, highlight_shell, HighlightRole, HighlightSpec};
use crate::operation_context::OperationContext;
use crate::parse_constants::{ParseTokenType, ParseTreeFlags, SourceRange};
use crate::parse_util::parse_util_compute_indents;
use crate::print_help::print_help;
use crate::threads;
use crate::tokenizer::{TokenType, Tokenizer, TOK_SHOW_BLANK_LINES, TOK_SHOW_COMMENTS};
use crate::topic_monitor::topic_monitor_init;
use crate::wchar::prelude::*;
use crate::wchar_ffi::WCharToFFI;
use crate::wcstringutil::count_preceding_backslashes;
use crate::wgetopt::{wgetopter_t, wopt, woption, woption_argument_t};
use crate::wutil::perror;
use crate::wutil::{fish_iswalnum, write_to_fd};
use crate::{ffi, print_help::print_help};
use crate::{
flog::{self, activate_flog_categories_by_pattern, set_flog_file_fd},
future_feature_flags,
@ -805,7 +804,6 @@ fn fish_indent_main() -> i32 {
'\x03' => output_type = OutputType::PygmentsCsv,
'c' => output_type = OutputType::Check,
'd' => {
ffi::activate_flog_categories_by_pattern(w.woptarg.unwrap().to_ffi());
activate_flog_categories_by_pattern(w.woptarg.unwrap());
for cat in flog::categories::all_categories() {
if cat.enabled.load(Ordering::Relaxed) {

View file

@ -1,7 +1,7 @@
use crate::parse_util::parse_util_unescape_wildcards;
use crate::wchar::prelude::*;
use crate::wildcard::wildcard_match;
use crate::wutil::write_to_fd;
use crate::{parse_util::parse_util_unescape_wildcards, wutil::wwrite_to_fd};
use libc::c_int;
use std::sync::atomic::{AtomicI32, Ordering};
@ -251,3 +251,7 @@ pub fn set_flog_file_fd(fd: c_int) {
pub fn get_flog_file_fd() -> c_int {
FLOG_FD.load(Ordering::Relaxed)
}
pub fn log_extra_to_flog_file(s: &wstr) {
wwrite_to_fd(s, get_flog_file_fd());
}

View file

@ -1,10 +1,11 @@
use crate::flog::log_extra_to_flog_file;
use crate::parser::Parser;
use crate::{
common::escape,
ffi::{self, wcharz_t, wcstring_list_ffi_t},
ffi::{wcharz_t, wcstring_list_ffi_t},
global_safety::RelaxedAtomicBool,
wchar::prelude::*,
wchar_ffi::{WCharFromFFI, WCharToFFI},
wchar_ffi::WCharFromFFI,
};
#[cxx::bridge]
@ -65,7 +66,7 @@ pub fn trace_argv<S: AsRef<wstr>>(parser: &Parser, command: &wstr, args: &[S]) {
trace_text.push_utfstr(&escape(arg.as_ref()));
}
trace_text.push('\n');
ffi::log_extra_to_flog_file(&trace_text.to_ffi());
log_extra_to_flog_file(&trace_text);
}
pub fn trace_if_enabled_ffi<S: AsRef<wstr>>(parser: &Parser, command: &wstr, args: &[S]) {