Skip to content
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

Failing to generate type referenced by a whitelisted type's constructor #447

Closed
fitzgen opened this issue Jan 26, 2017 · 3 comments
Closed

Comments

@fitzgen
Copy link
Member

fitzgen commented Jan 26, 2017

Input:

namespace mozilla {
template <typename> class a {};
namespace detail {
class GuardObjectNotifier;
struct b;
}
class c {
  typedef detail::b d;
};
}
namespace js {
class D {
  mozilla::a<mozilla::c> e;
};
}
struct f {
  js::D g;
};
namespace js {
struct ContextFriendFields : f {};
}
class JSAutoCompartment {
public:
  JSAutoCompartment(mozilla::detail::GuardObjectNotifier);
};

Output with --enable-cxx-namespaces --whitelist-type JSAutoCompartment -- --std=c++11:

/* automatically generated by rust-bindgen */

pub mod root {
    #[allow(unused_imports)]
    use self::super::root;
    pub mod mozilla {
        #[allow(unused_imports)]
        use self::super::super::root;
    }
    #[repr(C)]
    #[derive(Debug, Copy)]
    pub struct JSAutoCompartment {
        pub _address: u8,
    }
    #[test]
    fn bindgen_test_layout_JSAutoCompartment() {
        assert_eq!(::std::mem::size_of::<JSAutoCompartment>() , 1usize);
        assert_eq!(::std::mem::align_of::<JSAutoCompartment>() , 1usize);
    }
    extern "C" {
        #[link_name =
              "_ZN17JSAutoCompartmentC1EN7mozilla6detail19GuardObjectNotifierE"]
        pub fn JSAutoCompartment_JSAutoCompartment(this:
                                                       *mut root::JSAutoCompartment,
                                                   arg1:
                                                       root::mozilla::detail::GuardObjectNotifier);
    }
    impl Clone for JSAutoCompartment {
        fn clone(&self) -> Self { *self }
    }
    impl JSAutoCompartment {
        #[inline]
        pub unsafe fn new(arg1: root::mozilla::detail::GuardObjectNotifier)
         -> Self {
            let mut __bindgen_tmp = ::std::mem::uninitialized();
            JSAutoCompartment_JSAutoCompartment(&mut __bindgen_tmp, arg1);
            __bindgen_tmp
        }
    }
}

Compilation errors:

error[E0433]: failed to resolve. Could not find `detail` in `mozilla`
  --> js.rs:26:56
   |
26 |                                                        root::mozilla::detail::GuardObjectNotifier);
   |                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Could not find `detail` in `mozilla`
@emilio
Copy link
Contributor

emilio commented Jan 26, 2017

Hmm, well, bindgen knows about the detail namespace, that's good. Do we trace constructors at all right now?

@fitzgen
Copy link
Member Author

fitzgen commented Jan 26, 2017

We trace all methods, and we don't distinguish constructors from methods except with a MethodKind, so I would think we should trace constructors.

@fitzgen
Copy link
Member Author

fitzgen commented Jan 27, 2017

We trace all methods, and we don't distinguish constructors from methods except with a MethodKind, so I would think we should trace constructors.

This is not true, they are actually separated. Patch incoming.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants