summaryrefslogtreecommitdiff
path: root/ecs-macros
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2025-04-02 14:42:10 +0200
committerHampusM <hampus@hampusmat.com>2025-04-02 14:42:10 +0200
commitd00ce85c591f7fa8385ef7e99b44db6a14788cd4 (patch)
tree81c17ccc6b5446ea46ba039cd231cfd01c3f2a91 /ecs-macros
parentff7406e6d8b70884faaff7707c7d917faabe1a53 (diff)
refactor(ecs): move & rename system::ComponentRef* to component mod
Diffstat (limited to 'ecs-macros')
-rw-r--r--ecs-macros/src/lib.rs44
1 files changed, 23 insertions, 21 deletions
diff --git a/ecs-macros/src/lib.rs b/ecs-macros/src/lib.rs
index b58671d..5af10b9 100644
--- a/ecs-macros/src/lib.rs
+++ b/ecs-macros/src/lib.rs
@@ -47,7 +47,7 @@ pub fn component_derive(input: TokenStream) -> TokenStream
{
let item: TypeItem = parse::<Item>(input).unwrap().try_into().unwrap();
- let ComponentAttribute { ref_type, ref_mut_type } = item
+ let ComponentAttribute { handle_type, handle_mut_type } = item
.attribute::<ComponentAttribute>("component")
.unwrap_or_default();
@@ -114,8 +114,10 @@ pub fn component_derive(input: TokenStream) -> TokenStream
Removed as ComponentRemovedEvent,
Kind as ComponentEventKind,
};
- use #ecs_path::system::ComponentRefMut;
- use #ecs_path::system::ComponentRef;
+ use #ecs_path::component::{
+ Handle as ComponentHandle,
+ HandleMut as ComponentHandleMut
+ };
use #ecs_path::uid::{Uid, Kind as UidKind};
use #ecs_path::system::Input as SystemInput;
use #ecs_path::type_name::TypeName;
@@ -129,8 +131,8 @@ pub fn component_derive(input: TokenStream) -> TokenStream
{
type Component = Self;
- type RefMut<'component> = #ref_mut_type;
- type Ref<'component> = #ref_type;
+ type HandleMut<'component> = #handle_mut_type;
+ type Handle<'component> = #handle_type;
fn id() -> Uid
{
@@ -389,32 +391,32 @@ fn find_engine_ecs_crate_path() -> Option<Path>
#[derive(Debug)]
struct ComponentAttribute
{
- ref_type: proc_macro2::TokenStream,
- ref_mut_type: proc_macro2::TokenStream,
+ handle_type: proc_macro2::TokenStream,
+ handle_mut_type: proc_macro2::TokenStream,
}
impl FromAttribute for ComponentAttribute
{
fn from_attribute(attribute: &Attribute) -> Result<Self, syn::Error>
{
- let mut ref_type: Option<Type> = None;
- let mut ref_mut_type: Option<Type> = None;
+ let mut handle_type: Option<Type> = None;
+ let mut handle_mut_type: Option<Type> = None;
attribute.parse_nested_meta(|meta| {
let Some(flag) = meta.path.get_ident() else {
return Err(meta.error("Not a single identifier"));
};
- if flag == "ref_type" {
+ if flag == "handle_type" {
let value = meta.value()?;
- ref_type = Some(value.parse::<Type>()?);
+ handle_type = Some(value.parse::<Type>()?);
return Ok(());
- } else if flag == "ref_mut_type" {
+ } else if flag == "handle_mut_type" {
let value = meta.value()?;
- ref_mut_type = Some(value.parse::<Type>()?);
+ handle_mut_type = Some(value.parse::<Type>()?);
return Ok(());
}
@@ -423,12 +425,12 @@ impl FromAttribute for ComponentAttribute
})?;
Ok(Self {
- ref_type: ref_type
- .map(|ref_type| ref_type.into_token_stream())
- .unwrap_or_else(|| Self::default().ref_type),
- ref_mut_type: ref_mut_type
- .map(|ref_mut_type| ref_mut_type.into_token_stream())
- .unwrap_or_else(|| Self::default().ref_mut_type),
+ handle_type: handle_type
+ .map(|handle_type| handle_type.into_token_stream())
+ .unwrap_or_else(|| Self::default().handle_type),
+ handle_mut_type: handle_mut_type
+ .map(|handle_mut_type| handle_mut_type.into_token_stream())
+ .unwrap_or_else(|| Self::default().handle_mut_type),
})
}
}
@@ -438,8 +440,8 @@ impl Default for ComponentAttribute
fn default() -> Self
{
Self {
- ref_type: quote! { ComponentRef<'component, Self> },
- ref_mut_type: quote! { ComponentRefMut<'component, Self> },
+ handle_type: quote! { ComponentHandle<'component, Self> },
+ handle_mut_type: quote! { ComponentHandleMut<'component, Self> },
}
}
}