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 % 37 0
Test Date: 2025-11-12:00:00:00 Functions: 0.0 % 9 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              :     /// Try to find the enum entry matching the given value
      27            0 :     pub fn entry_by_value(&self, value: i64) -> Option<Entry<'_>> {
      28            0 :         into_optional(self.ptr.find_entry(value))
      29            0 :     }
      30              : }
      31              : 
      32              : impl FromFFI<ffi::DWARF_types_Enum> for Enum<'_> {
      33            0 :     fn from_ffi(ptr: cxx::UniquePtr<ffi::DWARF_types_Enum>) -> Self {
      34            0 :         Self {
      35            0 :             ptr,
      36            0 :             _owner: PhantomData,
      37            0 :         }
      38            0 :     }
      39              : }
      40              : 
      41              : impl DwarfType for Enum<'_> {
      42            0 :     fn get_base(&self) -> &ffi::DWARF_Type {
      43            0 :         self.ptr.as_ref().unwrap().as_ref()
      44            0 :     }
      45              : }
      46              : 
      47              : 
      48              : /// This struct represents an enum entry which is essentially composed of a name and its value
      49              : /// (integer).
      50              : pub struct Entry<'a> {
      51              :     ptr: cxx::UniquePtr<ffi::DWARF_types_Enum_Entry>,
      52              :     _owner: PhantomData<&'a ()>,
      53              : }
      54              : 
      55              : impl Entry<'_> {
      56              :     /// Enum entry's name
      57            0 :     pub fn name(&self) -> String {
      58            0 :         self.ptr.name().to_string()
      59            0 :     }
      60              : 
      61              :     /// Enum entry's value
      62            0 :     pub fn value(&self) -> Option<i64> {
      63            0 :         to_opt!(&lief_ffi::DWARF_types_Enum_Entry::value, self);
      64            0 :     }
      65              : }
      66              : 
      67              : 
      68              : impl FromFFI<ffi::DWARF_types_Enum_Entry> for Entry<'_> {
      69            0 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::DWARF_types_Enum_Entry>) -> Self {
      70            0 :         Self {
      71            0 :             ptr: cmd,
      72            0 :             _owner: PhantomData,
      73            0 :         }
      74            0 :     }
      75              : }
      76              : 
      77            0 : declare_fwd_iterator!(
      78            0 :     Entries,
      79            0 :     Entry<'a>,
      80            0 :     ffi::DWARF_types_Enum_Entry,
      81            0 :     ffi::DWARF_types_Enum,
      82            0 :     ffi::DWARF_types_Enum_it_entries
      83            0 : );
        

Generated by: LCOV version 2.1-1