| 1 | use super::*; |
| 2 | |
| 3 | mod attribute; |
| 4 | mod class_layout; |
| 5 | mod constant; |
| 6 | mod field; |
| 7 | mod generic_param; |
| 8 | mod impl_map; |
| 9 | mod interface_impl; |
| 10 | mod member_ref; |
| 11 | mod method_def; |
| 12 | mod module_ref; |
| 13 | mod nested_class; |
| 14 | mod param; |
| 15 | mod type_def; |
| 16 | mod type_ref; |
| 17 | mod type_spec; |
| 18 | |
| 19 | macro_rules! tables { |
| 20 | ($(($name:ident, $table:literal))+) => { |
| 21 | $( |
| 22 | #[derive(Copy, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)] |
| 23 | pub struct $name(pub Row); |
| 24 | impl AsRow for $name { |
| 25 | const TABLE: usize = $table; |
| 26 | fn to_row(&self) -> Row { |
| 27 | self.0 |
| 28 | } |
| 29 | fn from_row(row: Row) -> Self { |
| 30 | $name(row) |
| 31 | } |
| 32 | } |
| 33 | )* |
| 34 | }; |
| 35 | } |
| 36 | |
| 37 | tables! { |
| 38 | (Attribute, 1) |
| 39 | (ClassLayout, 16) |
| 40 | (Constant, 0) |
| 41 | (Field, 2) |
| 42 | (GenericParam, 3) |
| 43 | (ImplMap, 11) |
| 44 | (InterfaceImpl, 4) |
| 45 | (MemberRef, 5) |
| 46 | (MethodDef, 6) |
| 47 | (ModuleRef, 12) |
| 48 | (NestedClass, 13) |
| 49 | (Param, 7) |
| 50 | (TypeDef, 8) |
| 51 | (TypeRef, 9) |
| 52 | (TypeSpec, 10) |
| 53 | } |
| 54 | |
| 55 | fn trim_tick(name: &str) -> &str { |
| 56 | if name.as_bytes().iter().rev().nth(1) == Some(&b'`' ) { |
| 57 | &name[..name.len() - 2] |
| 58 | } else { |
| 59 | name |
| 60 | } |
| 61 | } |
| 62 | |