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

Generated by: LCOV version 2.1-1