Skip to content

Commit

Permalink
Merge pull request #200 from getditto/dhm/virtual-ptr-option
Browse files Browse the repository at this point in the history
Allow `VirtualPtr` to be `Option`-wrapped
  • Loading branch information
danielhenrymantilla authored Jan 22, 2024
2 parents 36ae9f3 + 8184a78 commit cfd329c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ path = "src/_lib.rs"

[package]
name = "safer-ffi"
version = "0.1.4" # Keep in sync
version = "0.1.5" # Keep in sync
authors = [
"Daniel Henry-Mantilla <[email protected]>",
]
Expand Down Expand Up @@ -164,7 +164,7 @@ version = "0.0.3"

[dependencies.safer_ffi-proc_macros]
path = "src/proc_macro"
version = "=0.1.4" # Keep in sync
version = "=0.1.5" # Keep in sync

[workspace]
members = [
Expand Down
4 changes: 2 additions & 2 deletions ffi_tests/Cargo.lock

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

4 changes: 2 additions & 2 deletions js_tests/Cargo.lock

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

18 changes: 18 additions & 0 deletions src/dyn_traits/_mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ impl<DynTrait : ?Sized + DynClone> Clone for VirtualPtr<DynTrait> {

use hack::VirtualPtr_;
mod hack {
use ::safer_ffi::layout;

#[super::derive_ReprC]
#[repr(C)]
#[allow(missing_debug_implementations)]
Expand All @@ -123,6 +125,22 @@ mod hack {
pub(in super) ptr: Ptr,
pub(in super) vtable: VTable,
}

unsafe
impl<Ptr, VTable>
layout::__HasNiche__
for
VirtualPtr_<Ptr, VTable>
where
Ptr : layout::ConcreteReprC + layout::__HasNiche__,
VTable : layout::ConcreteReprC,
{
fn is_niche (it: &'_ <Self as super::ReprC>::CLayout)
-> bool
{
Ptr::is_niche(&it.ptr)
}
}
}

#[derive_ReprC]
Expand Down
2 changes: 1 addition & 1 deletion src/proc_macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ proc-macro = true

[package]
name = "safer_ffi-proc_macros"
version = "0.1.4" # Keep in sync
version = "0.1.5" # Keep in sync
authors = ["Daniel Henry-Mantilla <[email protected]>"]
edition = "2021"

Expand Down

0 comments on commit cfd329c

Please sign in to comment.