-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Instead of being on the component type, tracking is set on the view
- Loading branch information
Showing
96 changed files
with
3,013 additions
and
3,949 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,77 +1,18 @@ | ||
use proc_macro2::TokenStream; | ||
use quote::quote; | ||
use syn::{Error, Result}; | ||
|
||
pub(crate) fn expand_component( | ||
name: syn::Ident, | ||
generics: syn::Generics, | ||
attribute_input: Option<&syn::Attribute>, | ||
) -> Result<TokenStream> { | ||
let tracking = if let Some(tracking_attr) = attribute_input { | ||
let tracking: syn::Ident = tracking_attr.parse_args().map_err(|_| { | ||
Error::new_spanned( | ||
&tracking_attr.tokens, | ||
"Track should be one of: Untracked, Insertion, Modification, Deletion, Removal or All.", | ||
) | ||
})?; | ||
|
||
let tracking_name = tracking.to_string(); | ||
|
||
match tracking_name.as_str() { | ||
"Untracked" | "Insertion" | "Modification" | "Deletion" | "Removal" | "All" => {} | ||
_ => return Err(Error::new_spanned( | ||
&tracking, | ||
"Track should be one of: Untracked, Insertion, Modification, Deletion, Removal or All.", | ||
)), | ||
} | ||
|
||
quote!(#tracking) | ||
} else { | ||
quote!(Untracked) | ||
}; | ||
|
||
pub(crate) fn expand_component(name: syn::Ident, generics: syn::Generics) -> TokenStream { | ||
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); | ||
|
||
Ok(quote!( | ||
impl #impl_generics ::shipyard::Component for #name #ty_generics #where_clause { | ||
type Tracking = ::shipyard::track::#tracking; | ||
} | ||
)) | ||
quote!( | ||
impl #impl_generics ::shipyard::Component for #name #ty_generics #where_clause {} | ||
) | ||
} | ||
|
||
pub(crate) fn expand_unique( | ||
name: syn::Ident, | ||
generics: syn::Generics, | ||
attribute_input: Option<&syn::Attribute>, | ||
) -> Result<TokenStream> { | ||
let tracking = if let Some(tracking_attr) = attribute_input { | ||
let tracking: syn::Ident = tracking_attr.parse_args().map_err(|_| { | ||
Error::new_spanned( | ||
&tracking_attr.tokens, | ||
"Track should be one of: Untracked, Insertion, Modification, Deletion, Removal or All.", | ||
) | ||
})?; | ||
|
||
let tracking_name = tracking.to_string(); | ||
|
||
match tracking_name.as_str() { | ||
"Untracked" | "Insertion" | "Modification" | "Deletion" | "Removal" | "All" => {} | ||
_ => return Err(Error::new_spanned( | ||
&tracking, | ||
"Track should be one of: Untracked, Insertion, Modification, Deletion, Removal or All.", | ||
)), | ||
} | ||
|
||
quote!(#tracking) | ||
} else { | ||
quote!(Untracked) | ||
}; | ||
|
||
pub(crate) fn expand_unique(name: syn::Ident, generics: syn::Generics) -> TokenStream { | ||
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl(); | ||
|
||
Ok(quote!( | ||
impl #impl_generics ::shipyard::Unique for #name #ty_generics #where_clause { | ||
type Tracking = ::shipyard::track::#tracking; | ||
} | ||
)) | ||
quote!( | ||
impl #impl_generics ::shipyard::Unique for #name #ty_generics #where_clause {} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.