Reorganize package structure

Former-commit-id: d7ad26c07fc7063522fae061577f7ceece797ae5
This commit is contained in:
Michel Heily 2019-06-30 22:31:16 +03:00
parent bd053354cb
commit 22c175d9cc
4 changed files with 37 additions and 34 deletions

View file

@ -1,36 +1,17 @@
use std::fs::File;
use std::io;
use std::io::prelude::*;
#[macro_use]
extern crate enum_primitive_derive;
extern crate num_traits;
extern crate bit;
extern crate byteorder;
#[macro_use]
extern crate clap;
use clap::{App, ArgMatches};
extern crate rustyline;
extern crate rustboyadvance_ng;
extern crate nom;
extern crate colored; // not needed in Rust 2018
extern crate ansi_term;
pub mod sysbus;
use sysbus::SysBus;
mod arm7tdmi;
mod debugger;
use debugger::{Debugger, DebuggerError};
mod disass;
use disass::Disassembler;
use rustboyadvance_ng::arm7tdmi;
use rustboyadvance_ng::sysbus::SysBus;
use rustboyadvance_ng::debugger::{Debugger, DebuggerError};
use rustboyadvance_ng::disass::Disassembler;
use rustboyadvance_ng::util::read_bin_file;
#[derive(Debug)]
pub enum GBAError {
@ -66,14 +47,6 @@ impl From<DebuggerError> for GBAError {
}
}
fn read_bin_file(filename: &str) -> GBAResult<Vec<u8>> {
let mut buf = Vec::new();
let mut file = File::open(filename)?;
file.read_to_end(&mut buf)?;
Ok(buf)
}
fn run_disass(matches: &ArgMatches) -> GBAResult<()> {
let input = matches.value_of("INPUT").unwrap();
let bin = read_bin_file(&input)?;

20
src/lib.rs Normal file
View file

@ -0,0 +1,20 @@
#[macro_use]
extern crate enum_primitive_derive;
extern crate num_traits;
extern crate bit;
extern crate byteorder;
extern crate rustyline;
extern crate nom;
extern crate colored; // not needed in Rust 2018
extern crate ansi_term;
pub mod sysbus;
pub mod arm7tdmi;
pub mod debugger;
pub mod disass;
pub mod util;

10
src/util.rs Normal file
View file

@ -0,0 +1,10 @@
use std::fs::File;
use std::io;
use std::io::prelude::*;
pub fn read_bin_file(filename: &str) -> io::Result<Vec<u8>> {
let mut buf = Vec::new();
let mut file = File::open(filename)?;
file.read_to_end(&mut buf)?;
Ok(buf)
}