| 1 | use super::*; |
| 2 | |
| 3 | impl std::fmt::Debug for Field { |
| 4 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 5 | f.debug_tuple(name:"Field" ).field(&self.name()).finish() |
| 6 | } |
| 7 | } |
| 8 | |
| 9 | impl Field { |
| 10 | pub fn flags(&self) -> FieldAttributes { |
| 11 | FieldAttributes(self.usize(0) as u16) |
| 12 | } |
| 13 | |
| 14 | pub fn name(&self) -> &'static str { |
| 15 | self.str(1) |
| 16 | } |
| 17 | |
| 18 | pub fn constant(&self) -> Option<Constant> { |
| 19 | self.file() |
| 20 | .equal_range(1, HasConstant::Field(*self).encode()) |
| 21 | .next() |
| 22 | } |
| 23 | |
| 24 | pub fn ty(&self, enclosing: Option<&CppStruct>) -> Type { |
| 25 | let mut blob = self.blob(2); |
| 26 | blob.read_usize(); |
| 27 | blob.read_modifiers(); |
| 28 | |
| 29 | let ty = Type::from_blob(&mut blob, enclosing, &[]); |
| 30 | |
| 31 | if self.has_attribute("ConstAttribute" ) { |
| 32 | ty.to_const_type().to_const_ptr() |
| 33 | } else { |
| 34 | ty |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |