@@ -247,6 +247,29 @@ pub fn reflect_trait(args: TokenStream, input: TokenStream) -> TokenStream {
247
247
trait_reflection:: reflect_trait ( & args, input)
248
248
}
249
249
250
+ /// A macro used to generate reflection trait implementations for the given type.
251
+ ///
252
+ /// This is functionally the same as [deriving `Reflect`] using the `#[reflect_value]` container attribute.
253
+ ///
254
+ /// The only reason for this macro's existence is so that `bevy_reflect` can easily implement the reflection traits
255
+ /// on primitives and other Rust types internally.
256
+ ///
257
+ /// # Examples
258
+ ///
259
+ /// Types can be passed with or without registering type data:
260
+ ///
261
+ /// ```ignore
262
+ /// impl_reflect_value!(foo);
263
+ /// impl_reflect_value!(bar(Debug, Default, Serialize, Deserialize));
264
+ /// ```
265
+ ///
266
+ /// Generic types can also specify their parameters and bounds:
267
+ ///
268
+ /// ```ignore
269
+ /// impl_reflect_value!(foo<T1, T2: Baz> where T1: Bar (Default, Serialize, Deserialize));
270
+ /// ```
271
+ ///
272
+ /// [deriving `Reflect`]: Reflect
250
273
#[ proc_macro]
251
274
pub fn impl_reflect_value ( input : TokenStream ) -> TokenStream {
252
275
let def = parse_macro_input ! ( input as ReflectValueDef ) ;
@@ -328,6 +351,22 @@ pub fn impl_reflect_struct(input: TokenStream) -> TokenStream {
328
351
}
329
352
}
330
353
354
+ /// A macro used to generate a `FromReflect` trait implementation for the given type.
355
+ ///
356
+ /// This is functionally the same as [deriving `FromReflect`] on a type that [derives `Reflect`] using
357
+ /// the `#[reflect_value]` container attribute.
358
+ ///
359
+ /// The only reason this macro exists is so that `bevy_reflect` can easily implement `FromReflect` on
360
+ /// primitives and other Rust types internally.
361
+ ///
362
+ /// # Examples
363
+ ///
364
+ /// ```ignore
365
+ /// impl_from_reflect_value!(foo<T1, T2: Baz> where T1: Bar);
366
+ /// ```
367
+ ///
368
+ /// [deriving `FromReflect`]: FromReflect
369
+ /// [derives `Reflect`]: Reflect
331
370
#[ proc_macro]
332
371
pub fn impl_from_reflect_value ( input : TokenStream ) -> TokenStream {
333
372
let def = parse_macro_input ! ( input as ReflectValueDef ) ;
0 commit comments