Skip to content

Commit

Permalink
chore(elf): add more TODO comments for issue #85
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Mar 10, 2017
1 parent a309ba4 commit b2352d1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
8 changes: 2 additions & 6 deletions elf/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ pub trait Header {
type Word: ElfWord;

/// Attempt to extract an ELF file header from a slice of bytes.
/// TODO: should this be a From impl maybe?
// - eliza, 03/08/2017
/// TODO: rewrite this as a `TryFrom` implementation (see issue #85)
// - eliza, 03/09/2017
fn from_slice<'a>(input: &'a [u8]) -> ElfResult<&'a Self>;

/// Attempt to extract a section header from a slice of bytes.
Expand Down Expand Up @@ -80,10 +80,6 @@ pub trait Header {

}


/// FIXME(style): generate more stuff with macros/use `macro_attr` to derive
/// these...
// - eliza, 03/08/2017
macro_rules! impl_getters {
($(#[$attr:meta])* pub fn $name:ident(&self) -> $ty:ident; $($rest:tt)*) => {
$(#[$attr])* #[inline] pub fn $name(&self) -> $ty { self.$name as $ty }
Expand Down
5 changes: 4 additions & 1 deletion elf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SOS: the Stupid Operating System
// by Eliza Weisman ([email protected])
//
// Copyright (c) 2015-2016 Eliza Weisman
// Copyright (c) 2015-2017 Eliza Weisman
// Released under the terms of the MIT license. See `LICENSE` in the root
// directory of this repository for more information.
//
Expand Down Expand Up @@ -35,6 +35,7 @@ pub type Section<'a> = section::Header<'a>;
/// An ELF header file.
pub type FileHeader<W> = file::HeaderRepr<W>;

/// TODO: should ELF have its own error type?
pub type ElfResult<T> = Result<T, &'static str>;

pub trait ElfWord: Sized + Copy + Clone
Expand Down Expand Up @@ -88,6 +89,8 @@ where Word: ElfWord + 'a

/// if `n` == 0, this will give you an `&[]`. just a warning.
// thanks to Max for making me figure this out.
/// TODO: rewrite this as a `TryFrom` implementation (see issue #85)
// - eliza, 03/09/2017
unsafe fn extract_from_slice<T: Sized>( data: &[u8]
, offset: usize
, n: usize)
Expand Down
2 changes: 1 addition & 1 deletion elf/src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SOS: the Stupid Operating System
// by Eliza Weisman ([email protected])
//
// Copyright (c) 2015-2016 Eliza Weisman
// Copyright (c) 2015-2017 Eliza Weisman
// Released under the terms of the MIT license. See `LICENSE` in the root
// directory of this repository for more information.
//
Expand Down
2 changes: 2 additions & 0 deletions elf/src/section.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ pub enum Contents<'a> {
struct TypeRepr(u32);

impl TypeRepr {
/// TODO: rewrite this as a `TryFrom` implementation (see issue #85)
// - eliza, 03/09/2017
#[inline] fn as_type(&self) -> ElfResult<Type> {
match self.0 {
0 => Ok(Type::Null)
Expand Down

0 comments on commit b2352d1

Please sign in to comment.