LCOV - code coverage report
Current view: top level - src/dwarf/types - enum_type.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 0.0 % 34 0
Test Date: 2025-10-27:00:00:00 Functions: 0.0 % 8 0

            Line data    Source code
       1              : use lief_ffi as ffi;
       2              : 
       3              : use crate::common::{FromFFI, into_optional};
       4              : use std::marker::PhantomData;
       5              : use crate::dwarf::types::{DwarfType, Type};
       6              : 
       7              : use crate::{declare_fwd_iterator, to_opt};
       8              : 
       9              : /// This structure represents a `DW_TAG_enumeration_type`
      10              : pub struct Enum<'a> {
      11              :     ptr: cxx::UniquePtr<ffi::DWARF_types_Enum>,
      12              :     _owner: PhantomData<&'a ()>,
      13              : }
      14              : 
      15              : impl Enum<'_> {
      16              :     /// Entries associated with this enum
      17            0 :     pub fn entries(&self) -> Entries<'_> {
      18            0 :         Entries::new(self.ptr.entries())
      19            0 :     }
      20              : 
      21              :     /// The underlying type that is used to encode this enum
      22            0 :     pub fn underlying_type(&self) -> Option<Type> {
      23            0 :         into_optional(self.ptr.underlying_type())
      24            0 :     }
      25              : }
      26              : 
      27              : impl FromFFI<ffi::DWARF_types_Enum> for Enum<'_> {
      28            0 :     fn from_ffi(ptr: cxx::UniquePtr<ffi::DWARF_types_Enum>) -> Self {
      29            0 :         Self {
      30            0 :             ptr,
      31            0 :             _owner: PhantomData,
      32            0 :         }
      33            0 :     }
      34              : }
      35              : 
      36              : impl DwarfType for Enum<'_> {
      37            0 :     fn get_base(&self) -> &ffi::DWARF_Type {
      38            0 :         self.ptr.as_ref().unwrap().as_ref()
      39            0 :     }
      40              : }
      41              : 
      42              : 
      43              : /// This struct represents an enum entry which is essentially composed of a name and its value
      44              : /// (integer).
      45              : pub struct Entry<'a> {
      46              :     ptr: cxx::UniquePtr<ffi::DWARF_types_Enum_Entry>,
      47              :     _owner: PhantomData<&'a ()>,
      48              : }
      49              : 
      50              : impl Entry<'_> {
      51              :     /// Enum entry's name
      52            0 :     pub fn name(&self) -> String {
      53            0 :         self.ptr.name().to_string()
      54            0 :     }
      55              : 
      56              :     /// Enum entry's value
      57            0 :     pub fn value(&self) -> Option<i64> {
      58            0 :         to_opt!(&lief_ffi::DWARF_types_Enum_Entry::value, self);
      59            0 :     }
      60              : }
      61              : 
      62              : 
      63              : impl FromFFI<ffi::DWARF_types_Enum_Entry> for Entry<'_> {
      64            0 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::DWARF_types_Enum_Entry>) -> Self {
      65            0 :         Self {
      66            0 :             ptr: cmd,
      67            0 :             _owner: PhantomData,
      68            0 :         }
      69            0 :     }
      70              : }
      71              : 
      72            0 : declare_fwd_iterator!(
      73            0 :     Entries,
      74            0 :     Entry<'a>,
      75            0 :     ffi::DWARF_types_Enum_Entry,
      76            0 :     ffi::DWARF_types_Enum,
      77            0 :     ffi::DWARF_types_Enum_it_entries
      78            0 : );
        

Generated by: LCOV version 2.1-1