From d10a06f3d8e0ae08d1adbbc4ca25106c2fc433ab Mon Sep 17 00:00:00 2001 From: truenagual Date: Mon, 4 Sep 2017 23:00:14 +0200 Subject: [PATCH] Crate renamed to dlopen --- Cargo.toml | 8 ++++---- README.md | 12 ++++++------ examples/README.md | 4 ++-- examples/commons/mod.rs | 4 ++-- examples/raw.rs | 4 ++-- examples/symbor.rs | 6 +++--- examples/symbor_api.rs | 8 ++++---- examples/wrapper_api.rs | 8 ++++---- examples/wrapper_multi_api.rs | 8 ++++---- .../Cargo.toml | 4 ++-- .../src/api.rs | 4 ++-- .../src/common.rs | 2 +- .../src/lib.rs | 4 ++-- .../src/multi_api.rs | 6 +++--- .../src/wrapper.rs | 6 +++--- src/raw/common.rs | 10 +++++----- src/raw/mod.rs | 4 ++-- src/symbor/api.rs | 10 +++++----- src/symbor/container.rs | 6 +++--- src/symbor/library.rs | 4 ++-- src/symbor/mod.rs | 14 +++++++------- src/wrapper/api.rs | 18 +++++++++--------- src/wrapper/container.rs | 8 ++++---- src/wrapper/mod.rs | 18 +++++++++--------- src/wrapper/multi_api.rs | 6 +++--- src/wrapper/optional.rs | 10 +++++----- tests/commons/mod.rs | 4 ++-- tests/raw.rs | 6 +++--- tests/symbor.rs | 6 +++--- tests/symbor_api.rs | 10 +++++----- tests/wrapper_api.rs | 10 +++++----- 31 files changed, 116 insertions(+), 116 deletions(-) rename {rust-dynlib-derive => rust-dlopen-derive}/Cargo.toml (71%) rename {rust-dynlib-derive => rust-dlopen-derive}/src/api.rs (84%) rename {rust-dynlib-derive => rust-dlopen-derive}/src/common.rs (97%) rename {rust-dynlib-derive => rust-dlopen-derive}/src/lib.rs (92%) rename {rust-dynlib-derive => rust-dlopen-derive}/src/multi_api.rs (77%) rename {rust-dynlib-derive => rust-dlopen-derive}/src/wrapper.rs (96%) diff --git a/Cargo.toml b/Cargo.toml index 43f433a..0ba25b3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "dynlib" +name = "dlopen" version = "0.1.0" authors = ["Szymon Wieloch "] description = "A library for opening and operating on dynamically loadable libraries." @@ -7,10 +7,10 @@ keywords = [ #common functions "dlopen", "dll", "so", "dylib", "shared"] license = "MIT" -repository = "https://github.com/szymonwieloch/rust-dynlib" +repository = "https://github.com/szymonwieloch/rust-dlopen" -[dependencies.dynlib_derive] -path = "rust-dynlib-derive" +[dependencies.dlopen_derive] +path = "rust-dlopen-derive" version = "0.1.0" [target.'cfg(windows)'.dependencies] diff --git a/README.md b/README.md index 10411b3..02f7127 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# rust-dynlib +# rust-dlopen [![Travis CI][tcii]][tci] [![Appveyor CI][acii]][aci] -[tcii]: https://travis-ci.org/szymonwieloch/rust-dynlib.svg?branch=master -[tci]: https://travis-ci.org/szymonwieloch/rust-dynlib -[acii]: https://ci.appveyor.com/api/projects/status/github/szymonwieloch/rust-dynlib?svg=true -[aci]: https://ci.appveyor.com/project/szymonwieloch/rust-dynlib +[tcii]: https://travis-ci.org/szymonwieloch/rust-dlopen.svg?branch=master +[tci]: https://travis-ci.org/szymonwieloch/rust-dlopen +[acii]: https://ci.appveyor.com/api/projects/status/github/szymonwieloch/rust-dlopen?svg=true +[aci]: https://ci.appveyor.com/project/szymonwieloch/rust-dlopen A long time ago in a dirty basement far, far away a programmer was trying to dynamically load a library using standard C API (because he didnt know Rust yet): @@ -63,7 +63,7 @@ loading libraries requires transmutation of obtained pointers). Cargo.toml: ```toml [dependencies] -dynlib = "0.1" +dlopen = "0.1" ``` # License This code is licensed under [MIT](./LICENSE) license. diff --git a/examples/README.md b/examples/README.md index dd3254a..3600d03 100644 --- a/examples/README.md +++ b/examples/README.md @@ -1,4 +1,4 @@ -#rust-dynlib examples +#rust-dlopen examples Files in directory perform very similar operations but they use different APIs. You can compare these @@ -20,6 +20,6 @@ library gets unloaded. Please notice that this bug is related to building dynamic link libraries (in this case the example library), not to loading libraries. - If you userust-dynlib for working with correctly built + If you userust-dlopen for working with correctly built dynamic link libraries, everything should work normally. \ No newline at end of file diff --git a/examples/commons/mod.rs b/examples/commons/mod.rs index bb6f358..80bd78a 100644 --- a/examples/commons/mod.rs +++ b/examples/commons/mod.rs @@ -1,7 +1,7 @@ extern crate libc; -extern crate dynlib; +extern crate dlopen; extern crate regex; -use dynlib::utils::{PLATFORM_FILE_EXTENSION, PLATFORM_FILE_PREFIX}; +use dlopen::utils::{PLATFORM_FILE_EXTENSION, PLATFORM_FILE_PREFIX}; use std::env; use std::path::{PathBuf}; use libc::{c_int}; diff --git a/examples/raw.rs b/examples/raw.rs index 6055dd3..5c41412 100644 --- a/examples/raw.rs +++ b/examples/raw.rs @@ -1,4 +1,4 @@ -extern crate dynlib; +extern crate dlopen; extern crate libc; #[macro_use] extern crate const_cstr; @@ -6,7 +6,7 @@ extern crate const_cstr; mod commons; use commons::{SomeData, example_lib_path}; -use dynlib::raw::{Library}; +use dlopen::raw::{Library}; use libc::{c_int, c_char}; use std::ffi::CStr; diff --git a/examples/symbor.rs b/examples/symbor.rs index f490cbe..2f21503 100644 --- a/examples/symbor.rs +++ b/examples/symbor.rs @@ -1,4 +1,4 @@ -extern crate dynlib; +extern crate dlopen; extern crate libc; #[macro_use] extern crate const_cstr; @@ -6,8 +6,8 @@ extern crate const_cstr; mod commons; use commons::{SomeData, example_lib_path}; -use dynlib::symbor::{Library}; -use dynlib::utils::platform_file_name; +use dlopen::symbor::{Library}; +use dlopen::utils::platform_file_name; use libc::{c_char, c_int}; use std::ffi::CStr; diff --git a/examples/symbor_api.rs b/examples/symbor_api.rs index 027b279..fcf648e 100644 --- a/examples/symbor_api.rs +++ b/examples/symbor_api.rs @@ -1,14 +1,14 @@ #[macro_use] -extern crate dynlib_derive; +extern crate dlopen_derive; #[macro_use] -extern crate dynlib; +extern crate dlopen; extern crate libc; #[macro_use] extern crate const_cstr; mod commons; use commons::{SomeData, example_lib_path}; -use dynlib::symbor::{Library, PtrOrNull, PtrOrNullMut, Ref, RefMut, Symbol, SymBorApi}; +use dlopen::symbor::{Library, PtrOrNull, PtrOrNullMut, Ref, RefMut, Symbol, SymBorApi}; use libc::{c_char, c_int}; use std::ffi::CStr; @@ -21,7 +21,7 @@ struct Api<'a> { pub c_fun_add_two: Symbol<'a, unsafe extern "C" fn(c_int) -> c_int>, pub rust_i32: Ref<'a, i32>, pub rust_i32_mut: RefMut<'a, i32>, - #[dynlib_name="rust_i32_mut"] + #[dlopen_name="rust_i32_mut"] pub rust_i32_ptr: Symbol<'a, * const i32>, pub c_int: Ref<'a, c_int>, pub c_struct: Ref<'a, SomeData>, diff --git a/examples/wrapper_api.rs b/examples/wrapper_api.rs index 4f479a8..fee22bf 100644 --- a/examples/wrapper_api.rs +++ b/examples/wrapper_api.rs @@ -1,10 +1,10 @@ -extern crate dynlib; +extern crate dlopen; #[macro_use] -extern crate dynlib_derive; +extern crate dlopen_derive; extern crate libc; #[macro_use] extern crate const_cstr; -use dynlib::wrapper::{Container, WrapperApi}; +use dlopen::wrapper::{Container, WrapperApi}; use libc::{c_int, c_char}; use std::ffi::CStr; @@ -20,7 +20,7 @@ struct Api<'a> { c_fun_add_two: unsafe extern "C" fn(arg: c_int) -> c_int, rust_i32: &'a i32, rust_i32_mut: &'a mut i32, - #[dynlib_name="rust_i32_mut"] + #[dlopen_name="rust_i32_mut"] rust_i32_ptr: * const i32, c_int: &'a c_int, c_struct: &'a SomeData, diff --git a/examples/wrapper_multi_api.rs b/examples/wrapper_multi_api.rs index 53c4911..7dee9d6 100644 --- a/examples/wrapper_multi_api.rs +++ b/examples/wrapper_multi_api.rs @@ -1,12 +1,12 @@ #[macro_use] -extern crate dynlib_derive; -extern crate dynlib; +extern crate dlopen_derive; +extern crate dlopen; extern crate libc; mod commons; use commons::{example_lib_path, SomeData}; use libc::{c_double, c_char, c_int}; -use dynlib::wrapper::{Container, WrapperApi, WrapperMultiApi}; -use dynlib::utils::platform_file_name; +use dlopen::wrapper::{Container, WrapperApi, WrapperMultiApi}; +use dlopen::utils::platform_file_name; use std::ffi::CStr; diff --git a/rust-dynlib-derive/Cargo.toml b/rust-dlopen-derive/Cargo.toml similarity index 71% rename from rust-dynlib-derive/Cargo.toml rename to rust-dlopen-derive/Cargo.toml index 217ff92..fffcaa8 100644 --- a/rust-dynlib-derive/Cargo.toml +++ b/rust-dlopen-derive/Cargo.toml @@ -1,8 +1,8 @@ [package] -name = "dynlib_derive" +name = "dlopen_derive" version = "0.1.0" authors = ["Szymon Wieloch "] -description = "Derive macros for the dynlib crate." +description = "Derive macros for the dlopen crate." license = "MIT" [lib] diff --git a/rust-dynlib-derive/src/api.rs b/rust-dlopen-derive/src/api.rs similarity index 84% rename from rust-dynlib-derive/src/api.rs rename to rust-dlopen-derive/src/api.rs index 3ab596c..6df5995 100644 --- a/rust-dynlib-derive/src/api.rs +++ b/rust-dlopen-derive/src/api.rs @@ -9,7 +9,7 @@ pub fn impl_library_api(ast: &DeriveInput) -> quote::Tokens { let tok_iter = fields.iter().map(field_to_tokens); let q = quote! { impl<'a> SymBorApi<'a> for #name<'a> { - unsafe fn load(lib: &'a ::dynlib::symbor::Library) -> Result<#name<'a>,::dynlib::Error> { + unsafe fn load(lib: &'a ::dlopen::symbor::Library) -> Result<#name<'a>,::dlopen::Error> { Ok(#name { #(#tok_iter),* }) @@ -33,7 +33,7 @@ fn field_to_tokens(field: &Field) -> quote::Tokens { let raw_result = lib.ptr_or_null_cstr::<()>( ::std::ffi::CStr::from_bytes_with_nul_unchecked(concat!(#symbol_name, "\0").as_bytes()) ); - dynlib::symbor::FromRawResult::from_raw_result(raw_result)? + dlopen::symbor::FromRawResult::from_raw_result(raw_result)? } } diff --git a/rust-dynlib-derive/src/common.rs b/rust-dlopen-derive/src/common.rs similarity index 97% rename from rust-dynlib-derive/src/common.rs rename to rust-dlopen-derive/src/common.rs index 097e013..310677b 100644 --- a/rust-dynlib-derive/src/common.rs +++ b/rust-dlopen-derive/src/common.rs @@ -1,7 +1,7 @@ use syn::{Field, DeriveInput, Body, VariantData, Lit, MetaItem}; pub fn symbol_name(field: &Field) -> &str { - match find_str_attr_val(field, "dynlib_name") { + match find_str_attr_val(field, "dlopen_name") { Some(val) => val, None => //not found, so use field name match field.ident { diff --git a/rust-dynlib-derive/src/lib.rs b/rust-dlopen-derive/src/lib.rs similarity index 92% rename from rust-dynlib-derive/src/lib.rs rename to rust-dlopen-derive/src/lib.rs index 8667da7..54e0659 100644 --- a/rust-dynlib-derive/src/lib.rs +++ b/rust-dlopen-derive/src/lib.rs @@ -17,7 +17,7 @@ use api::impl_library_api; use wrapper::impl_wrapper_api; use multi_api::impl_wrapper_multi_api; -#[proc_macro_derive(WrapperApi, attributes(dynlib_name, dynlib_allow_null))] +#[proc_macro_derive(WrapperApi, attributes(dlopen_name, dlopen_allow_null))] pub fn wrapper_api(input: TokenStream) -> TokenStream { // Construct a string representation of the type definition let s = input.to_string(); @@ -47,7 +47,7 @@ pub fn wrapper_multi_api(input: TokenStream) -> TokenStream { gen.parse().unwrap() } -#[proc_macro_derive(SymBorApi, attributes(dynlib_name))] +#[proc_macro_derive(SymBorApi, attributes(dlopen_name))] pub fn library_api(input: TokenStream) -> TokenStream { // Construct a string representation of the type definition let s = input.to_string(); diff --git a/rust-dynlib-derive/src/multi_api.rs b/rust-dlopen-derive/src/multi_api.rs similarity index 77% rename from rust-dynlib-derive/src/multi_api.rs rename to rust-dlopen-derive/src/multi_api.rs index 8d05414..090f779 100644 --- a/rust-dynlib-derive/src/multi_api.rs +++ b/rust-dlopen-derive/src/multi_api.rs @@ -13,8 +13,8 @@ pub fn impl_wrapper_multi_api(ast: &DeriveInput) -> quote::Tokens { let q = quote! { impl #generics WrapperMultiApi for #name #generics{} - impl #generics ::dynlib::wrapper::WrapperApi for # name #generics{ - unsafe fn load(lib: & ::dynlib::raw::Library) -> Result { + impl #generics ::dlopen::wrapper::WrapperApi for # name #generics{ + unsafe fn load(lib: & ::dlopen::raw::Library) -> Result { Ok(#name { #(#tok_iter),* }) @@ -34,7 +34,7 @@ fn field_to_tokens(field: &Field) -> quote::Tokens { //panic!("type_name = {}, {:?}", field_type_name, field); quote! { - #field_name: ::dynlib::wrapper::WrapperApi::load(&lib)? + #field_name: ::dlopen::wrapper::WrapperApi::load(&lib)? } } \ No newline at end of file diff --git a/rust-dynlib-derive/src/wrapper.rs b/rust-dlopen-derive/src/wrapper.rs similarity index 96% rename from rust-dynlib-derive/src/wrapper.rs rename to rust-dlopen-derive/src/wrapper.rs index 3e67f2d..f7e7e8a 100644 --- a/rust-dynlib-derive/src/wrapper.rs +++ b/rust-dlopen-derive/src/wrapper.rs @@ -2,7 +2,7 @@ use syn::{Field, Ty, DeriveInput, Visibility, BareFnArg, FunctionRetTy, MutTy, M use quote; use super::common::{get_fields, symbol_name, has_marker_attr}; -const ALLOW_NULL: &str = "dynlib_allow_null"; +const ALLOW_NULL: &str = "dlopen_allow_null"; const TRAIT_NAME: &str = "WrapperApi"; pub fn impl_wrapper_api(ast: &DeriveInput) -> quote::Tokens { @@ -24,7 +24,7 @@ pub fn impl_wrapper_api(ast: &DeriveInput) -> quote::Tokens { let wrapper_iter = fields.iter().filter_map(field_to_wrapper); let q = quote! { impl #generics WrapperApi for #struct_name #generics { - unsafe fn load(lib: & ::dynlib::raw::Library ) -> Result { + unsafe fn load(lib: & ::dlopen::raw::Library ) -> Result { Ok(Self{ #(#field_iter),* }) @@ -83,7 +83,7 @@ fn allow_null_field(field: &Field, ptr: &Box) -> quote::Tokens { ) { Ok(val) => val, Err(err) => match err { - ::dynlib::Error::NullSymbol => ::std::ptr:: #null_fun (), + ::dlopen::Error::NullSymbol => ::std::ptr:: #null_fun (), _ => return Err(err) } } diff --git a/src/raw/common.rs b/src/raw/common.rs index 8684631..2432310 100644 --- a/src/raw/common.rs +++ b/src/raw/common.rs @@ -42,8 +42,8 @@ impl Library { #Example ```no_run - extern crate dynlib; - use dynlib::raw::Library; + extern crate dlopen; + use dlopen::raw::Library; fn main() { //use full path @@ -76,9 +76,9 @@ impl Library { #Example ```no_run - extern crate dynlib; - use dynlib::raw::Library; - use dynlib::Error; + extern crate dlopen; + use dlopen::raw::Library; + use dlopen::Error; use std::ptr::null; fn main(){ let lib = Library::open("libyourlib.so").unwrap(); diff --git a/src/raw/mod.rs b/src/raw/mod.rs index 5c4b7cf..c12647c 100644 --- a/src/raw/mod.rs +++ b/src/raw/mod.rs @@ -9,8 +9,8 @@ approach to loading dynamic link libraries. # Example ```no_run -extern crate dynlib; -use dynlib::raw::Library; +extern crate dlopen; +use dlopen::raw::Library; fn main(){ let lib = Library::open("libexample.so").unwrap(); let fun_add_one: unsafe extern "C" fn(i32)->i32 = unsafe{lib.symbol("add_one")}.unwrap(); diff --git a/src/symbor/api.rs b/src/symbor/api.rs index fb6ddab..8a497be 100644 --- a/src/symbor/api.rs +++ b/src/symbor/api.rs @@ -10,10 +10,10 @@ generated `load(&Library)` function to load all symbols from previously opened l ```no_run #[macro_use] -extern crate dynlib_derive; -extern crate dynlib; +extern crate dlopen_derive; +extern crate dlopen; extern crate libc; -use dynlib::symbor::{Library, Symbol, SymBorApi, PtrOrNull, RefMut, PtrOrNullMut}; +use dlopen::symbor::{Library, Symbol, SymBorApi, PtrOrNull, RefMut, PtrOrNullMut}; use libc::{c_double, c_char}; #[derive(SymBorApi)] @@ -23,7 +23,7 @@ struct Example<'a> { pub optional_fun: Option>, pub nullable_ptr: PtrOrNullMut<'a, c_char>, pub mut_ref_i32: Symbol<'a, &'a mut i32>, - #[dynlib_name="mut_ref_i32"] + #[dlopen_name="mut_ref_i32"] pub the_same_mut_ref_i32: RefMut<'a, i32>, pub not_nullable_ptr: Symbol<'a, * mut c_double> } @@ -51,7 +51,7 @@ fn main(){ Please notice several supported features: * By default `SymBorApi` uses the field name to obtain a symbol from the library. - You can override the symbol name using the `dynlib_name` attribute. + You can override the symbol name using the `dlopen_name` attribute. * All kind of objects from the `symbor` module implement the Deref or DerefMut trait. This means that you can use them as if you would use primitive types that they wrap. * You can obtain optional symbols. This is very useful when you are dealing with diff --git a/src/symbor/container.rs b/src/symbor/container.rs index 00ca2fd..c98a318 100644 --- a/src/symbor/container.rs +++ b/src/symbor/container.rs @@ -17,9 +17,9 @@ This structure allows you to do it. ```no_run #[macro_use] -extern crate dynlib_derive; -extern crate dynlib; -use dynlib::symbor::{Library, Symbol, Ref, PtrOrNull, SymBorApi, Container}; +extern crate dlopen_derive; +extern crate dlopen; +use dlopen::symbor::{Library, Symbol, Ref, PtrOrNull, SymBorApi, Container}; #[derive(SymBorApi)] struct ExampleApi<'a> { diff --git a/src/symbor/library.rs b/src/symbor/library.rs index b384a3d..8cb9225 100644 --- a/src/symbor/library.rs +++ b/src/symbor/library.rs @@ -26,8 +26,8 @@ dangling symbols is prevented. #Example ```no_run -extern crate dynlib; -use dynlib::symbor::Library; +extern crate dlopen; +use dlopen::symbor::Library; fn main(){ let lib = Library::open("libexample.dylib").unwrap(); diff --git a/src/symbor/mod.rs b/src/symbor/mod.rs index 7d6e5da..8da6744 100644 --- a/src/symbor/mod.rs +++ b/src/symbor/mod.rs @@ -7,8 +7,8 @@ that take place when the library gets closed but the symbols still exist and are #Example of a dangling symbol prevention ```no_run -extern crate dynlib; -use dynlib::symbor::Library; +extern crate dlopen; +use dlopen::symbor::Library; fn main(){ let lib = Library::open("libexample.dylib").unwrap(); let fun = unsafe{lib.symbol::f64>("some_symbol_name")}.unwrap(); @@ -28,9 +28,9 @@ This is especially handy if you have a huge API with multiple symbols: ```no_run #[macro_use] -extern crate dynlib_derive; -extern crate dynlib; -use dynlib::symbor::{Library, Symbol, Ref, PtrOrNull, SymBorApi}; +extern crate dlopen_derive; +extern crate dlopen; +use dlopen::symbor::{Library, Symbol, Ref, PtrOrNull, SymBorApi}; #[derive(SymBorApi)] struct ExampleApi<'a> { @@ -69,8 +69,8 @@ However it is possible to make a mistake if you dereference safe wrappers into r #Example of a mistake - dangling symbol ```no_run -extern crate dynlib; -use dynlib::symbor::Library; +extern crate dlopen; +use dlopen::symbor::Library; fn main(){ let raw_fun = { let lib = Library::open("libexample.dylib").unwrap(); diff --git a/src/wrapper/api.rs b/src/wrapper/api.rs index e78f3a7..8cb0288 100644 --- a/src/wrapper/api.rs +++ b/src/wrapper/api.rs @@ -5,7 +5,7 @@ use super::super::raw::Library; Trait for defining library API. This trait is intended to be used with `#[derive(WrapperApi)]` macro defined in the -`dynlib_derive` crate. It forces several restrictions on types that implement it: +`dlopen_derive` crate. It forces several restrictions on types that implement it: * Only structures can implement this trait. * All fields need to be private. @@ -32,21 +32,21 @@ Wrappers are not generated only for: ```no_run #[macro_use] -extern crate dynlib_derive; -extern crate dynlib; +extern crate dlopen_derive; +extern crate dlopen; extern crate libc; -use dynlib::wrapper::{WrapperApi, Container}; +use dlopen::wrapper::{WrapperApi, Container}; use libc::{c_char}; use std::ffi::CStr; #[derive(WrapperApi)] struct Example<'a> { - #[dynlib_name="function"] + #[dlopen_name="function"] do_something: extern "C" fn(), add_one: unsafe extern "C" fn (arg: i32) -> i32, global_count: &'a mut u32, c_string: * const c_char, - #[dynlib_allow_null] + #[dlopen_allow_null] maybe_null_ptr: * const (), } @@ -58,7 +58,7 @@ impl<'a> Example<'a> { } fn main () { - let mut cont: Container = unsafe { Container::load("libexample.dynlib")}.unwrap(); + let mut cont: Container = unsafe { Container::load("libexample.dylib")}.unwrap(); cont.do_something(); let _result = unsafe { cont.add_one(5) }; *cont.global_count_mut() += 1; @@ -70,12 +70,12 @@ fn main () { a standalone object. API and library handle need to be kept together to prevent dangling symbols. **Note:** By default obtained symbol name is the field name. You can change this by -assigning the "dynlib_name" attribute to the given field. +assigning the "dlopen_name" attribute to the given field. **Note:** By default `Error::NullSymbol` is returned if the loaded symbol name has a null value. While null is a valid value of a exported symbol, it is usually not expected by users of libraries. If in your scenario null is an acceptable value, you should assign -"dynlib_allow_null" attribute to the given field. Of course this makes sense only if the field +"dlopen_allow_null" attribute to the given field. Of course this makes sense only if the field is of pointer type. */ pub trait WrapperApi where Self: Sized { diff --git a/src/wrapper/container.rs b/src/wrapper/container.rs index d98b37f..37a3cec 100644 --- a/src/wrapper/container.rs +++ b/src/wrapper/container.rs @@ -15,10 +15,10 @@ easy to use `Container` inside structures. ```no_run #[macro_use] -extern crate dynlib_derive; -extern crate dynlib; +extern crate dlopen_derive; +extern crate dlopen; extern crate libc; -use dynlib::wrapper::{Container, WrapperApi}; +use dlopen::wrapper::{Container, WrapperApi}; use libc::{c_char}; use std::ffi::CStr; @@ -38,7 +38,7 @@ impl<'a> Example<'a> { } fn main () { - let mut container: Container = unsafe { Container::load("libexample.dynlib")}.unwrap(); + let mut container: Container = unsafe { Container::load("libexample.dylib")}.unwrap(); container.do_something(); let _result = unsafe { container.add_one(5) }; *container.global_count_mut() += 1; diff --git a/src/wrapper/mod.rs b/src/wrapper/mod.rs index ff4de41..8390cea 100644 --- a/src/wrapper/mod.rs +++ b/src/wrapper/mod.rs @@ -12,9 +12,9 @@ symbols get released at the same time. ```no_run #[macro_use] -extern crate dynlib_derive; -extern crate dynlib; -use dynlib::wrapper::{Container, WrapperApi}; +extern crate dlopen_derive; +extern crate dlopen; +use dlopen::wrapper::{Container, WrapperApi}; #[derive(WrapperApi)] struct Example<'a> { @@ -24,7 +24,7 @@ struct Example<'a> { } fn main () { -let mut container: Container = unsafe { Container::load("libexample.dynlib")}.unwrap(); +let mut container: Container = unsafe { Container::load("libexample.dylib")}.unwrap(); container.do_something(); let _result = unsafe { container.add_one(5) }; *container.global_count_mut() += 1; @@ -43,10 +43,10 @@ However it is possible to make a mistake if you create API as a standalone objec ```no_run #[macro_use] -extern crate dynlib_derive; -extern crate dynlib; -use dynlib::wrapper::{Container, WrapperApi}; -use dynlib::raw::Library; +extern crate dlopen_derive; +extern crate dlopen; +use dlopen::wrapper::{Container, WrapperApi}; +use dlopen::raw::Library; #[derive(WrapperApi)] struct Example<'a> { @@ -56,7 +56,7 @@ struct Example<'a> { } fn main () { -let lib = Library::open("libexample.dynlib").unwrap(); +let lib = Library::open("libexample.dylib").unwrap(); let mut api = unsafe{Example::load(&lib)}; drop(lib); diff --git a/src/wrapper/multi_api.rs b/src/wrapper/multi_api.rs index 40716b2..39d66eb 100644 --- a/src/wrapper/multi_api.rs +++ b/src/wrapper/multi_api.rs @@ -17,9 +17,9 @@ a standalone object. API and library handle need to be kept together to prevent ```no_run #[macro_use] -extern crate dynlib_derive; -extern crate dynlib; -use dynlib::wrapper::{Container, WrapperApi, WrapperMultiApi}; +extern crate dlopen_derive; +extern crate dlopen; +use dlopen::wrapper::{Container, WrapperApi, WrapperMultiApi}; //Define 3 APIs: diff --git a/src/wrapper/optional.rs b/src/wrapper/optional.rs index cdef24f..3406dff 100644 --- a/src/wrapper/optional.rs +++ b/src/wrapper/optional.rs @@ -16,9 +16,9 @@ library, the optional API gets loaded. Otherwise the `optional()` method will re ```no_run #[macro_use] -extern crate dynlib_derive; -extern crate dynlib; -use dynlib::wrapper::{OptionalContainer, WrapperApi}; +extern crate dlopen_derive; +extern crate dlopen; +use dlopen::wrapper::{OptionalContainer, WrapperApi}; #[derive(WrapperApi)] struct Obligatory<'a> { @@ -33,7 +33,7 @@ struct Optional{ } fn main () { - let mut container: OptionalContainer = unsafe { OptionalContainer::load("libexample.dynlib")}.unwrap(); + let mut container: OptionalContainer = unsafe { OptionalContainer::load("libexample.dylib")}.unwrap(); container.do_something(); *container.global_count_mut() += 1; @@ -51,7 +51,7 @@ fn main () { [`WrapperMultiApi`](./trait.WrapperMultiApi.html). */ pub struct OptionalContainer where Api: WrapperApi, Optional: WrapperApi { - #[allow(dead_code)] //this is not dead code because destructor of DynLib deallocates the library + #[allow(dead_code)] //this is not dead code because destructor of Library deallocates the library lib: Library, api: Api, optional: Option diff --git a/tests/commons/mod.rs b/tests/commons/mod.rs index bb6f358..80bd78a 100644 --- a/tests/commons/mod.rs +++ b/tests/commons/mod.rs @@ -1,7 +1,7 @@ extern crate libc; -extern crate dynlib; +extern crate dlopen; extern crate regex; -use dynlib::utils::{PLATFORM_FILE_EXTENSION, PLATFORM_FILE_PREFIX}; +use dlopen::utils::{PLATFORM_FILE_EXTENSION, PLATFORM_FILE_PREFIX}; use std::env; use std::path::{PathBuf}; use libc::{c_int}; diff --git a/tests/raw.rs b/tests/raw.rs index 56b9404..a19f478 100644 --- a/tests/raw.rs +++ b/tests/raw.rs @@ -1,8 +1,8 @@ -extern crate dynlib; +extern crate dlopen; extern crate libc; #[macro_use] extern crate const_cstr; -use dynlib::raw::Library; +use dlopen::raw::Library; use libc::{c_int, c_char}; use std::ffi::CStr; @@ -49,7 +49,7 @@ fn open_play_close_raw(){ //It turns out that there is a bug in rust. //On OSX calls to dynamic libraries written in Rust causes segmentation fault - //please note that this ia a problem with the example library, not with dynlib + //please note that this ia a problem with the example library, not with dlopen //https://github.com/rust-lang/rust/issues/28794 #[cfg(any(target_os="macos", target_os="ios"))] ::std::mem::forget(lib); diff --git a/tests/symbor.rs b/tests/symbor.rs index bd25bf5..8fdfef2 100644 --- a/tests/symbor.rs +++ b/tests/symbor.rs @@ -1,8 +1,8 @@ -extern crate dynlib; +extern crate dlopen; extern crate libc; #[macro_use] extern crate const_cstr; -use dynlib::symbor::Library; +use dlopen::symbor::Library; use libc::{c_int, c_char}; use std::ffi::CStr; @@ -12,7 +12,7 @@ use commons::{example_lib_path, SomeData}; //It turns out that there is a bug in rust. //On OSX calls to dynamic libraries written in Rust causes segmentation fault -//please note that this ia a problem with the example library, not with dynlib +//please note that this ia a problem with the example library, not with dlopen //https://github.com/rust-lang/rust/issues/28794 #[cfg(not(any(target_os="macos", target_os="ios")))] #[test] diff --git a/tests/symbor_api.rs b/tests/symbor_api.rs index 3f8f2f6..c8d2360 100644 --- a/tests/symbor_api.rs +++ b/tests/symbor_api.rs @@ -1,10 +1,10 @@ -extern crate dynlib; +extern crate dlopen; #[macro_use] -extern crate dynlib_derive; +extern crate dlopen_derive; extern crate libc; #[macro_use] extern crate const_cstr; -use dynlib::symbor::{Library, SymBorApi, Symbol, RefMut, Ref, PtrOrNull}; +use dlopen::symbor::{Library, SymBorApi, Symbol, RefMut, Ref, PtrOrNull}; use libc::{c_int, c_char}; use std::ffi::CStr; @@ -20,7 +20,7 @@ struct Api<'a> { pub c_fun_add_two: Symbol<'a, unsafe extern "C" fn(c_int) -> c_int>, pub rust_i32: Ref<'a, i32>, pub rust_i32_mut: RefMut<'a, i32>, - #[dynlib_name="rust_i32_mut"] + #[dlopen_name="rust_i32_mut"] pub rust_i32_ptr: Symbol<'a, * const i32>, pub c_int: Ref<'a, c_int>, pub c_struct: Ref<'a, SomeData>, @@ -30,7 +30,7 @@ struct Api<'a> { //It turns out that there is a bug in rust. //On OSX calls to dynamic libraries written in Rust causes segmentation fault -//please note that this ia a problem with the example library, not with dynlib +//please note that this ia a problem with the example library, not with dlopen //https://github.com/rust-lang/rust/issues/28794 #[cfg(not(any(target_os="macos", target_os="ios")))] #[test] diff --git a/tests/wrapper_api.rs b/tests/wrapper_api.rs index 3846e53..091c4a2 100644 --- a/tests/wrapper_api.rs +++ b/tests/wrapper_api.rs @@ -1,10 +1,10 @@ -extern crate dynlib; +extern crate dlopen; #[macro_use] -extern crate dynlib_derive; +extern crate dlopen_derive; extern crate libc; #[macro_use] extern crate const_cstr; -use dynlib::wrapper::{Container, WrapperApi}; +use dlopen::wrapper::{Container, WrapperApi}; use libc::{c_int, c_char}; use std::ffi::CStr; @@ -20,7 +20,7 @@ struct Api<'a> { c_fun_add_two: unsafe extern "C" fn(arg: c_int) -> c_int, rust_i32: &'a i32, rust_i32_mut: &'a mut i32, - #[dynlib_name="rust_i32_mut"] + #[dlopen_name="rust_i32_mut"] rust_i32_ptr: * const i32, c_int: &'a c_int, c_struct: &'a SomeData, @@ -39,7 +39,7 @@ impl<'a> Api<'a> { //It turns out that there is a bug in rust. //On OSX calls to dynamic libraries written in Rust causes segmentation fault -//please note that this ia a problem with the example library, not with dynlib +//please note that this ia a problem with the example library, not with dlopen //https://github.com/rust-lang/rust/issues/28794 #[cfg(not(any(target_os="macos", target_os="ios")))] #[test]