proc: expose macro implementation
Some checks are pending
/ build (push) Waiting to run

This commit is contained in:
🪞👃🪞 2025-05-04 19:59:41 +03:00
parent b543c43e68
commit cba23a005c
3 changed files with 417 additions and 34 deletions

View file

@ -1,14 +1,4 @@
use proc_macro::TokenStream;
use proc_macro2::{
TokenStream as TokenStream2, TokenTree,
Ident, Span, Punct, Spacing, Group, Delimiter, Literal
};
use syn::{parse, parse_macro_input, braced, Token};
use syn::{Expr, Attribute, Meta, MetaList, Path, PathSegment, PathArguments, ImplItem, LitStr};
use syn::parse::{Parse, ParseStream, Result};
use syn::token::{PathSep, Brace};
use syn::punctuated::Punctuated;
use quote::{quote, TokenStreamExt, ToTokens};
use crate::*;
pub(crate) fn view_impl (meta: TokenStream, data: TokenStream) -> TokenStream {
let mut out = TokenStream2::new();
@ -28,7 +18,6 @@ struct ViewDefinition {
#[derive(Debug, Clone)]
struct ViewMeta {
output: Ident,
//attrs: Vec<Attribute>,
}
#[derive(Debug, Clone)]
@ -70,7 +59,7 @@ impl Parse for ViewMeta {
impl Parse for ViewImpl {
fn parse (input: ParseStream) -> Result<Self> {
let _ = input.parse::<Token![impl]>()?;
let mut syms = vec![];
let mut syms = vec![];
Ok(Self {
target: input.parse::<Ident>()?,
items: {
@ -131,7 +120,6 @@ impl Parse for ViewItem {
impl ToTokens for ViewSym {
fn to_tokens (&self, out: &mut TokenStream2) {
use Spacing::*;
out.append(Punct::new(':', Joint));
out.append(Punct::new(':', Alone));
out.append(Ident::new("tengri", Span::call_site()));
@ -226,8 +214,6 @@ impl std::cmp::PartialEq for ViewSym {
}
}
#[cfg(test)] use syn::{ItemImpl, parse_quote as pq};
#[cfg(test)] #[test] fn test_view_meta () {
let x: ViewMeta = pq! { SomeOutput };
let output: Ident = pq! { SomeOutput };