mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
This commit is contained in:
parent
7570aefcc2
commit
7df7cb839c
2 changed files with 157 additions and 2 deletions
|
|
@ -2,6 +2,7 @@ extern crate proc_macro;
|
|||
|
||||
pub(crate) use std::collections::{BTreeMap, BTreeSet};
|
||||
pub(crate) use std::cmp::Ordering;
|
||||
pub(crate) use std::sync::Arc;
|
||||
pub(crate) use proc_macro::TokenStream;
|
||||
pub(crate) use proc_macro2::{
|
||||
TokenStream as TokenStream2, TokenTree,
|
||||
|
|
@ -11,16 +12,17 @@ pub(crate) use syn::{
|
|||
parse, parse_macro_input, parse_quote as pq,
|
||||
braced, bracketed, parenthesized, Token,
|
||||
Arm, Expr, Attribute, Meta, MetaList, Path, PathSegment, PathArguments,
|
||||
ImplItem, ImplItemFn, LitStr, Type, ItemImpl, ReturnType, Signature,
|
||||
ImplItem, ImplItemFn, LitStr, Type, ItemImpl, ReturnType, Signature, FnArg, PatType,
|
||||
parse::{Parse, ParseStream, Result},
|
||||
token::{PathSep, Brace},
|
||||
punctuated::Punctuated,
|
||||
};
|
||||
pub(crate) use quote::{quote, TokenStreamExt, ToTokens};
|
||||
pub(crate) use heck::AsKebabCase;
|
||||
pub(crate) use heck::{AsKebabCase, AsUpperCamelCase};
|
||||
|
||||
mod proc_view;
|
||||
mod proc_expose;
|
||||
mod proc_command;
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn view (meta: TokenStream, item: TokenStream) -> TokenStream {
|
||||
|
|
@ -40,6 +42,15 @@ pub fn expose (meta: TokenStream, item: TokenStream) -> TokenStream {
|
|||
))
|
||||
}
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn command (meta: TokenStream, item: TokenStream) -> TokenStream {
|
||||
use self::proc_command::{CommandDef, CommandMeta, CommandImpl};
|
||||
write_macro(CommandDef(
|
||||
parse_macro_input!(meta as CommandMeta),
|
||||
parse_macro_input!(item as CommandImpl),
|
||||
))
|
||||
}
|
||||
|
||||
fn write_macro <T: ToTokens> (t: T) -> TokenStream {
|
||||
let mut out = TokenStream2::new();
|
||||
t.to_tokens(&mut out);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue