Skip to content

Commit

Permalink
Apply field attributes for gfx_defines! structures
Browse files Browse the repository at this point in the history
  • Loading branch information
mzmonsour committed Jul 14, 2017
1 parent 6ef45d9 commit 57d9d61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions src/render/src/macros/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ macro_rules! gfx_format {
#[macro_export]
macro_rules! gfx_defines {
($(#[$attr:meta])* vertex $name:ident {
$( $field:ident : $ty:ty = $e:expr, )+
$( $(#[$field_attr:meta])* $field:ident : $ty:ty = $e:expr, )+
}) => {
gfx_vertex_struct_meta!($(#[$attr])* vertex_struct_meta $name {$($field:$ty = $e,)+});
gfx_vertex_struct_meta!($(#[$attr])* vertex_struct_meta $name {$( $(#[$field_attr])* $field:$ty = $e,)+});
};

($(#[$attr:meta])* constant $name:ident {
$( $field:ident : $ty:ty = $e:expr, )+
$( $(#[$field_attr:meta])* $field:ident : $ty:ty = $e:expr, )+
}) => {
gfx_constant_struct_meta!($(#[$attr])* constant_struct_meta $name {$($field:$ty = $e,)+});
gfx_constant_struct_meta!($(#[$attr])* constant_struct_meta $name {$( $(#[$field_attr])* $field:$ty = $e,)+});
};

(pipeline $name:ident {
Expand All @@ -156,22 +156,22 @@ macro_rules! gfx_defines {

// The recursive case for vertex structs
($(#[$attr:meta])* vertex $name:ident {
$( $field:ident : $ty:ty = $e:expr, )+
$( $(#[$field_attr:meta])* $field:ident : $ty:ty = $e:expr, )+
} $($tail:tt)+) => {
gfx_defines! {
$(#[$attr])*
vertex $name { $($field : $ty = $e,)+ }
vertex $name { $( $(#[$field_attr])* $field : $ty = $e,)+ }
}
gfx_defines!($($tail)+);
};

// The recursive case for constant structs
($(#[$attr:meta])* constant $name:ident {
$( $field:ident : $ty:ty = $e:expr, )+
$( $(#[$field_attr:meta])* $field:ident : $ty:ty = $e:expr, )+
} $($tail:tt)+) => {
gfx_defines! {
$(#[$attr])*
constant $name { $($field : $ty = $e,)+ }
constant $name { $( $(#[$field_attr])* $field : $ty = $e,)+ }
}
gfx_defines!($($tail)+);
};
Expand Down
12 changes: 6 additions & 6 deletions src/render/src/macros/structure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ macro_rules! gfx_impl_struct {
#[macro_export]
macro_rules! gfx_impl_struct_meta {
($(#[$attr:meta])* impl_struct_meta $runtime_format:ty : $compile_format:path = $root:ident {
$( $field:ident: $ty:ty = $name:expr, )*
$( $(#[$field_attr:meta])* $field:ident: $ty:ty = $name:expr, )*
}) => {
#[allow(missing_docs)]
#[derive(Clone, Copy, Debug, PartialEq)]
$(#[$attr])*
pub struct $root {
$( pub $field: $ty, )*
$( $(#[$field_attr])* pub $field: $ty, )*
}

unsafe impl $crate::traits::Pod for $root {}
Expand Down Expand Up @@ -90,12 +90,12 @@ macro_rules! gfx_vertex_struct {
#[macro_export]
macro_rules! gfx_vertex_struct_meta {
($(#[$attr:meta])* vertex_struct_meta $root:ident {
$( $field:ident: $ty:ty = $name:expr, )*
$( $(#[$field_attr:meta])* $field:ident: $ty:ty = $name:expr, )*
}) => (gfx_impl_struct_meta!{
$(#[$attr])* impl_struct_meta
$crate::format::Format : $crate::format::Formatted =
$root {
$( $field: $ty = $name, )*
$( $(#[$field_attr])* $field: $ty = $name, )*
}
})
}
Expand All @@ -114,12 +114,12 @@ macro_rules! gfx_constant_struct {
#[macro_export]
macro_rules! gfx_constant_struct_meta {
($(#[$attr:meta])* constant_struct_meta $root:ident {
$( $field:ident: $ty:ty = $name:expr, )*
$( $(#[$field_attr:meta])* $field:ident: $ty:ty = $name:expr, )*
}) => (gfx_impl_struct_meta!{
$(#[$attr])* impl_struct_meta
$crate::shade::ConstFormat : $crate::shade::Formatted =
$root {
$( $field: $ty = $name, )*
$( $(#[$field_attr])* $field: $ty = $name, )*
}
})
}

0 comments on commit 57d9d61

Please sign in to comment.