Skip to content

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Nov 11, 2020

This is called out in #370 as not implemented yet.

It should achieve points 1-3 on the plan in #353, and most of #​4 (it doesn't currently look for namespace attributes on extern blocks but the rest is done).

This PR implements #[namespace = "..."] attributes on extern blocks, such that an item will inherit the namespace specified on its surrounding extern block if any, otherwise the namespace specified with the top level cxx::bridge attribute.

#[cxx::bridge(namespace = "third_priority")]
mod ffi {
    #[namespace = "second_priority"]
    extern "Rust" {
        fn f();

        #[namespace = "first_priority"]
        fn g();
    }

    extern "Rust" {
        fn h();
    }
}

The above would result in functions ::second_priority::f, ::first_priority::g, ::third_priority::h.

@dtolnay dtolnay merged commit c1e475e into master Nov 11, 2020
@dtolnay dtolnay deleted the namespace branch November 11, 2020 03:03
@dtolnay dtolnay mentioned this pull request Nov 28, 2020
7 tasks
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

Successfully merging this pull request may close these issues.

1 participant