Skip to content

Commit

Permalink
chore: actually rename AssetParser -> Parser.
Browse files Browse the repository at this point in the history
chore: make `asset::pack_info` public.
  • Loading branch information
UserIsntAvailable committed Oct 15, 2024
1 parent fa20872 commit 3486a6c
Show file tree
Hide file tree
Showing 22 changed files with 70 additions and 70 deletions.
8 changes: 4 additions & 4 deletions ashen/src/asset/color_map.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::ops::Deref;

use super::AssetParser;
use super::Parser;
use crate::{error, utils::nom::*};

const COLORS_COUNT: usize = 256;
Expand Down Expand Up @@ -35,7 +35,7 @@ impl Color {
}
}

impl AssetParser for Color {
impl Parser for Color {
type Output = Self;

type Context<'ctx> = ();
Expand All @@ -55,7 +55,7 @@ pub struct ColorMap {
pub shades: Box<[[Color; COLORS_COUNT]; SHADES_COUNT]>,
}

impl AssetParser for ColorMap {
impl Parser for ColorMap {
type Output = Self;

type Context<'ctx> = ();
Expand Down Expand Up @@ -155,7 +155,7 @@ mod tests {
#[test]
#[ignore = "uses Ashen ROM files"]
fn parse_rom_asset() -> eyre::Result<()> {
let (_, color_map) = <ColorMap as AssetParser>::parser(())(&COLOR_MAP_DATA)?;
let (_, color_map) = ColorMap::parser(())(&COLOR_MAP_DATA)?;

output_file(
parsed_file_path!("color-map/monsters.png"),
Expand Down
6 changes: 3 additions & 3 deletions ashen/src/asset/gamma_table.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::mem;

use super::AssetParser;
use super::Parser;
use crate::{error, utils::nom::*};

const ROWS_COUNT: usize = 256;
Expand All @@ -12,7 +12,7 @@ pub struct GammaTable {
pub lookups: Box<[[u8; ROWS_COUNT]; COLS_COUNT]>,
}

impl AssetParser for GammaTable {
impl Parser for GammaTable {
type Output = Self;

type Context<'ctx> = ();
Expand Down Expand Up @@ -61,7 +61,7 @@ mod tests {
#[test]
#[ignore = "uses Ashen ROM files"]
fn parse_rom_asset() -> eyre::Result<()> {
let (_, gamma_table) = <GammaTable as AssetParser>::parser(())(&GAMMA_TABLE_DATA)?;
let (_, gamma_table) = GammaTable::parser(())(&GAMMA_TABLE_DATA)?;

let gamma_table = gamma_table
.lookups
Expand Down
4 changes: 2 additions & 2 deletions ashen/src/asset/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ pub mod color_map;
pub mod gamma_table;
pub mod model;
pub mod pack_file;
mod pack_info;
pub mod pack_info;
pub mod skybox;
pub mod sound;
pub mod string_table;
pub mod texture;

use crate::utils::nom::{Input, Result};

pub trait AssetParser
pub trait Parser
where
Self: Sized,
{
Expand Down
8 changes: 4 additions & 4 deletions ashen/src/asset/model/dat/frame.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{asset::AssetParser, utils::nom::*};
use crate::{asset::Parser, utils::nom::*};

// TODO(nenikitov): Should probably be a fancy utility class
// With generics for data type and dimension
Expand All @@ -9,7 +9,7 @@ pub struct Vec3 {
pub z: f32,
}

impl AssetParser for Vec3 {
impl Parser for Vec3 {
type Output = Self;

type Context<'ctx> = ();
Expand Down Expand Up @@ -49,7 +49,7 @@ pub struct VertexTransform {
origin: Vec3,
}

impl AssetParser for ModelVertex {
impl Parser for ModelVertex {
type Output = Self;

type Context<'ctx> = VertexTransform;
Expand Down Expand Up @@ -94,7 +94,7 @@ pub struct ModelSpecs {
pub frame_size: u32,
}

impl AssetParser for ModelFrame {
impl Parser for ModelFrame {
type Output = Self;

type Context<'ctx> = ModelSpecs;
Expand Down
4 changes: 2 additions & 2 deletions ashen/src/asset/model/dat/header.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{asset::AssetParser, utils::nom::*};
use crate::{asset::Parser, utils::nom::*};

pub struct ModelHeader {
pub triangle_count: u32,
Expand All @@ -15,7 +15,7 @@ pub struct ModelHeader {
pub locator_nodes: [u8; 16],
}

impl AssetParser for ModelHeader {
impl Parser for ModelHeader {
type Output = Self;

type Context<'ctx> = ();
Expand Down
4 changes: 2 additions & 2 deletions ashen/src/asset/model/dat/sequence.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::{asset::AssetParser, utils::nom::*};
use crate::{asset::Parser, utils::nom::*};

pub struct ModelSequence {
pub frames: Vec<u32>,
}

impl AssetParser for ModelSequence {
impl Parser for ModelSequence {
type Output = Self;

// TODO(nenikitov): Maybe refactor it to not accept full input.
Expand Down
6 changes: 3 additions & 3 deletions ashen/src/asset/model/dat/triangle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{asset::AssetParser, utils::nom::*};
use crate::{asset::Parser, utils::nom::*};

pub struct ModelPoint {
pub vertex_index: u16,
Expand All @@ -11,7 +11,7 @@ pub struct TextureDimensions {
pub height: u32,
}

impl AssetParser for ModelPoint {
impl Parser for ModelPoint {
type Output = Self;

type Context<'ctx> = &'ctx TextureDimensions;
Expand All @@ -36,7 +36,7 @@ pub struct ModelTriangle {
pub points: [ModelPoint; 3],
}

impl AssetParser for ModelTriangle {
impl Parser for ModelTriangle {
type Output = Self;

type Context<'ctx> = TextureDimensions;
Expand Down
8 changes: 4 additions & 4 deletions ashen/src/asset/model/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use dat::{

use super::{
texture::{Texture, TextureSize},
AssetParser,
Parser,
};
use crate::utils::nom::*;

Expand All @@ -20,7 +20,7 @@ pub struct Model {
pub frames: Vec<ModelFrame>,
}

impl AssetParser for Model {
impl Parser for Model {
type Output = Self;

type Context<'ctx> = ();
Expand Down Expand Up @@ -94,9 +94,9 @@ mod tests {
#[test]
#[ignore = "uses Ashen ROM files"]
fn parse_rom_asset() -> eyre::Result<()> {
let (_, model) = <Model as AssetParser>::parser(())(&MODEL_DATA)?;
let (_, model) = Model::parser(())(&MODEL_DATA)?;
let palette = {
let (_, color_map) = <ColorMap as AssetParser>::parser(())(&COLOR_MAP_DATA)?;
let (_, color_map) = ColorMap::parser(())(&COLOR_MAP_DATA)?;
color_map.shades[15]
};

Expand Down
4 changes: 2 additions & 2 deletions ashen/src/asset/pack_info.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::ops::Index;

use super::AssetParser;
use super::Parser;
use crate::utils::nom::*;

#[derive(Debug)]
Expand All @@ -9,7 +9,7 @@ pub struct PackInfo {
pub size: u32,
}

impl AssetParser for PackInfo {
impl Parser for PackInfo {
type Output = Self;

type Context<'ctx> = ();
Expand Down
6 changes: 3 additions & 3 deletions ashen/src/asset/skybox.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{
texture::{Texture, TextureSize},
AssetParser,
Parser,
};
use crate::{asset::color_map::Color, utils::nom::*};

Expand All @@ -11,7 +11,7 @@ pub struct Skybox {
pub texture: Texture,
}

impl AssetParser for Skybox {
impl Parser for Skybox {
type Output = Self;

type Context<'ctx> = ();
Expand Down Expand Up @@ -50,7 +50,7 @@ mod tests {
#[test]
#[ignore = "uses Ashen ROM files"]
fn parse_rom_asset() -> eyre::Result<()> {
let (_, skybox) = <Skybox as AssetParser>::parser(())(&SKYBOX_DATA)?;
let (_, skybox) = Skybox::parser(())(&SKYBOX_DATA)?;

output_file(
parsed_file_path!("skyboxes/level-1.png"),
Expand Down
4 changes: 2 additions & 2 deletions ashen/src/asset/sound/dat/asset_header.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
asset::{pack_info::PackInfo, AssetParser},
asset::{pack_info::PackInfo, Parser},
utils::nom::*,
};

Expand All @@ -14,7 +14,7 @@ impl SoundAssetHeader {
const HEADER: &'static str = "TSND";
}

impl AssetParser for SoundAssetHeader {
impl Parser for SoundAssetHeader {
type Output = Self;

type Context<'ctx> = ();
Expand Down
4 changes: 2 additions & 2 deletions ashen/src/asset/sound/dat/chunk_header.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use crate::{
asset::{pack_info::PackInfo, AssetParser},
asset::{pack_info::PackInfo, Parser},
utils::nom::*,
};

pub struct SoundChunkHeader {
pub infos: Vec<PackInfo>,
}

impl AssetParser for SoundChunkHeader {
impl Parser for SoundChunkHeader {
type Output = Self;

type Context<'ctx> = ();
Expand Down
4 changes: 2 additions & 2 deletions ashen/src/asset/sound/dat/pattern_effect.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{convert_volume, finetune::FineTune};
use crate::{asset::AssetParser, utils::nom::*};
use crate::{asset::Parser, utils::nom::*};

#[derive(Debug, Clone, Copy)]
pub enum Speed {
Expand Down Expand Up @@ -127,7 +127,7 @@ impl PatternEffect {
}
}

impl AssetParser for Option<PatternEffect> {
impl Parser for Option<PatternEffect> {
type Output = Self;

type Context<'ctx> = bool;
Expand Down
12 changes: 6 additions & 6 deletions ashen/src/asset/sound/dat/pattern_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::rc::Rc;
use bitflags::bitflags;

use super::{convert_volume, finetune::FineTune, pattern_effect::PatternEffect, t_instrument::*};
use crate::{asset::AssetParser, utils::nom::*};
use crate::{asset::Parser, utils::nom::*};

#[derive(Default, PartialEq, Clone, Copy, Debug)]
pub enum PatternEventNote {
Expand All @@ -12,7 +12,7 @@ pub enum PatternEventNote {
On(FineTune),
}

impl AssetParser for Option<PatternEventNote> {
impl Parser for Option<PatternEventNote> {
type Output = Self;

type Context<'ctx> = bool;
Expand Down Expand Up @@ -48,7 +48,7 @@ bitflags! {
}
}

impl AssetParser for PatternEventFlags {
impl Parser for PatternEventFlags {
type Output = Self;

type Context<'ctx> = ();
Expand All @@ -68,7 +68,7 @@ impl AssetParser for PatternEventFlags {
}
}

impl AssetParser for Option<PatternEventInstrument> {
impl Parser for Option<PatternEventInstrument> {
type Output = Self;

type Context<'ctx> = (bool, &'ctx [Rc<TInstrument>]);
Expand Down Expand Up @@ -102,7 +102,7 @@ impl Default for PatternEventVolume {
}
}

impl AssetParser for Option<PatternEventVolume> {
impl Parser for Option<PatternEventVolume> {
type Output = Self;

type Context<'ctx> = bool;
Expand Down Expand Up @@ -149,7 +149,7 @@ impl PatternEvent {
}
}

impl AssetParser for PatternEvent {
impl Parser for PatternEvent {
type Output = Self;

type Context<'ctx> = &'ctx [Rc<TInstrument>];
Expand Down
6 changes: 3 additions & 3 deletions ashen/src/asset/sound/dat/t_effect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use super::{
uncompress,
};
use crate::{
asset::{sound::sample::AudioBuffer, AssetParser},
asset::{sound::sample::AudioBuffer, Parser},
utils::nom::*,
};

Expand All @@ -20,7 +20,7 @@ impl TEffect {
}
}

impl AssetParser for TEffect {
impl Parser for TEffect {
type Output = Self;

type Context<'ctx> = ();
Expand Down Expand Up @@ -50,7 +50,7 @@ struct TEffectPointers {
sample_data: u32,
}

impl AssetParser for TEffectPointers {
impl Parser for TEffectPointers {
type Output = Self;

type Context<'ctx> = ();
Expand Down
Loading

0 comments on commit 3486a6c

Please sign in to comment.