more doc revisions

This commit is contained in:
lifning 2021-11-02 00:32:53 -07:00
parent 725a5d8f03
commit c94400f1b6
8 changed files with 15 additions and 146 deletions

View File

@ -1,103 +0,0 @@
use std::cell::RefCell;
use std::os::raw::c_uint;
use std::rc::Rc;
use std::path::PathBuf;
use crate::prelude::*;
use crate::retro::ffi::*;
impl<T: RetroCallbacks> RetroCallbacks for Rc<RefCell<T>> {
fn video_refresh(&mut self, frame: &VideoFrame) {
RefCell::borrow_mut(self).video_refresh(frame)
}
fn audio_samples(&mut self, stereo_pcm: &[i16]) -> usize {
RefCell::borrow_mut(self).audio_samples(stereo_pcm)
}
fn input_poll(&mut self) {
RefCell::borrow_mut(self).input_poll()
}
fn input_state(&mut self, port: u32, device: InputDeviceId, index: InputIndex) -> i16 {
RefCell::borrow_mut(self).input_state(port, device, index)
}
fn set_rotation(&mut self, rotation: EnvRotation) -> Option<bool> {
RefCell::borrow_mut(self).set_rotation(rotation)
}
fn get_overscan(&mut self) -> Option<bool> {
RefCell::borrow_mut(self).get_overscan()
}
fn set_message(&mut self, message: &Message) -> Option<bool> {
RefCell::borrow_mut(self).set_message(message)
}
fn shutdown(&mut self) -> Option<bool> {
RefCell::borrow_mut(self).shutdown()
}
fn set_performance_level(&mut self, level: c_uint) -> Option<bool> {
RefCell::borrow_mut(self).set_performance_level(level)
}
fn get_system_directory(&mut self) -> Option<PathBuf> {
RefCell::borrow_mut(self).get_system_directory()
}
fn set_pixel_format(&mut self, format: PixelFormat) -> Option<bool> {
RefCell::borrow_mut(self).set_pixel_format(format)
}
fn set_input_descriptors(&mut self, input_descriptors: &Vec<InputDescriptor2>) -> Option<bool> {
RefCell::borrow_mut(self).set_input_descriptors(input_descriptors)
}
fn set_hw_render(&mut self, hw_render_callback: &HwRenderCallback) -> Option<bool> {
RefCell::borrow_mut(self).set_hw_render(hw_render_callback)
}
fn get_variable(&mut self, key: &str) -> Option<String> {
RefCell::borrow_mut(self).get_variable(key)
}
fn set_variables(&mut self, variables: &Vec<Variable2>) -> Option<bool> {
RefCell::borrow_mut(self).set_variables(variables)
}
fn get_variable_update(&mut self) -> Option<bool> {
RefCell::borrow_mut(self).get_variable_update()
}
fn set_support_no_game(&mut self, supports_no_game: bool) -> Option<bool> {
RefCell::borrow_mut(self).set_support_no_game(supports_no_game)
}
fn get_libretro_path(&mut self) -> Option<PathBuf> {
RefCell::borrow_mut(self).get_libretro_path()
}
fn get_input_device_capabilities(&mut self) -> Option<u64> {
RefCell::borrow_mut(self).get_input_device_capabilities()
}
fn get_core_assets_directory(&mut self) -> Option<PathBuf> {
RefCell::borrow_mut(self).get_core_assets_directory()
}
fn get_save_directory(&mut self) -> Option<PathBuf> {
RefCell::borrow_mut(self).get_save_directory()
}
fn set_system_av_info(&mut self, system_av_info: &SystemAvInfo) -> Option<bool> {
RefCell::borrow_mut(self).set_system_av_info(system_av_info)
}
fn set_subsystem_info(&mut self, subsystem_info: &Vec<SubsystemInfo2>) -> Option<bool> {
RefCell::borrow_mut(self).set_subsystem_info(subsystem_info)
}
fn set_controller_info(&mut self, controller_info: &Vec<ControllerDescription2>) -> Option<bool> {
RefCell::borrow_mut(self).set_controller_info(controller_info)
}
fn set_memory_maps(&mut self, memory_map: &MemoryMap) -> Option<bool> {
RefCell::borrow_mut(self).set_memory_maps(memory_map)
}
fn set_geometry(&mut self, game_geometry: &GameGeometry) -> Option<bool> {
RefCell::borrow_mut(self).set_geometry(game_geometry)
}
fn get_username(&mut self) -> Option<String> {
RefCell::borrow_mut(self).get_username()
}
fn get_language(&mut self) -> Option<Language> {
RefCell::borrow_mut(self).get_language()
}
fn hw_get_current_framebuffer(&mut self) -> Option<usize> {
RefCell::borrow_mut(self).hw_get_current_framebuffer()
}
fn hw_get_proc_address(&mut self, sym: &str) -> Option<*const ()> {
RefCell::borrow_mut(self).hw_get_proc_address(sym)
}
// TODO: the rest, dynamically.
// can we proc macro it?
// 's~^\( *\)fn \(.*\)(&mut self\(, \)\?\([^)]*\))\(.*\){$~\1fn \2(\&mut self\3\4)\5{\n\1 RefCell::borrow_mut(self).\2(\4)~'
}

