Skip to content
Open

DNS #128

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,13 @@ pub fn generated_items_to_tokens(
__COMMENT__ "Generated due to CRUBIT_OWNED_POINTEE annotation."
#[repr(transparent)]
pub struct #owned_type_name(::core::ptr::NonNull<#ident>);

impl Drop for #owned_type_name {
fn drop(&mut self) {
__COMMENT__ "The DropImpl method must be implemented in a user-written .rs file that's included using additional_rust_srcs"
self.DropImpl();
}
}
}
});

Expand Down
6 changes: 6 additions & 0 deletions rs_bindings_from_cc/test/annotations/owned_ptr_rs_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ unsafe impl ::cxx::ExternType for RawThing {
// Generated due to CRUBIT_OWNED_POINTEE annotation.
#[repr(transparent)]
pub struct OwnedThing(::core::ptr::NonNull<RawThing>);
impl Drop for OwnedThing {
fn drop(&mut self) {
// The DropImpl method must be implemented in a user-written .rs file that's included using additional_rust_srcs
self.DropImpl();
}
}

/// Generated from: rs_bindings_from_cc/test/annotations/owned_ptr.h;l=18
impl From<i32> for RawThing {
Expand Down
4 changes: 2 additions & 2 deletions rs_bindings_from_cc/test/annotations/owned_ptr_rust_thing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

impl Drop for crate::OwnedThing {
fn drop(&mut self) {
impl crate::OwnedThing {
pub(crate) fn DropImpl(&mut self) {
unsafe {
crate::RawThing::Close(self.0.as_mut());
}
Expand Down