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

View file

@ -39,14 +39,6 @@ include_cpp! {
generate_pod!("wcharz_t") generate_pod!("wcharz_t")
generate!("wcstring_list_ffi_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") generate!("wgettext_ptr")

View file

@ -27,6 +27,7 @@ use crate::{
restore_term_foreground_process_group_for_exit, save_term_foreground_process_group, restore_term_foreground_process_group_for_exit, save_term_foreground_process_group,
scoped_push_replacer, str2wcstring, wcs2string, PROFILING_ACTIVE, PROGRAM_NAME, scoped_push_replacer, str2wcstring, wcs2string, PROFILING_ACTIVE, PROGRAM_NAME,
}, },
compat::setlinebuf,
env::Statuses, env::Statuses,
env::{ env::{
environment::{env_init, EnvStack, Environment}, environment::{env_init, EnvStack, Environment},
@ -34,7 +35,6 @@ use crate::{
}, },
event::{self, Event}, event::{self, Event},
fds::set_cloexec, fds::set_cloexec,
ffi::{self},
flog::{self, activate_flog_categories_by_pattern, set_flog_file_fd, FLOG, FLOGF}, flog::{self, activate_flog_categories_by_pattern, set_flog_file_fd, FLOG, FLOGF},
function, future_feature_flags as features, history, function, future_feature_flags as features, history,
history::start_private_mode, history::start_private_mode,
@ -387,7 +387,6 @@ fn fish_parse_opt(args: &mut [WString], opts: &mut FishCmdOpts) -> usize {
.postconfig_cmds .postconfig_cmds
.push(OsString::from_vec(wcs2string(w.woptarg.unwrap()))), .push(OsString::from_vec(wcs2string(w.woptarg.unwrap()))),
'd' => { 'd' => {
ffi::activate_flog_categories_by_pattern(w.woptarg.unwrap());
activate_flog_categories_by_pattern(w.woptarg.unwrap()); activate_flog_categories_by_pattern(w.woptarg.unwrap());
for cat in flog::categories::all_categories() { for cat in flog::categories::all_categories() {
if cat.enabled.load(Ordering::Relaxed) { 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 = opts.profile_startup_output =
Some(OsString::from_vec(wcs2string(w.woptarg.unwrap()))); Some(OsString::from_vec(wcs2string(w.woptarg.unwrap())));
PROFILING_ACTIVE.store(true); PROFILING_ACTIVE.store(true);
ffi::set_profiling_active(true);
} }
'P' => opts.enable_private_mode = true, 'P' => opts.enable_private_mode = true,
'v' => { 'v' => {
@ -525,7 +523,6 @@ fn main() -> i32 {
if let Some(debug_categories) = env::var_os("FISH_DEBUG") { if let Some(debug_categories) = env::var_os("FISH_DEBUG") {
let s = str2wcstring(debug_categories.as_bytes()); let s = str2wcstring(debug_categories.as_bytes());
activate_flog_categories_by_pattern(&s); activate_flog_categories_by_pattern(&s);
ffi::activate_flog_categories_by_pattern(s);
} }
let mut opts = FishCmdOpts::default(); let mut opts = FishCmdOpts::default();
@ -552,8 +549,7 @@ fn main() -> i32 {
} }
set_cloexec(unsafe { libc::fileno(debug_file) }, true); set_cloexec(unsafe { libc::fileno(debug_file) }, true);
ffi::flog_setlinebuf_ffi(debug_file as *mut _); unsafe { setlinebuf(debug_file) };
ffi::set_flog_output_file_ffi(debug_file as *mut _);
set_flog_file_fd(unsafe { libc::fileno(debug_file) }); set_flog_file_fd(unsafe { libc::fileno(debug_file) });
debug_output = debug_file; debug_output = debug_file;
@ -675,7 +671,6 @@ fn main() -> i32 {
} }
PROFILING_ACTIVE.store(opts.profile_output.is_some()); 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. // Run post-config commands specified as arguments, if any.
if !opts.postconfig_cmds.is_empty() { 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::operation_context::OperationContext;
use crate::parse_constants::{ParseTokenType, ParseTreeFlags, SourceRange}; use crate::parse_constants::{ParseTokenType, ParseTreeFlags, SourceRange};
use crate::parse_util::parse_util_compute_indents; use crate::parse_util::parse_util_compute_indents;
use crate::print_help::print_help;
use crate::threads; use crate::threads;
use crate::tokenizer::{TokenType, Tokenizer, TOK_SHOW_BLANK_LINES, TOK_SHOW_COMMENTS}; use crate::tokenizer::{TokenType, Tokenizer, TOK_SHOW_BLANK_LINES, TOK_SHOW_COMMENTS};
use crate::topic_monitor::topic_monitor_init; use crate::topic_monitor::topic_monitor_init;
use crate::wchar::prelude::*; use crate::wchar::prelude::*;
use crate::wchar_ffi::WCharToFFI;
use crate::wcstringutil::count_preceding_backslashes; use crate::wcstringutil::count_preceding_backslashes;
use crate::wgetopt::{wgetopter_t, wopt, woption, woption_argument_t}; use crate::wgetopt::{wgetopter_t, wopt, woption, woption_argument_t};
use crate::wutil::perror; use crate::wutil::perror;
use crate::wutil::{fish_iswalnum, write_to_fd}; use crate::wutil::{fish_iswalnum, write_to_fd};
use crate::{ffi, print_help::print_help};
use crate::{ use crate::{
flog::{self, activate_flog_categories_by_pattern, set_flog_file_fd}, flog::{self, activate_flog_categories_by_pattern, set_flog_file_fd},
future_feature_flags, future_feature_flags,
@ -805,7 +804,6 @@ fn fish_indent_main() -> i32 {
'\x03' => output_type = OutputType::PygmentsCsv, '\x03' => output_type = OutputType::PygmentsCsv,
'c' => output_type = OutputType::Check, 'c' => output_type = OutputType::Check,
'd' => { 'd' => {
ffi::activate_flog_categories_by_pattern(w.woptarg.unwrap().to_ffi());
activate_flog_categories_by_pattern(w.woptarg.unwrap()); activate_flog_categories_by_pattern(w.woptarg.unwrap());
for cat in flog::categories::all_categories() { for cat in flog::categories::all_categories() {
if cat.enabled.load(Ordering::Relaxed) { 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::wchar::prelude::*;
use crate::wildcard::wildcard_match; use crate::wildcard::wildcard_match;
use crate::wutil::write_to_fd; use crate::wutil::write_to_fd;
use crate::{parse_util::parse_util_unescape_wildcards, wutil::wwrite_to_fd};
use libc::c_int; use libc::c_int;
use std::sync::atomic::{AtomicI32, Ordering}; 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 { pub fn get_flog_file_fd() -> c_int {
FLOG_FD.load(Ordering::Relaxed) 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::parser::Parser;
use crate::{ use crate::{
common::escape, common::escape,
ffi::{self, wcharz_t, wcstring_list_ffi_t}, ffi::{wcharz_t, wcstring_list_ffi_t},
global_safety::RelaxedAtomicBool, global_safety::RelaxedAtomicBool,
wchar::prelude::*, wchar::prelude::*,
wchar_ffi::{WCharFromFFI, WCharToFFI}, wchar_ffi::WCharFromFFI,
}; };
#[cxx::bridge] #[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_utfstr(&escape(arg.as_ref()));
} }
trace_text.push('\n'); 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]) { pub fn trace_if_enabled_ffi<S: AsRef<wstr>>(parser: &Parser, command: &wstr, args: &[S]) {