Skip to content

No bindings are being generated for destructors #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dflemstr opened this issue Feb 18, 2017 · 4 comments
Closed

No bindings are being generated for destructors #529

dflemstr opened this issue Feb 18, 2017 · 4 comments

Comments

@dflemstr
Copy link

This is probably mentioned elsewhere since it is such an obvious thing but I couldn't find a tracking issue for it so I thought I would create one.

Input C/C++ Header

class Foo {
public:
    ~Foo();
};

Foo::~Foo() {
}

Bindgen Invokation

$ bindgen test.hpp

Actual Results

/* automatically generated by rust-bindgen */

#[repr(C)]
#[derive(Debug)]
pub struct Foo {
    pub _address: u8,
}
#[test]
fn bindgen_test_layout_Foo() {
    assert_eq!(::std::mem::size_of::<Foo>() , 1usize , concat ! (
               "Size of: " , stringify ! ( Foo ) ));
    assert_eq! (::std::mem::align_of::<Foo>() , 1usize , concat ! (
                "Alignment of " , stringify ! ( Foo ) ));
}

Expected Results

// ... as above ...

impl Drop for Foo {
    fn drop(&mut self) {
      // ... call mangled destructor
    }
}
@emilio
Copy link
Contributor

emilio commented Feb 19, 2017

Yup, that's known. It shouldn't be too hard. We already keep track of the constructors.

I'd rather not implement Drop in bindgen itself, because we can't do it for stuff with, let's say, inlined destructors, so it can be tricky to make it work reliably, and implementing drop you prevent doing other stuff like droping the outer structure via an FFI call or similar.

@emilio
Copy link
Contributor

emilio commented Feb 19, 2017

Anyway, I'm all-in in exposing destructors. Should be easy. I'm happy to do it when I have the time, but if someone wants to jump-in and implement it, I'm happy to mentor it.

@fitzgen
Copy link
Member

fitzgen commented Apr 6, 2017

Are we done here? Can this be closed?

@emilio
Copy link
Contributor

emilio commented Apr 7, 2017

Yup! Fixed by #608

@emilio emilio closed this as completed Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants