Lines Matching defs:library
17 pub fn $name(library: &mut super::SharedLibrary) {
18 let symbol = unsafe { library.library.get(stringify!($name).as_bytes()) }.ok();
19 library.functions.$name = match symbol {
46 /// The (minimum) version of a `libclang` shared library.
72 /// A dynamically loaded instance of the `libclang` library.
75 library: libloading::Library,
81 fn new(library: libloading::Library, path: PathBuf) -> Self {
82 Self { library, path, functions: Functions::default() }
85 /// Returns the path to this `libclang` shared library.
90 /// Returns the (minimum) version of this `libclang` shared library.
94 /// version of this shared library is more recent than that fully
100 if self.library.get::<unsafe extern fn()>($fn).is_ok() {
126 /// Returns whether a `libclang` shared library is loaded on this thread.
134 Some(library) => Some(f(&library)),
152 }).expect("a `libclang` shared library is not loaded on this thread");
168 /// Loads a `libclang` shared library and returns the library instance.
170 /// This function does not attempt to load any functions from the shared library. The caller
175 /// * a `libclang` shared library could not be found
176 /// * the `libclang` shared library could not be opened
187 let library = libloading::Library::new(&path).map_err(|e| {
189 "the `libclang` shared library at {} could not be opened: {}",
195 let mut library = SharedLibrary::new(library?, path);
196 $(load::$name(&mut library);)+
197 Ok(library)
201 /// Loads a `libclang` shared library for use in the current thread.
203 /// This functions attempts to load all the functions in the shared library. Whether a
210 /// * a `libclang` shared library could not be found
211 /// * the `libclang` shared library could not be opened
214 let library = Arc::new(load_manually()?);
215 LIBRARY.with(|l| *l.borrow_mut() = Some(library));
219 /// Unloads the `libclang` shared library in use in the current thread.
223 /// * a `libclang` shared library is not in use in the current thread
225 let library = set_library(None);
226 if library.is_some() {
229 Err("a `libclang` shared library is not in use in the current thread".into())
233 /// Returns the library instance stored in TLS.
235 /// This functions allows for sharing library instances between threads.
240 /// Sets the library instance stored in TLS and returns the previous library.
242 /// This functions allows for sharing library instances between threads.
243 pub fn set_library(library: Option<Arc<SharedLibrary>>) -> Option<Arc<SharedLibrary>> {
244 LIBRARY.with(|l| mem::replace(&mut *l.borrow_mut(), library))