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 : use crate::declare_fwd_iterator;
7 : use crate::dwarf::Parameters;
8 :
9 : /// This structure represents a `DW_TAG_subroutine_type`
10 : pub struct Subroutine<'a> {
11 : ptr: cxx::UniquePtr<ffi::DWARF_types_Subroutine>,
12 : _owner: PhantomData<&'a ()>,
13 : }
14 :
15 : impl FromFFI<ffi::DWARF_types_Subroutine> for Subroutine<'_> {
16 0 : fn from_ffi(ptr: cxx::UniquePtr<ffi::DWARF_types_Subroutine>) -> Self {
17 0 : Self {
18 0 : ptr,
19 0 : _owner: PhantomData,
20 0 : }
21 0 : }
22 : }
23 :
24 : impl DwarfType for Subroutine<'_> {
25 0 : fn get_base(&self) -> &ffi::DWARF_Type {
26 0 : self.ptr.as_ref().unwrap().as_ref()
27 0 : }
28 : }
29 :
30 : impl Subroutine<'_> {
31 : /// [`Parameters`] of this subroutine
32 0 : pub fn parameters(&self) -> ParametersIt {
33 0 : ParametersIt::new(self.ptr.parameters())
34 0 : }
35 : }
36 :
37 0 : declare_fwd_iterator!(
38 0 : ParametersIt,
39 0 : Parameters<'a>,
40 0 : ffi::DWARF_Parameter,
41 0 : ffi::DWARF_types_Subroutine,
42 0 : ffi::DWARF_types_Subroutine_it_parameters
43 0 : );
|