-
Notifications
You must be signed in to change notification settings - Fork 543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add attributes to gfx_defines macros #1080
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,8 +18,20 @@ | |
macro_rules! gfx_impl_struct { | ||
($runtime_format:ty : $compile_format:path = $root:ident { | ||
$( $field:ident: $ty:ty = $name:expr, )* | ||
}) => (gfx_impl_struct_meta! { | ||
impl_struct_meta $runtime_format : $compile_format = $root { | ||
$( $field : $ty = $name, )* | ||
} | ||
}) | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! gfx_impl_struct_meta { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any reason you decided to not just put the extra stuff into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Backwards compatibility in case anybody called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could probably have two patterns inside |
||
($(#[$attr:meta])* impl_struct_meta $runtime_format:ty : $compile_format:path = $root:ident { | ||
$( $field:ident: $ty:ty = $name:expr, )* | ||
}) => { | ||
#[derive(Clone, Copy, Debug)] | ||
$(#[$attr])* | ||
pub struct $root { | ||
$( pub $field: $ty, )* | ||
} | ||
|
@@ -66,7 +78,19 @@ macro_rules! gfx_impl_struct { | |
macro_rules! gfx_vertex_struct { | ||
($root:ident { | ||
$( $field:ident: $ty:ty = $name:expr, )* | ||
}) => (gfx_impl_struct!{ | ||
}) => (gfx_vertex_struct_meta! { | ||
vertex_struct_meta $root { | ||
$( $field : $ty = $name, )* | ||
} | ||
}) | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! gfx_vertex_struct_meta { | ||
($(#[$attr:meta])* vertex_struct_meta $root:ident { | ||
$( $field:ident: $ty:ty = $name:expr, )* | ||
}) => (gfx_impl_struct_meta!{ | ||
$(#[$attr])* impl_struct_meta | ||
$crate::format::Format : $crate::format::Formatted = | ||
$root { | ||
$( $field: $ty = $name, )* | ||
|
@@ -78,7 +102,19 @@ macro_rules! gfx_vertex_struct { | |
macro_rules! gfx_constant_struct { | ||
($root:ident { | ||
$( $field:ident: $ty:ty = $name:expr, )* | ||
}) => (gfx_impl_struct!{ | ||
}) => (gfx_constant_struct_meta!{ | ||
constant_struct_meta $root { | ||
$( $field : $ty = $name, )* | ||
} | ||
}) | ||
} | ||
|
||
#[macro_export] | ||
macro_rules! gfx_constant_struct_meta { | ||
($(#[$attr:meta])* constant_struct_meta $root:ident { | ||
$( $field:ident: $ty:ty = $name:expr, )* | ||
}) => (gfx_impl_struct_meta!{ | ||
$(#[$attr])* impl_struct_meta | ||
$crate::shade::ConstFormat : $crate::shade::Formatted = | ||
$root { | ||
$( $field: $ty = $name, )* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this ever going to hit, given that the same pattern is parsed above?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern contains
$($tail:tt)+
, it's the recursive case. The above pattern only matches for a single struct.