From 9644aa9b95bde5bd93a141629ac64daf676b862e Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Sat, 9 Dec 2023 00:26:21 +0100 Subject: [PATCH] Formatted --- crates/goblin-pyo3/src/exports.rs | 51 ++++++++++++++----------------- crates/goblin-pyo3/src/lib.rs | 10 +++--- crates/goblin-pyo3/src/symbols.rs | 2 +- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/crates/goblin-pyo3/src/exports.rs b/crates/goblin-pyo3/src/exports.rs index d4e7038..8149fa1 100644 --- a/crates/goblin-pyo3/src/exports.rs +++ b/crates/goblin-pyo3/src/exports.rs @@ -6,7 +6,7 @@ enum ExportTyp { #[default] Regular, Reexport, - Stub + Stub, } #[pymethods] @@ -39,32 +39,28 @@ impl From> for ExportInfo { fn from(info: goblin::mach::exports::ExportInfo) -> Self { use goblin::mach::exports::ExportInfo::*; match info { - Regular { address, flags } => { - Self { - typ: ExportTyp::Regular, - address, - flags, - .. Default::default() - } - } - Reexport { lib, lib_symbol_name, flags } => { - Self { - typ: ExportTyp::Reexport, - lib: Some(lib.to_string()), - lib_symbol_name: lib_symbol_name.map(|s| s.to_string()), - flags, - .. Default::default() - } - } - Stub { - flags, .. - } => { - Self { - typ: ExportTyp::Stub, - flags, - .. Default::default() - } - } + Regular { address, flags } => Self { + typ: ExportTyp::Regular, + address, + flags, + ..Default::default() + }, + Reexport { + lib, + lib_symbol_name, + flags, + } => Self { + typ: ExportTyp::Reexport, + lib: Some(lib.to_string()), + lib_symbol_name: lib_symbol_name.map(|s| s.to_string()), + flags, + ..Default::default() + }, + Stub { flags, .. } => Self { + typ: ExportTyp::Stub, + flags, + ..Default::default() + }, } } } @@ -99,4 +95,3 @@ impl From> for Export { } } } - diff --git a/crates/goblin-pyo3/src/lib.rs b/crates/goblin-pyo3/src/lib.rs index 7fe3feb..a1a9974 100644 --- a/crates/goblin-pyo3/src/lib.rs +++ b/crates/goblin-pyo3/src/lib.rs @@ -1,4 +1,7 @@ -use std::{fs::{File, self}, io::Read}; +use std::{ + fs::{self, File}, + io::Read, +}; use goblin::mach::Mach; use pyo3::{exceptions::PyTypeError, prelude::*}; @@ -12,7 +15,7 @@ mod symbols; use exports::Export; use header::Header; use imports::Import; -use sections::{Sections, Section}; +use sections::{Section, Sections}; use symbols::Symbols; #[pyclass] @@ -85,11 +88,10 @@ impl Object { sections.extend(sect_iter.map(|section| { let (sect, _data) = section.unwrap(); Section::from(sect) - })); } Sections { sections } - }, + } _ => unimplemented!(), } } diff --git a/crates/goblin-pyo3/src/symbols.rs b/crates/goblin-pyo3/src/symbols.rs index c5e5cde..ff6b0ee 100644 --- a/crates/goblin-pyo3/src/symbols.rs +++ b/crates/goblin-pyo3/src/symbols.rs @@ -1,4 +1,4 @@ -use goblin::mach::symbols::{N_TYPE, n_type_to_str, N_EXT, N_WEAK_REF, N_WEAK_DEF, N_UNDF, N_STAB}; +use goblin::mach::symbols::{n_type_to_str, N_EXT, N_STAB, N_TYPE, N_UNDF, N_WEAK_DEF, N_WEAK_REF}; use pyo3::prelude::*; #[derive(Debug, Clone)]