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