View File

@ -8,5 +8,3 @@ pub mod prelude {
pub use crate::retro::wrapper::{RetroCallbacks, LibretroWrapper, LibretroWrapperAccess};
pub use crate::retro::ffi::{PixelFormat, GameGeometry, HwContextResetFn, HwRenderCallback, SystemAvInfo, SystemInfo};
}
mod dynamic_borrow;

View File

@ -1,3 +1,7 @@
//! Implementation of the [component system](RetroComponentBase)
//! and declaration of the [component trait](RetroComponent)
//! for composable subsets of [RetroCallbacks] implementations.
use crate::prelude::*;
use ferretro_base::retro::ffi::*;
use std::any::{Any, TypeId};
@ -255,6 +259,9 @@ impl RetroCallbacks for RetroComponentBase {
.unwrap_or_default()
}
// TODO: for this, set_pixel_format, and other mutation-themed calls returning Option<bool>,
// if any include both Some(false) and Some(true), then re-run with the previous value
// assumed to be supported by all components (to signal to true-returners to revert).
fn set_rotation(&mut self, rotation: EnvRotation) -> Option<bool> {
self.components.iter_mut()
.map(|comp| comp.set_rotation(rotation))

View File

@ -1,33 +0,0 @@
use std::cell::RefCell;
use std::rc::Rc;
use std::path::Path;
use crate::base::ControlFlow;
use crate::base::RetroComponent;
use crate::base::Result;
use ferretro_base::prelude::*;
impl<T> RetroComponent for Rc<RefCell<T>> where
T: RetroComponent,
Rc<RefCell<T>>: RetroCallbacks,
{
fn pre_init(&mut self, retro: &mut LibretroWrapper) -> Result<()> {
RefCell::try_borrow_mut(self)?.pre_init(retro)
}
fn post_init(&mut self, retro: &mut LibretroWrapper) -> Result<()> {
RefCell::try_borrow_mut(self)?.post_init(retro)
}
fn pre_load_game(&mut self, retro: &mut LibretroWrapper, rom: &Path) -> Result<()> {
RefCell::try_borrow_mut(self)?.pre_load_game(retro, rom)
}
fn post_load_game(&mut self, retro: &mut LibretroWrapper, rom: &Path) -> Result<()> {
RefCell::try_borrow_mut(self)?.post_load_game(retro, rom)
}
fn pre_run(&mut self, retro: &mut LibretroWrapper) -> ControlFlow {
RefCell::borrow_mut(self).pre_run(retro)
}
fn post_run(&mut self, retro: &mut LibretroWrapper) -> ControlFlow {
RefCell::borrow_mut(self).post_run(retro)
}
}

View File

@ -2,11 +2,10 @@ pub mod provided;
pub mod base;
pub mod prelude {
//! Re-exports for types likely to be used by consumers of the crate.
pub use crate::base::{RetroComponent, RetroComponentBase};
pub use ferretro_base::retro::constants::*;
pub use ferretro_base::retro::wrapped_types::*;
pub use ferretro_base::retro::wrapper::{RetroCallbacks, LibretroWrapper, LibretroWrapperAccess};
pub use ferretro_base::retro::ffi::{PixelFormat, GameGeometry, HwContextResetFn, HwRenderCallback, SystemAvInfo, SystemInfo, MemoryMap};
}
mod dynamic_borrow;

View File

@ -1,3 +1,5 @@
//! (Experimental) support for recording a core's video and audio output to an encoded video file.
extern crate ffmpeg_next as ffmpeg;
use std::collections::VecDeque;

View File

@ -1,3 +1,5 @@
//! Implementations of [RetroComponent](crate::base::RetroComponent) for common emulator use-cases.
#[cfg(feature = "ffmpeg_comp")]
pub mod ffmpeg;

View File

@ -35,10 +35,9 @@ impl RetroCallbacks for PathBufComponent {
}
/// Write's the core's own log statements to stderr.
///
/// The public member [Self::prefix] may be set to add a prefix to each logged line.
#[derive(Default)]
pub struct StderrLogComponent {
/// May be set to add a prefix to each logged line.
pub prefix: String,
}
@ -51,10 +50,9 @@ impl RetroCallbacks for StderrLogComponent {
/// Writes all the input descriptors, variables, and subsystem information to stderr as they are
/// provided by the core.
///
/// The public member [Self::prefix] may be set to add a prefix to each logged line.
#[derive(Default)]
pub struct StderrSysInfoLogComponent {
/// May be set to add a prefix to each logged line.
pub prefix: String,
}
@ -83,10 +81,9 @@ impl RetroCallbacks for StderrSysInfoLogComponent {
}
/// Trace-logs every callback call made and their arguments to stderr.
///
/// The public member [Self::prefix] may be set to add a prefix to each logged line.
#[derive(Default)]
pub struct StderrCallTraceComponent {
/// May be set to add a prefix to each logged line.
pub prefix: String,
}