summaryrefslogtreecommitdiffstats
path: root/third_party/rust/uniffi_macros/src/export/metadata.rs
blob: 2d0b2843333d91e1f181800e97b66bd980fe5001 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

use proc_macro2::Span;

use super::ExportItem;

pub(crate) mod convert;
mod function;
mod impl_;

use self::{function::gen_fn_metadata, impl_::gen_impl_metadata};

pub fn gen_metadata(item: syn::Item, mod_path: &[String]) -> syn::Result<ExportItem> {
    match item {
        syn::Item::Fn(item) => gen_fn_metadata(item.sig, mod_path),
        syn::Item::Impl(item) => gen_impl_metadata(item, mod_path),
        // FIXME: Support const / static?
        _ => Err(syn::Error::new(
            Span::call_site(),
            "unsupported item: only functions and impl \
             blocks may be annotated with this attribute",
        )),
    }
}