|
4 | 4 | //! crate's `build.rs` into a static library (`libWispAudioKit.a`). The C ABI |
5 | 5 | //! surface is hand-mirrored from `native/WispAudioKit/include/wisp_audiokit.h`. |
6 | 6 | //! |
7 | | -//! On non-macOS targets every binding is a stub returning a null pointer or |
8 | | -//! a non-zero error code so the workspace stays buildable. |
| 7 | +//! `WispAudioKit` is macOS-only, so the `extern "C"` block below is gated to |
| 8 | +//! `target_os = "macos"`. On other targets the crate exposes only the type |
| 9 | +//! aliases and constants — there are no function symbols to link against, |
| 10 | +//! and consumers must (and do) cfg-gate any code that touches them. |
9 | 11 |
|
10 | 12 | #![allow(unsafe_code, non_camel_case_types)] |
11 | 13 |
|
12 | | -use std::os::raw::{c_char, c_int, c_void}; |
| 14 | +#[cfg(target_os = "macos")] |
| 15 | +use std::os::raw::c_int; |
| 16 | +use std::os::raw::{c_char, c_void}; |
13 | 17 |
|
14 | 18 | /// Opaque handle for a `WispSession`. Construct via [`wisp_session_new`]. |
15 | 19 | #[repr(C)] |
@@ -71,74 +75,3 @@ unsafe extern "C" { |
71 | 75 | /// null. Invalidated by the next mutating call. |
72 | 76 | pub fn wisp_session_last_error_message(session: *mut WispSession) -> *const c_char; |
73 | 77 | } |
74 | | - |
75 | | -// ---- Non-macOS stubs ---------------------------------------------------- |
76 | | - |
77 | | -#[cfg(not(target_os = "macos"))] |
78 | | -mod stubs { |
79 | | - //! Non-macOS stubs. `WispAudioKit` is macOS-only, so on Linux / Windows |
80 | | - //! every entry point is a no-op returning null / `-1`. The functions are |
81 | | - //! marked `unsafe` only to keep their signatures interchangeable with |
82 | | - //! the real `extern "C"` declarations on macOS — they are trivially |
83 | | - //! safe to call. |
84 | | -
|
85 | | - use super::{WispLogCallback, WispResultCallback, WispSession, c_char, c_int, c_void}; |
86 | | - |
87 | | - /// Stub: always returns null on non-macOS. |
88 | | - /// |
89 | | - /// # Safety |
90 | | - /// Trivially safe; no pointers are dereferenced. |
91 | | - #[must_use] |
92 | | - pub unsafe fn wisp_audiokit_version() -> *const c_char { |
93 | | - core::ptr::null() |
94 | | - } |
95 | | - |
96 | | - /// Stub: always returns null on non-macOS. |
97 | | - /// |
98 | | - /// # Safety |
99 | | - /// Trivially safe; no pointers are dereferenced. |
100 | | - pub unsafe fn wisp_session_new( |
101 | | - _output_dir: *const c_char, |
102 | | - _locale: *const c_char, |
103 | | - _on_result: Option<WispResultCallback>, |
104 | | - _on_log: Option<WispLogCallback>, |
105 | | - _user_data: *mut c_void, |
106 | | - ) -> *mut WispSession { |
107 | | - core::ptr::null_mut() |
108 | | - } |
109 | | - |
110 | | - /// Stub: always returns `-1` on non-macOS. |
111 | | - /// |
112 | | - /// # Safety |
113 | | - /// Trivially safe; no pointers are dereferenced. |
114 | | - pub unsafe fn wisp_session_start(_session: *mut WispSession) -> c_int { |
115 | | - -1 |
116 | | - } |
117 | | - |
118 | | - /// Stub: no-op on non-macOS. |
119 | | - /// |
120 | | - /// # Safety |
121 | | - /// Trivially safe; no pointers are dereferenced. |
122 | | - pub unsafe fn wisp_session_stop(_session: *mut WispSession) {} |
123 | | - |
124 | | - /// Stub: no-op on non-macOS. |
125 | | - /// |
126 | | - /// # Safety |
127 | | - /// Trivially safe; no pointers are dereferenced. |
128 | | - pub unsafe fn wisp_session_free(_session: *mut WispSession) {} |
129 | | - |
130 | | - /// Stub: always returns null on non-macOS. |
131 | | - /// |
132 | | - /// # Safety |
133 | | - /// Trivially safe; no pointers are dereferenced. |
134 | | - #[must_use] |
135 | | - pub unsafe fn wisp_session_last_error_message(_session: *mut WispSession) -> *const c_char { |
136 | | - core::ptr::null() |
137 | | - } |
138 | | -} |
139 | | - |
140 | | -#[cfg(not(target_os = "macos"))] |
141 | | -pub use stubs::{ |
142 | | - wisp_audiokit_version, wisp_session_free, wisp_session_last_error_message, wisp_session_new, |
143 | | - wisp_session_start, wisp_session_stop, |
144 | | -}; |
0 commit comments