From cc2a4c12f7b01c4155208fab2ced6d914ec95620 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Thu, 13 Aug 2020 06:46:16 -0500 Subject: [PATCH] Rename ns_speech_synthesizer backend to appkit. --- src/backends/{ns_speech_synthesizer.rs => appkit.rs} | 10 +++++----- src/backends/mod.rs | 4 ++-- src/lib.rs | 8 +++----- 3 files changed, 10 insertions(+), 12 deletions(-) rename src/backends/{ns_speech_synthesizer.rs => appkit.rs} (96%) diff --git a/src/backends/ns_speech_synthesizer.rs b/src/backends/appkit.rs similarity index 96% rename from src/backends/ns_speech_synthesizer.rs rename to src/backends/appkit.rs index 339fb11..8f6a37b 100644 --- a/src/backends/ns_speech_synthesizer.rs +++ b/src/backends/appkit.rs @@ -9,9 +9,9 @@ use objc::*; use crate::{Backend, Error, Features}; -pub struct NSSpeechSynthesizerBackend(*mut Object, *mut Object); +pub struct AppKit(*mut Object, *mut Object); -impl NSSpeechSynthesizerBackend { +impl AppKit { pub fn new() -> Self { info!("Initializing NSSpeechSynthesizer backend"); unsafe { @@ -85,12 +85,12 @@ impl NSSpeechSynthesizerBackend { let strings: id = msg_send![class!(NSMutableArray), new]; delegate_obj.as_mut().unwrap().set_ivar("strings", strings); let _: Object = msg_send![obj, setDelegate: delegate_obj]; - NSSpeechSynthesizerBackend(obj, delegate_obj) + AppKit(obj, delegate_obj) } } } -impl Backend for NSSpeechSynthesizerBackend { +impl Backend for AppKit { fn supported_features(&self) -> Features { Features { stop: true, @@ -197,7 +197,7 @@ impl Backend for NSSpeechSynthesizerBackend { } } -impl Drop for NSSpeechSynthesizerBackend { +impl Drop for AppKit { fn drop(&mut self) { unsafe { let _: Object = msg_send![self.0, release]; diff --git a/src/backends/mod.rs b/src/backends/mod.rs index 15ffedf..792a9b4 100644 --- a/src/backends/mod.rs +++ b/src/backends/mod.rs @@ -11,7 +11,7 @@ pub(crate) mod winrt; mod web; #[cfg(target_os = "macos")] -mod ns_speech_synthesizer; +mod appkit; #[cfg(target_os = "linux")] pub use self::speech_dispatcher::*; @@ -23,4 +23,4 @@ pub use self::tolk::*; pub use self::web::*; #[cfg(target_os = "macos")] -pub use self::ns_speech_synthesizer::*; +pub use self::appkit::*; diff --git a/src/lib.rs b/src/lib.rs index c8c5096..44d49ae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,7 +24,7 @@ pub enum Backends { #[cfg(windows)] WinRT, #[cfg(target_os = "macos")] - NSSpeechSynthesizer, + AppKit, } pub struct Features { @@ -109,9 +109,7 @@ impl TTS { Ok(TTS(Box::new(tts))) } #[cfg(target_os = "macos")] - Backends::NSSpeechSynthesizer => { - Ok(TTS(Box::new(backends::NSSpeechSynthesizerBackend::new()))) - } + Backends::AppKit => Ok(TTS(Box::new(backends::AppKit::new()))), } } @@ -127,7 +125,7 @@ impl TTS { #[cfg(target_arch = "wasm32")] let tts = TTS::new(Backends::Web); #[cfg(target_os = "macos")] - let tts = TTS::new(Backends::NSSpeechSynthesizer); + let tts = TTS::new(Backends::AppKit); tts }