1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
Hereditary
Autors: Francisco Leon <https://github.com/superoptimo>
License Apache-2.0
*/
use TokenStream;
///
/// Trait declarations only have to aggregate this attribute for generating
/// trait information, and this procedure generates a declarative macro information
/// that pass trait information fields to a receiver bridge macro.
/// ```
/// #[trait_info]
/// trait MyTrait
/// {
/// type MyTyp = AnotherClass::Typ;
/// fn method1(&self, num:u32) -> String;
/// fn method1(&mut self, num:u32, arr:&[u8]) -> String;
/// }
/// ```
/// The resulting code processed by **Rust Compiler** expands a
/// delcarative macro that injects a trait information syntax to
/// a requester macro by demand (The `Bridge Macro`):
///
/// ```
/// // Original trait
/// trait MyTrait
/// {
/// type MyTyp = AnotherClass::Typ;
/// fn method1(&self, num:u32) -> String;
/// fn method1(&mut self, num:u32, arr:&[u8]) -> String;
/// }
///
/// // Generated macro is named with the prefix TraitInfo_
/// // prepended before the name of the trait (MyTrait)
/// #[macro_export]
/// macrorules! TraitInfo_MyTrait
/// {
/// ($target_bridge_macro:ident, [ $($bridgecontent:tt)*]) => {
/// $target_bridge_macro!(
/// [
/// $($bridgecontent)*
/// ],
/// [
/// //** Here comes the trait information block
/// MyTrait
/// {
/// FUNCS[
/// fn method1(&self, num:u32) -> String;
/// fn method1(&mut self, num:u32, arr:&[u8]) -> String;
/// ]
/// TYPES[
/// MyTyp;
/// ]
/// CONSTANTS[]
/// }
/// //** End Block Trait info
/// ]
/// );
/// };
/// }
///
/// ```
/// The `Bridge Macro` would be a procedural macro that interprets the trait information
/// with the help of the utility type `trait_info_gen::SimpleTraitInfo`
///