JavaScript is disabled, refresh for a better experience. ambee/giterated

ambee/giterated

Git repository hosting, collaboration, and discovery for the Fediverse.

Structure refactoring

Amber - ⁨1⁩ year ago

parent: tbd commit: ⁨a8f41ac

⁨giterated-macros/src/lib.rs⁩ - ⁨974⁩ bytes
Raw
1 use proc_macro::TokenStream;
2 use quote::quote;
3 use syn::{parse_macro_input, Abi, Attribute, ItemFn};
4
5 extern crate proc_macro;
6
7 #[proc_macro]
8 pub fn plugin(metadata: TokenStream) -> TokenStream {
9 emit_plugin_api().into()
10 }
11
12 #[proc_macro_attribute]
13 pub fn plugin_init(attribute: TokenStream, item: TokenStream) -> TokenStream {
14 let mut input = parse_macro_input!(item as ItemFn);
15
16 quote! {
17 #[doc(hidden)]
18 #[no_mangle]
19 unsafe extern "C" fn __plugin_init() {
20 #input.sig.ident()
21 }
22 }
23 .into()
24 }
25
26 fn emit_plugin_api() -> impl Into<TokenStream> {
27 quote! {
28 #[doc(hidden)]
29 #[no_mangle]
30 unsafe extern "C" fn __load_runtime_vtable(vtable: &'static ::giterated_abi::VTable<Runtime>) {
31 todo!()
32 }
33
34 #[doc(hidden)]
35 #[no_mangle]
36 unsafe extern "C" fn __get_plugin_vtable() -> &'static ::giterated_abi::VTable<Plugin> {
37 todo!()
38 }
39 }
40 }
41