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

Parse namespace attribute on foreign mods #444

Merged
merged 2 commits into from
Nov 11, 2020
Merged

Parse namespace attribute on foreign mods #444

merged 2 commits into from
Nov 11, 2020

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