Skip to content

Commit ecb3fa6

Browse files
committed
Merge #1373
1373: Support field attributes on vertex and constant structures r=kvark a=mzmonsour Adds support for attributes on struct fields, such as doc comments. This doesn't work on stable because of a macro parser bug. Wait until rust-lang/rust#42913 is in a stable release (1.20 probably) before merging this.
2 parents 7ab476e + c29b9f7 commit ecb3fa6

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

appveyor.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
environment:
22
matrix:
3-
- TARGET: 1.18.0-x86_64-pc-windows
3+
- TARGET: 1.20.0-x86_64-pc-windows
44
COMPILER: gnu
5-
- TARGET: 1.18.0-x86_64-pc-windows
5+
- TARGET: 1.20.0-x86_64-pc-windows
66
COMPILER: msvc
77
- TARGET: nightly-x86_64-pc-windows
88
COMPILER: msvc

src/render/src/macros/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ macro_rules! gfx_format {
137137
#[macro_export]
138138
macro_rules! gfx_defines {
139139
($(#[$attr:meta])* vertex $name:ident {
140-
$( $field:ident : $ty:ty = $e:expr, )+
140+
$( $(#[$field_attr:meta])* $field:ident : $ty:ty = $e:expr, )+
141141
}) => {
142-
gfx_vertex_struct_meta!($(#[$attr])* vertex_struct_meta $name {$($field:$ty = $e,)+});
142+
gfx_vertex_struct_meta!($(#[$attr])* vertex_struct_meta $name {$( $(#[$field_attr])* $field:$ty = $e,)+});
143143
};
144144

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

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

157157
// The recursive case for vertex structs
158158
($(#[$attr:meta])* vertex $name:ident {
159-
$( $field:ident : $ty:ty = $e:expr, )+
159+
$( $(#[$field_attr:meta])* $field:ident : $ty:ty = $e:expr, )+
160160
} $($tail:tt)+) => {
161161
gfx_defines! {
162162
$(#[$attr])*
163-
vertex $name { $($field : $ty = $e,)+ }
163+
vertex $name { $( $(#[$field_attr])* $field : $ty = $e,)+ }
164164
}
165165
gfx_defines!($($tail)+);
166166
};
167167

168168
// The recursive case for constant structs
169169
($(#[$attr:meta])* constant $name:ident {
170-
$( $field:ident : $ty:ty = $e:expr, )+
170+
$( $(#[$field_attr:meta])* $field:ident : $ty:ty = $e:expr, )+
171171
} $($tail:tt)+) => {
172172
gfx_defines! {
173173
$(#[$attr])*
174-
constant $name { $($field : $ty = $e,)+ }
174+
constant $name { $( $(#[$field_attr])* $field : $ty = $e,)+ }
175175
}
176176
gfx_defines!($($tail)+);
177177
};

src/render/src/macros/structure.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ macro_rules! gfx_impl_struct {
2828
#[macro_export]
2929
macro_rules! gfx_impl_struct_meta {
3030
($(#[$attr:meta])* impl_struct_meta $runtime_format:ty : $compile_format:path = $root:ident {
31-
$( $field:ident: $ty:ty = $name:expr, )*
31+
$( $(#[$field_attr:meta])* $field:ident: $ty:ty = $name:expr, )*
3232
}) => {
3333
#[allow(missing_docs)]
3434
#[derive(Clone, Copy, Debug, PartialEq)]
3535
$(#[$attr])*
3636
pub struct $root {
37-
$( pub $field: $ty, )*
37+
$( $(#[$field_attr])* pub $field: $ty, )*
3838
}
3939

4040
unsafe impl $crate::traits::Pod for $root {}
@@ -90,12 +90,12 @@ macro_rules! gfx_vertex_struct {
9090
#[macro_export]
9191
macro_rules! gfx_vertex_struct_meta {
9292
($(#[$attr:meta])* vertex_struct_meta $root:ident {
93-
$( $field:ident: $ty:ty = $name:expr, )*
93+
$( $(#[$field_attr:meta])* $field:ident: $ty:ty = $name:expr, )*
9494
}) => (gfx_impl_struct_meta!{
9595
$(#[$attr])* impl_struct_meta
9696
$crate::format::Format : $crate::format::Formatted =
9797
$root {
98-
$( $field: $ty = $name, )*
98+
$( $(#[$field_attr])* $field: $ty = $name, )*
9999
}
100100
})
101101
}
@@ -114,12 +114,12 @@ macro_rules! gfx_constant_struct {
114114
#[macro_export]
115115
macro_rules! gfx_constant_struct_meta {
116116
($(#[$attr:meta])* constant_struct_meta $root:ident {
117-
$( $field:ident: $ty:ty = $name:expr, )*
117+
$( $(#[$field_attr:meta])* $field:ident: $ty:ty = $name:expr, )*
118118
}) => (gfx_impl_struct_meta!{
119119
$(#[$attr])* impl_struct_meta
120120
$crate::shade::ConstFormat : $crate::shade::Formatted =
121121
$root {
122-
$( $field: $ty = $name, )*
122+
$( $(#[$field_attr])* $field: $ty = $name, )*
123123
}
124124
})
125125
}

0 commit comments

Comments
 (0)