LCOV - code coverage report
Current view: top level - src/pdb/types - classlike.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 0.0 % 51 0
Test Date: 2024-11-30:00:00:00 Functions: 0.0 % 34 0

            Line data    Source code
       1              : use lief_ffi as ffi;
       2              : 
       3              : use crate::common::FromFFI;
       4              : use std::marker::PhantomData;
       5              : use crate::pdb::types::PdbType;
       6              : use crate::pdb::types::attribute::Attributes;
       7              : use crate::pdb::types::method::Methods;
       8              : 
       9              : 
      10              : /// Trait shared by [`Structure`], [`Class`], [`Union`] and [`Interface`]
      11              : pub trait ClassLike {
      12              :     #[doc(hidden)]
      13              :     fn get_classlike(&self) -> &ffi::PDB_types_ClassLike;
      14              : 
      15              :     /// Mangled type name
      16            0 :     fn unique_name(&self) -> String {
      17            0 :         self.get_classlike().unique_name().to_string()
      18            0 :     }
      19              : 
      20              :     /// Demangled type name
      21            0 :     fn name(&self) -> String {
      22            0 :         self.get_classlike().name().to_string()
      23            0 :     }
      24              : 
      25              :     /// Size of the type including all its attributes. This size should match
      26              :     /// the `sizeof(...)` this type.
      27            0 :     fn size(&self) -> u64 {
      28            0 :         self.get_classlike().size()
      29            0 :     }
      30              : 
      31              :     /// Iterator over the different [`crate::pdb::types::Attribute`] defined in this
      32              :     /// class-like type
      33            0 :     fn attributes(&self) -> Attributes {
      34            0 :         Attributes::new(self.get_classlike().attributes())
      35            0 :     }
      36              : 
      37              :     /// Iterator over the different [`crate::pdb::types::Method`] implemented in this
      38              :     /// class-like type
      39            0 :     fn methods(&self) -> Methods {
      40            0 :         Methods::new(self.get_classlike().methods())
      41            0 :     }
      42              : }
      43              : 
      44              : /// This structure wraps a `LF_CLASS` PDB type
      45              : pub struct Class<'a> {
      46              :     ptr: cxx::UniquePtr<ffi::PDB_types_Class>,
      47              :     _owner: PhantomData<&'a ()>,
      48              : }
      49              : 
      50              : impl FromFFI<ffi::PDB_types_Class> for Class<'_> {
      51            0 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::PDB_types_Class>) -> Self {
      52            0 :         Self {
      53            0 :             ptr: cmd,
      54            0 :             _owner: PhantomData,
      55            0 :         }
      56            0 :     }
      57              : }
      58              : 
      59              : impl ClassLike for Class<'_> {
      60            0 :     fn get_classlike(&self) -> &ffi::PDB_types_ClassLike {
      61            0 :         self.ptr.as_ref().unwrap().as_ref()
      62            0 :     }
      63              : }
      64              : 
      65              : impl PdbType for Class<'_> {
      66            0 :     fn get_base(&self) -> &ffi::PDB_Type {
      67            0 :         self.ptr.as_ref().unwrap().as_ref().as_ref()
      68            0 :     }
      69              : }
      70              : 
      71              : /// This structure wraps a `LF_STRUCTURE` PDB type
      72              : pub struct Structure<'a> {
      73              :     ptr: cxx::UniquePtr<ffi::PDB_types_Structure>,
      74              :     _owner: PhantomData<&'a ()>,
      75              : }
      76              : 
      77              : impl FromFFI<ffi::PDB_types_Structure> for Structure<'_> {
      78            0 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::PDB_types_Structure>) -> Self {
      79            0 :         Self {
      80            0 :             ptr: cmd,
      81            0 :             _owner: PhantomData,
      82            0 :         }
      83            0 :     }
      84              : }
      85              : 
      86              : impl ClassLike for Structure<'_> {
      87            0 :     fn get_classlike(&self) -> &ffi::PDB_types_ClassLike {
      88            0 :         self.ptr.as_ref().unwrap().as_ref()
      89            0 :     }
      90              : }
      91              : 
      92              : impl PdbType for Structure<'_> {
      93            0 :     fn get_base(&self) -> &ffi::PDB_Type {
      94            0 :         self.ptr.as_ref().unwrap().as_ref().as_ref()
      95            0 :     }
      96              : }
      97              : 
      98              : /// This structure wraps a `LF_INTERFACE` PDB type
      99              : pub struct Interface<'a> {
     100              :     ptr: cxx::UniquePtr<ffi::PDB_types_Interface>,
     101              :     _owner: PhantomData<&'a ()>,
     102              : }
     103              : 
     104              : impl FromFFI<ffi::PDB_types_Interface> for Interface<'_> {
     105            0 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::PDB_types_Interface>) -> Self {
     106            0 :         Self {
     107            0 :             ptr: cmd,
     108            0 :             _owner: PhantomData,
     109            0 :         }
     110            0 :     }
     111              : }
     112              : 
     113              : impl ClassLike for Interface<'_> {
     114            0 :     fn get_classlike(&self) -> &ffi::PDB_types_ClassLike {
     115            0 :         self.ptr.as_ref().unwrap().as_ref()
     116            0 :     }
     117              : }
     118              : 
     119              : impl PdbType for Interface<'_> {
     120            0 :     fn get_base(&self) -> &ffi::PDB_Type {
     121            0 :         self.ptr.as_ref().unwrap().as_ref().as_ref()
     122            0 :     }
     123              : }
        

Generated by: LCOV version 2.1-1