Skip to content

Commit

Permalink
v0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yvan-sraka committed Dec 6, 2023
1 parent 755ff02 commit e40e002
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 66 deletions.
102 changes: 60 additions & 42 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ license = "MIT OR Apache-2.0"
name = "hs-bindgen"
repository = "https://github.com/yvan-sraka/hs-bindgen"
rust-version = "1.64.0"
version = "0.8.0"
version = "0.9.0"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]

[dependencies]
hs-bindgen-attribute = { version = "0.8", default-features = false }
hs-bindgen-traits = { version = "0.8", default-features = false }
hs-bindgen-attribute = { version = "0.9", default-features = false }
hs-bindgen-traits = { version = "0.9", default-features = false }

[features]
default = ["std"]
full = ["antlion", "std"]
antlion = ["hs-bindgen-attribute/antlion"]
full = ["reflexive", "std"]
reflexive = ["hs-bindgen-attribute/reflexive"]
std = ["hs-bindgen-traits/std"]
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,19 @@ fn greetings(name: &str) {
extern "C" fn __c_greetings(__0: *const core::ffi::c_char) -> () {
// `traits` module is `hs-bindgen::hs-bindgen-traits`
// n.b. do not forget to import it, e.g., with `use hs-bindgen::*`
traits::ReprC::from(greetings(traits::ReprRust::from(__0),))
traits::FromReprC::from(greetings(traits::FromReprRust::from(__0),))
}
```

A more complete example, when we now try to pass a custom type to our
interface:

```rust
use hs_bindgen::{traits::ReprRust, *};
use hs_bindgen::{traits::FromReprRust, *};
use std::marker::PhantomData;

/// A custom Rust data-type, `#[repr(transparent)]` is not useful here
/// since `ReprRust` trait will offers the constructor we need to construct
/// since `FromReprRust` trait will offers the constructor we need to construct
/// our type out of a C-FFI safe primitive data-structure.
struct User<T: Kind> {
name: String,
Expand Down Expand Up @@ -86,10 +86,10 @@ expansion during compilation, and how rustc assign unmangled symbols to
monomorphised methods are AFAIK not a publicly specified behavior), but
this limitation didn’t apply to `hs-bindgen-traits` implementations! */

impl<T: Kind> ReprRust<*const i8> for User<T> {
impl<T: Kind> FromReprRust<*const i8> for User<T> {
fn from(ptr: *const i8) -> Self {
User::<T> {
name: <String as ReprRust<*const i8>>::from(ptr),
name: <String as FromReprRust<*const i8>>::from(ptr),
kind: PhantomData::<T>
}
}
Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@
//! extern "C" fn __c_greetings(__0: *const core::ffi::c_char) -> () {
//! // `traits` module is `hs-bindgen::hs-bindgen-traits`
//! // n.b. do not forget to import it, e.g., with `use hs-bindgen::*`
//! traits::ReprC::from(greetings(traits::ReprRust::from(__0),))
//! traits::FromReprC::from(greetings(traits::FromReprRust::from(__0),))
//! }
//! ```
//!
//! A more complete example, when we now try to pass a custom type to our
//! interface:
//!
//! ```rust
//! use hs_bindgen::{traits::ReprRust, *};
//! use hs_bindgen::{traits::FromReprRust, *};
//! use std::marker::PhantomData;
//!
//! /// A custom Rust data-type, `#[repr(transparent)]` is not useful here
//! /// since `ReprRust` trait will offers the constructor we need to construct
//! /// since `FromReprRust` trait will offers the constructor we need to construct
//! /// our type out of a C-FFI safe primitive data-structure.
//! struct User<T: Kind> {
//! name: String,
Expand Down Expand Up @@ -84,10 +84,10 @@
//! monomorphised methods are AFAIK not a publicly specified behavior), but
//! this limitation didn’t apply to `hs-bindgen-traits` implementations! */
//!
//! impl<T: Kind> ReprRust<*const i8> for User<T> {
//! impl<T: Kind> FromReprRust<*const i8> for User<T> {
//! fn from(ptr: *const i8) -> Self {
//! User::<T> {
//! name: <String as ReprRust<*const i8>>::from(ptr),
//! name: <String as FromReprRust<*const i8>>::from(ptr),
//! kind: PhantomData::<T>
//! }
//! }
Expand Down

0 comments on commit e40e002

Please sign in to comment.