reorganize files

This commit is contained in:
lif 2019-11-14 19:16:44 -08:00
parent b5b5a1041a
commit 6668c9c11f
8 changed files with 20 additions and 17 deletions

View File

@ -10,3 +10,4 @@ failure = "^0.1"
libloading = "^0.5" libloading = "^0.5"
num_enum = "^0.4" num_enum = "^0.4"
structopt = "^0.3" structopt = "^0.3"

View File

@ -1,21 +1,14 @@
extern crate failure; extern crate rustro;
extern crate libloading;
#[allow(non_camel_case_types, non_upper_case_globals, non_snake_case, dead_code)]
mod libretro_ffi;
mod libretro_loading;
mod libretro_convert;
mod libretro_wrapper;
use std::ffi::CStr; use std::ffi::CStr;
use std::path::PathBuf; use std::path::PathBuf;
use structopt::StructOpt; use structopt::StructOpt;
use crate::libretro_convert::Handler; use rustro::retro;
struct Foo; struct Foo;
impl Handler for Foo { impl retro::convert::Handler for Foo {
fn video_refresh(&mut self, data: &[u8], width: u32, height: u32, pitch: u32) { fn video_refresh(&mut self, data: &[u8], width: u32, height: u32, pitch: u32) {
println!("video_refresh {}x{}", width, height); println!("video_refresh {}x{}", width, height);
} }
@ -35,8 +28,8 @@ struct Opt {
fn main() -> failure::Fallible<()> { fn main() -> failure::Fallible<()> {
let opt: Opt = Opt::from_args(); let opt: Opt = Opt::from_args();
let lib = libloading::Library::new(&opt.core)?; let lib = libloading::Library::new(&opt.core)?;
let retro = libretro_loading::LibretroApi::from_library(&lib)?; let retro = retro::loading::LibretroApi::from_library(&lib)?;
let wrapper = libretro_wrapper::LibretroWrapper::from(retro); let wrapper = retro::wrapper::LibretroWrapper::from(retro);
let mut foo = Foo{}; let mut foo = Foo{};
wrapper.register_handler(&mut foo); wrapper.register_handler(&mut foo);
println!("api version: {}", wrapper.as_ref().api_version()); println!("api version: {}", wrapper.as_ref().api_version());

4
src/lib.rs Normal file
View File

@ -0,0 +1,4 @@
extern crate failure;
extern crate libloading;
pub mod retro;

View File

@ -4,7 +4,7 @@ use std::path::PathBuf;
use num_enum::{TryFromPrimitive, IntoPrimitive}; use num_enum::{TryFromPrimitive, IntoPrimitive};
use crate::libretro_ffi::*; use super::ffi::*;
// NB: commented-out stuff is from newer versions of libretro.h not yet represented in libretro-sys // NB: commented-out stuff is from newer versions of libretro.h not yet represented in libretro-sys

View File

@ -5,8 +5,8 @@ use std::path::Path;
use failure::Fallible; use failure::Fallible;
use libloading; use libloading;
use crate::libretro_ffi::*; use super::ffi::*;
use crate::libretro_convert::*; use super::convert::*;
pub struct LibretroApi<'a> { pub struct LibretroApi<'a> {
lib: &'a libloading::Library, // for tying our lifetime to its own lib: &'a libloading::Library, // for tying our lifetime to its own

5
src/retro/mod.rs Normal file
View File

@ -0,0 +1,5 @@
pub mod convert;
#[allow(non_camel_case_types, non_upper_case_globals, non_snake_case, dead_code)]
pub mod ffi;
pub mod loading;
pub mod wrapper;

View File

@ -9,8 +9,8 @@ use std::path::Path;
use libretro_sys::{Message, PixelFormat, SystemAvInfo, GameGeometry}; use libretro_sys::{Message, PixelFormat, SystemAvInfo, GameGeometry};
use num_enum::{IntoPrimitive, TryFromPrimitive}; use num_enum::{IntoPrimitive, TryFromPrimitive};
use crate::libretro_convert::*; use super::convert::*;
use crate::libretro_loading::*; use super::loading::*;
static mut CB_SINGLETON: StaticCallbacks = StaticCallbacks { static mut CB_SINGLETON: StaticCallbacks = StaticCallbacks {
handler: None, handler: None,