LCOV - code coverage report
Current view: top level - src/pdb/types - method.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 0.0 % 62 0
Test Date: 2026-02-28:00:00:00 Functions: 0.0 % 17 0

            Line data    Source code
       1              : use lief_ffi as ffi;
       2              : 
       3              : use crate::common::FromFFI;
       4              : use std::marker::PhantomData;
       5              : 
       6              : use crate::declare_fwd_iterator;
       7              : 
       8              : /// This class represents a Method (`LF_ONEMETHOD`) that can be defined in
       9              : /// ClassLike PDB type
      10              : pub struct Method<'a> {
      11              :     ptr: cxx::UniquePtr<ffi::PDB_types_Method>,
      12              :     _owner: PhantomData<&'a ()>,
      13              : }
      14              : 
      15              : impl FromFFI<ffi::PDB_types_Method> for Method<'_> {
      16            0 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::PDB_types_Method>) -> Self {
      17            0 :         Self {
      18            0 :             ptr: cmd,
      19            0 :             _owner: PhantomData,
      20            0 :         }
      21            0 :     }
      22              : }
      23              : 
      24              : #[allow(non_camel_case_types)]
      25            0 : #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
      26              : pub enum MethodAccess {
      27              :     /// No access specifier (or unknown)
      28              :     NONE,
      29              :     /// Private access
      30              :     PRIVATE,
      31              :     /// Protected access
      32              :     PROTECTED,
      33              :     /// Public access
      34              :     PUBLIC,
      35              : 
      36              :     UNKNOWN(u8),
      37              : }
      38              : 
      39              : impl From<u8> for MethodAccess {
      40            0 :     fn from(value: u8) -> Self {
      41            0 :         match value {
      42            0 :             0 => MethodAccess::NONE,
      43            0 :             1 => MethodAccess::PRIVATE,
      44            0 :             2 => MethodAccess::PROTECTED,
      45            0 :             3 => MethodAccess::PUBLIC,
      46            0 :             _ => MethodAccess::UNKNOWN(value),
      47              :         }
      48            0 :     }
      49              : }
      50              : 
      51              : impl From<MethodAccess> for u8 {
      52            0 :     fn from(value: MethodAccess) -> u8 {
      53            0 :         match value {
      54            0 :             MethodAccess::NONE => 0,
      55            0 :             MethodAccess::PRIVATE => 1,
      56            0 :             MethodAccess::PROTECTED => 2,
      57            0 :             MethodAccess::PUBLIC => 3,
      58            0 :             MethodAccess::UNKNOWN(v) => v,
      59              :         }
      60            0 :     }
      61              : }
      62              : 
      63              : #[allow(non_camel_case_types)]
      64            0 : #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
      65              : pub enum MethodType {
      66              :     /// Regular instance method
      67              :     VANILLA,
      68              :     /// Virtual method
      69              :     VIRTUAL,
      70              :     /// Static method
      71              :     STATIC,
      72              :     /// Friend method
      73              :     FRIEND,
      74              :     /// Virtual method that introduces a new vtable slot
      75              :     INTRODUCING_VIRTUAL,
      76              :     /// Pure virtual method (abstract)
      77              :     PURE_VIRTUAL,
      78              :     /// Pure virtual method that introduces a new vtable slot
      79              :     PURE_INTRODUCING_VIRTUAL,
      80              : 
      81              :     UNKNOWN(u32),
      82              : }
      83              : 
      84              : impl From<u32> for MethodType {
      85            0 :     fn from(value: u32) -> Self {
      86            0 :         match value {
      87            0 :             0x00 => MethodType::VANILLA,
      88            0 :             0x01 => MethodType::VIRTUAL,
      89            0 :             0x02 => MethodType::STATIC,
      90            0 :             0x03 => MethodType::FRIEND,
      91            0 :             0x04 => MethodType::INTRODUCING_VIRTUAL,
      92            0 :             0x05 => MethodType::PURE_VIRTUAL,
      93            0 :             0x06 => MethodType::PURE_INTRODUCING_VIRTUAL,
      94            0 :             _ => MethodType::UNKNOWN(value),
      95              :         }
      96            0 :     }
      97              : }
      98              : 
      99              : impl From<MethodType> for u32 {
     100            0 :     fn from(value: MethodType) -> u32 {
     101            0 :         match value {
     102            0 :             MethodType::VANILLA => 0x00,
     103            0 :             MethodType::VIRTUAL => 0x01,
     104            0 :             MethodType::STATIC => 0x02,
     105            0 :             MethodType::FRIEND => 0x03,
     106            0 :             MethodType::INTRODUCING_VIRTUAL => 0x04,
     107            0 :             MethodType::PURE_VIRTUAL => 0x05,
     108            0 :             MethodType::PURE_INTRODUCING_VIRTUAL => 0x06,
     109            0 :             MethodType::UNKNOWN(v) => v,
     110              :         }
     111            0 :     }
     112              : }
     113              : 
     114              : impl Method<'_> {
     115              :     /// Name of the method
     116            0 :     pub fn name(&self) -> String {
     117            0 :         self.ptr.name().to_string()
     118            0 :     }
     119              : 
     120            0 :     pub fn get_type(&self) -> MethodType {
     121            0 :         MethodType::from(self.ptr.get_type())
     122            0 :     }
     123              : 
     124            0 :     pub fn access(&self) -> MethodAccess {
     125            0 :         MethodAccess::from(self.ptr.access())
     126            0 :     }
     127              : 
     128              : }
     129              : 
     130            0 : declare_fwd_iterator!(
     131            0 :     Methods,
     132            0 :     Method<'a>,
     133            0 :     ffi::PDB_types_Method,
     134            0 :     ffi::PDB_types_ClassLike,
     135            0 :     ffi::PDB_types_ClassLike_it_methods
     136            0 : );
     137              : 
     138              : 
        

Generated by: LCOV version 2.1-1