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::pdb::types::PdbType;
6 : use super::Type;
7 : use crate::declare_fwd_iterator;
8 :
9 : /// This structure wraps a `LF_PROCEDURE` PDB type
10 : pub struct Function<'a> {
11 : ptr: cxx::UniquePtr<ffi::PDB_types_Function>,
12 : _owner: PhantomData<&'a ()>,
13 : }
14 :
15 : impl FromFFI<ffi::PDB_types_Function> for Function<'_> {
16 0 : fn from_ffi(cmd: cxx::UniquePtr<ffi::PDB_types_Function>) -> Self {
17 0 : Self {
18 0 : ptr: cmd,
19 0 : _owner: PhantomData,
20 0 : }
21 0 : }
22 : }
23 :
24 : impl Function<'_> {
25 : /// [`Type`] returned by the function
26 0 : pub fn return_type(&self) -> Option<Type<'_>> {
27 0 : into_optional(self.ptr.return_type())
28 0 : }
29 :
30 : /// [`Type`] of the function's parameters
31 0 : pub fn parameters(&self) -> ParametersIt<'_> {
32 0 : ParametersIt::new(self.ptr.parameters())
33 0 : }
34 : }
35 :
36 : impl PdbType for Function<'_> {
37 0 : fn get_base(&self) -> &ffi::PDB_Type {
38 0 : self.ptr.as_ref().unwrap().as_ref()
39 0 : }
40 : }
41 :
42 0 : declare_fwd_iterator!(
43 0 : ParametersIt,
44 0 : Type<'a>,
45 0 : ffi::PDB_Type,
46 0 : ffi::PDB_types_Function,
47 0 : ffi::PDB_types_Function_it_parameters
48 0 : );
|