Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
179 commits
Select commit Hold shift + click to select a range
7508593
feat: impl Container::push
alanpq Mar 5, 2026
1833a70
feat: impl Map::push
alanpq Mar 5, 2026
1f1a491
feat: impl Container::empty/empty_const
alanpq Mar 5, 2026
43c1eef
feat: impl Optional::empty_const
alanpq Mar 5, 2026
e56f247
fix: tests
alanpq Mar 5, 2026
be77f2f
feat: add PropertyExt::meta() + meta to Optional
alanpq Mar 6, 2026
6fbf4fd
fix: propagate meta generic to BinProperty/Struct
alanpq Mar 6, 2026
316fe9d
feat: String::new_with_meta, with_meta
alanpq Mar 6, 2026
45c916c
feat: new_with_meta for primitives
alanpq Mar 6, 2026
61e7270
feat: None::new()
alanpq Mar 6, 2026
9b08f2f
feat: PropertyExt::meta_mut()
alanpq Mar 6, 2026
ce7bc25
feat: propagate meta generic to BinObject
alanpq Mar 6, 2026
f15ceff
feat: no_meta helper
alanpq Mar 6, 2026
7b173b0
fix: snapshot test
alanpq Mar 7, 2026
c053fd7
fix: clippy
alanpq Mar 23, 2026
5e1e238
feat!: remove BinProperty & name_hash duplication
alanpq Mar 24, 2026
c0273d0
feat: meta generic in Bin
alanpq Mar 26, 2026
a20955a
chore: add cargo-public-api to flake + update flake
alanpq Jan 5, 2026
a2880bf
fix: promote parser module to folder
alanpq Jan 5, 2026
45ef7a1
wip: CST parser + handrolled tokenizer
alanpq Jan 7, 2026
f7a6e88
feat: Span::contains
alanpq Jan 7, 2026
ac0d8fa
feat: Visitor skip/stop behaviour
alanpq Jan 7, 2026
4fc3c0c
fix: string parsing
alanpq Jan 7, 2026
97b8960
fix: better tree printing
alanpq Jan 7, 2026
3106357
feat: better string lexing + dedicated unterminated string token
alanpq Jan 9, 2026
13c3e58
feat: pass whole tree in visitor methods
alanpq Jan 9, 2026
38c876d
feat: tree spans
alanpq Jan 9, 2026
44e1349
fix: impl Debug for Tree/Child
alanpq Jan 9, 2026
9c4af12
feat: helper span() method on Child
alanpq Jan 9, 2026
84997a5
feat: impl Index<Span> for str
alanpq Jan 9, 2026
6217a2b
feat: parser errors
alanpq Jan 9, 2026
a698381
feat: embed errors in tree
alanpq Jan 9, 2026
a566516
feat: rename ErrorToken -> Unknown
alanpq Jan 10, 2026
8be3ed9
feat: impl Display for TokenKind/TreeKind
alanpq Jan 10, 2026
8454625
feat: parser helper methods
alanpq Jan 10, 2026
fdddbb2
wip: parser tweaks
alanpq Jan 10, 2026
92f02f0
feat: impl Index<&Span> for str
alanpq Jan 10, 2026
b7836c0
wip: parser changes
alanpq Jan 10, 2026
d4409ae
feat: add semicolon to lexer
alanpq Jan 10, 2026
aef8e55
feat (lex): spit newline when at possibly statement ending token
alanpq Jan 10, 2026
cf16872
feat: entry termination parsing
alanpq Jan 10, 2026
91d1fab
fix: type argument parsing
alanpq Jan 10, 2026
1a44491
feat: proper block/list parsing
alanpq Jan 10, 2026
b7764d2
feat: tokenize hex literals
alanpq Jan 10, 2026
0f0bcae
wip: cleanup
alanpq Jan 10, 2026
a756ef9
fix: tweak parser
alanpq Jan 10, 2026
3d67652
fix: string literal lexing
alanpq Jan 10, 2026
906af1c
fix: disable some tests for now
alanpq Jan 10, 2026
693260d
feat: comments + numbers
alanpq Jan 10, 2026
b578a1f
fix: bring back fuel reset
alanpq Jan 10, 2026
d6b1254
feat: better parser
alanpq Jan 10, 2026
26ab0de
fix (lex): remove minus symbol + fix hex lexing
alanpq Jan 10, 2026
a403485
fix: safer slicing
alanpq Jan 10, 2026
4f8e87f
misc tweaks
alanpq Jan 10, 2026
64b0880
wip: typecheck
alanpq Jan 10, 2026
63e0af6
wip: typecheck
alanpq Jan 11, 2026
2162072
feat: change visitor call logic
alanpq Jan 11, 2026
db3cf32
chore: add type check to smoke test
alanpq Jan 11, 2026
3e7f215
wip: typecheck
alanpq Jan 11, 2026
9099d34
wip: typecheck
alanpq Jan 11, 2026
990fd2c
wip: typecheck
alanpq Jan 11, 2026
34e0e00
feat: parent value type infer + more typecheck
alanpq Jan 11, 2026
b4847fa
feat: working basic type construction
alanpq Jan 11, 2026
1bb16ce
wip: literal resolving
alanpq Jan 11, 2026
ca41f6e
feat: VisitorExt
alanpq Jan 12, 2026
0a5a09d
feat: Span::intersects
alanpq Jan 12, 2026
abcb953
feat: spanned IR entries + entry shadow diagnostic
alanpq Jan 12, 2026
5ef62e8
fix: typecheck stack
alanpq Jan 12, 2026
ce988ab
fix (parse): wrap string literals in TreeKind::Literal
alanpq Jan 12, 2026
7ed5c12
fix: look for Literal when calling literal resolve
alanpq Jan 12, 2026
e09ce96
feat: TypeMismatch error
alanpq Jan 12, 2026
630668d
feat: err on type mismatch in resolve_literal
alanpq Jan 12, 2026
dfc287b
feat: resolve all numeric literals
alanpq Jan 12, 2026
71de802
feat: type mismatch error in merge_ir
alanpq Jan 12, 2026
741906b
feat: type mismatch error for explicit type conflict w/ parent value …
alanpq Jan 12, 2026
2c5e28b
feat: add expected_span to TypeMismatch diag
alanpq Jan 12, 2026
866965d
feat: merge_ir for struct/embedded
alanpq Jan 12, 2026
76e38fa
feat: resolve embeds/structs with class hash
alanpq Jan 12, 2026
763fb6f
fix: hex hash parsing + better struct resolving
alanpq Jan 12, 2026
6819367
feat: f32 resolving
alanpq Jan 12, 2026
63a00f8
fix: wrap classes inside blocks with ListItem
alanpq Jan 12, 2026
1a77937
feat: AmbiguousNumeric diag
alanpq Jan 12, 2026
2574bf3
fix: remove unreachable! (it's now reachable)
alanpq Jan 12, 2026
2da3f7b
fix: put debug logs behind RB_STACK env var
alanpq Jan 12, 2026
9507208
wip: list item resolving
alanpq Jan 12, 2026
842832a
wip: vec/color population
alanpq Jan 12, 2026
e571cc8
wip: lists from blocks
alanpq Jan 14, 2026
80a7f06
chore: remove unused imports
alanpq Jan 14, 2026
ee9fad5
feat: ListBlock token to distinguish blocks as list items from blocks…
alanpq Jan 17, 2026
ac5162c
feat: improve list item handling
alanpq Jan 17, 2026
65b7752
fix: match latest ltk_meta
alanpq Mar 5, 2026
e9897bd
wip: disable old tests for now
alanpq Mar 5, 2026
99eb065
wip: build to Bin
alanpq Mar 5, 2026
05aaebc
wip: remove span
alanpq Mar 6, 2026
c5ea851
fix: no_meta
alanpq Mar 6, 2026
aa88033
feat: type coercion method + collect to bin
alanpq Mar 7, 2026
5afa41e
fix: update smoke test
alanpq Mar 7, 2026
359979b
feat: Cst::build_bin
alanpq Mar 7, 2026
6b7bdee
wip: bring back tests
alanpq Mar 7, 2026
263f8cf
wip: print attempt 1
alanpq Mar 7, 2026
7e662a8
wip: printer v2
alanpq Mar 7, 2026
c0a5ec8
fix: disable spammy logs
alanpq Mar 7, 2026
b60842f
wip: fix some things
alanpq Mar 7, 2026
02c45d0
fix: string list fmt
alanpq Mar 7, 2026
bee6f3f
fix: don't add softlines after TypeArgList
alanpq Mar 12, 2026
f609a10
feat: more tests
alanpq Mar 12, 2026
8d27404
feat: queue flushing + safety mechanisms
alanpq Mar 12, 2026
fb40adc
feat: formatter example
alanpq Mar 12, 2026
dfaf7a6
fix: replace mod.rs's
alanpq Mar 18, 2026
65c3a85
fix (typecheck): hash parsing for entry key
alanpq Mar 18, 2026
3ef7c65
feat: print fixed tokens regardless of span
alanpq Mar 18, 2026
8812738
fix: print token kind in Cst::print helper
alanpq Mar 18, 2026
7b0baf0
wip: cst construction from bin tree
alanpq Mar 18, 2026
766a912
wip: round trip tests
alanpq Mar 18, 2026
e754b1c
chore: reorganise
alanpq Mar 19, 2026
9638110
fix: use fixed token print value in print fallback arm
alanpq Mar 19, 2026
8987599
fix: number/vec/container cst building
alanpq Mar 19, 2026
0eacf8d
fix: set empty dependencies in typecheck
alanpq Mar 19, 2026
b50f249
fix: don't include quotes when building strings for bin
alanpq Mar 19, 2026
8909866
feat (typecheck): build mat44
alanpq Mar 19, 2026
ed3ab54
feat: impl serde traits for cst stuff
alanpq Mar 19, 2026
02647b2
feat: impl Span::is_empty
alanpq Mar 19, 2026
5e5b5c0
feat: fix list item stuff + more cst builder tests
alanpq Mar 19, 2026
aca3207
fix: remove bars in Cst::print
alanpq Mar 19, 2026
f9db869
fix: bring back some tests
alanpq Mar 19, 2026
333f16e
feat (typecheck): inject into Optionals
alanpq Mar 19, 2026
0e1a301
fix: cst builder public api
alanpq Mar 19, 2026
c237719
fix: support more types in cst builder
alanpq Mar 19, 2026
a10a031
fix: print impl
alanpq Mar 19, 2026
749845f
fix (typecheck): coerce values when resolving entries
alanpq Mar 19, 2026
818269a
fix: coerce value types in lists
alanpq Mar 19, 2026
6669225
fix: cst builder struct/embedded building + other hash printing
alanpq Mar 19, 2026
5aebbdf
feat (print): only break nested lists if the parent list has >1 item
alanpq Mar 19, 2026
e89c4ed
fix (print): increase default line width -> 120
alanpq Mar 19, 2026
b134d1a
fix: coerce map key values to the map key type
alanpq Mar 19, 2026
c08575f
fix: entry value coercion
alanpq Mar 19, 2026
40f43f8
feat (typecheck): coerce to ObjectLink/WadChunkLink
alanpq Mar 19, 2026
1ed1d91
test: nicer assertion messages in roundtrip test
alanpq Mar 19, 2026
bebec4c
fix: print visitor org
alanpq Mar 23, 2026
a23a843
chore: fmt
alanpq Mar 23, 2026
09697c2
chore: cargo fix
alanpq Mar 23, 2026
6fc18cc
fix: remove garbage
alanpq Mar 23, 2026
1f39e75
fix: remove hashprovider from cst printer
alanpq Mar 23, 2026
0ede2fb
feat: impl cst building of color/hash/wadchunklink
alanpq Mar 23, 2026
6dd6981
feat(primitives): Color::to_array
alanpq Mar 23, 2026
4b25d4e
feat: impl cst building of maps
alanpq Mar 23, 2026
ac30081
fix: unused
alanpq Mar 23, 2026
def02ca
feat: typecheck hex lit values
alanpq Mar 23, 2026
4eba805
fix: add error checks to roundtrip tests
alanpq Mar 23, 2026
97db263
feat: cst builder hash lookups
alanpq Mar 23, 2026
3275833
chore!: public api reorg
alanpq Mar 23, 2026
f37cf86
fix: consolidate rito type related traits
alanpq Mar 23, 2026
fc57c51
fix: reexport Cst to lib root
alanpq Mar 23, 2026
cc010ac
chore: tweak example eprintln
alanpq Mar 23, 2026
4725e52
feat: rito_to_bin example
alanpq Mar 23, 2026
9a3e42b
chore: doc
alanpq Mar 23, 2026
96585da
fix: cst builder hash literals
alanpq Mar 23, 2026
c89fab1
fix: cst builder map entry separation
alanpq Mar 23, 2026
0908bc7
feat: add Null token
alanpq Mar 24, 2026
5c151f0
fix: parse Null literals
alanpq Mar 24, 2026
0f913e1
fix: correct null handling in cst builder + null rt test
alanpq Mar 24, 2026
81a9cad
test: add rtt's for all property types
alanpq Mar 24, 2026
9193bbf
fix: remove BinProperty references
alanpq Mar 24, 2026
9e1ea01
fix: handle WadChunkLink's properly
alanpq Mar 24, 2026
dc6360c
feat: proper bool/bitbool typechecking
alanpq Mar 24, 2026
7c478b2
chore: rm unused import
alanpq Mar 24, 2026
74d1cd0
fix: fmt issues
alanpq Mar 24, 2026
9f7e4fd
feat: UnexpectedContainerItem when can't inject type
alanpq Mar 24, 2026
47c0a4c
test: add broken type arg test
alanpq Mar 24, 2026
75e21c5
fix: eat all unexpected tokens inside type arg expression
alanpq Mar 25, 2026
c6d31fc
feat(parser): allow entries to be terminated early by RCurly's
alanpq Mar 25, 2026
d61034d
feat(print): support inlining structs/classes via config
alanpq Mar 25, 2026
bc42fd2
fix!: clean up PrintConfig
alanpq Mar 25, 2026
47418e7
feat: add inline_lists config
alanpq Mar 25, 2026
c9b9177
fix(parser): less leaky entries when unterminated string as value
alanpq Mar 25, 2026
c8dde98
test: add unterminated string fmt test
alanpq Mar 25, 2026
9e5cc08
fix(lex): tokenize numerics like ".5"
alanpq Mar 25, 2026
2ac787a
test: add nice to have case
alanpq Mar 25, 2026
2d439fc
fix(typecheck): support parsing numerics with '_'s
alanpq Mar 25, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ indexmap = "2.7.0"
approx = "0.5.1"
insta = { version = "1.39.0", features = ["ron"] }
camino = "1.2.1"

pretty_assertions = "1.4.1"
6 changes: 3 additions & 3 deletions crates/ltk_meta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ for (path_hash, object) in &tree.objects {

```
use ltk_meta::{Bin, BinObject};
use ltk_meta::property::values;
use ltk_meta::property::{values, NoMeta};

// Using the builder pattern
let tree = Bin::builder()
.dependency("common.bin")
.object(
BinObject::builder(0x12345678, 0xABCDEF00)
BinObject::<NoMeta>::builder(0x12345678, 0xABCDEF00)
.property(0x1111, values::I32::new(42))
.property(0x2222, values::String::from("hello"))
.build()
Expand Down Expand Up @@ -70,7 +70,7 @@ tree.to_writer(&mut output)?;
```
*/
pub mod property;
pub use property::{BinProperty, Kind as PropertyKind, PropertyValueEnum};
pub use property::{Kind as PropertyKind, PropertyValueEnum};

mod tree;
pub use tree::*;
Expand Down
42 changes: 0 additions & 42 deletions crates/ltk_meta/src/property.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,8 @@ pub use kind::*;
mod r#enum;
pub use r#enum::*;

use super::traits::{ReaderExt as _, WriterExt as _};
use super::Error;
use byteorder::{ReadBytesExt as _, WriteBytesExt as _, LE};
use std::io;

use crate::traits::PropertyExt;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct NoMeta;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Clone, PartialEq, Debug)]
pub struct BinProperty {
pub name_hash: u32,
#[cfg_attr(feature = "serde", serde(flatten))]
pub value: PropertyValueEnum,
}

impl BinProperty {
/// Read a BinProperty from a reader. This will read the name_hash, prop kind and then value, in that order.
pub fn from_reader<R: io::Read + std::io::Seek + ?Sized>(
reader: &mut R,
legacy: bool,
) -> Result<Self, Error> {
let name_hash = reader.read_u32::<LE>()?;
let kind = reader.read_property_kind(legacy)?;

Ok(Self {
name_hash,
value: PropertyValueEnum::from_reader(reader, kind, legacy)?,
})
}
pub fn to_writer<W: io::Write + std::io::Seek + ?Sized>(
&self,
writer: &mut W,
) -> Result<(), io::Error> {
writer.write_u32::<LE>(self.name_hash)?;
writer.write_property_kind(self.value.kind())?;

self.value.to_writer(writer)?;
Ok(())
}
pub fn size(&self) -> usize {
5 + self.value.size_no_header()
}
}
50 changes: 45 additions & 5 deletions crates/ltk_meta/src/property/enum.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use enum_dispatch::enum_dispatch;

use crate::{
property::{Kind, NoMeta},
traits::{ReadProperty as _, WriteProperty as _},
traits::{PropertyExt, ReadProperty as _, WriteProperty as _},
Error,
};
use std::io;
Expand Down Expand Up @@ -50,10 +48,9 @@ macro_rules! create_enum {
)]
#[cfg_attr(feature = "serde", serde(tag = "kind", content = "value"))]
#[derive(Clone, Debug, PartialEq)]
#[enum_dispatch(PropertyExt)]
/// The value part of a [`super::BinProperty`]. Holds the type of the value, and the value itself.
pub enum PropertyValueEnum<M = NoMeta> {
$( $variant (pub self::$variant<M>), )*
$( $variant (self::$variant<M>), )*
}


Expand Down Expand Up @@ -81,13 +78,56 @@ macro_rules! create_enum {
}
}
impl<M> PropertyValueEnum<M> {
#[inline(always)]
#[must_use]
pub fn kind(&self) -> Kind {
match self {
$(Self::$variant(_) => Kind::$variant,)*
}
}

#[inline(always)]
#[must_use]
pub fn no_meta(self) -> PropertyValueEnum<NoMeta> {
match self {
$(Self::$variant(i) => PropertyValueEnum::$variant(i.no_meta()),)*
}
}

}

impl<M> PropertyExt for PropertyValueEnum<M> {
type Meta = M;
fn meta(&self) -> &Self::Meta {
match self {
$(Self::$variant(i) => i.meta(),)*
}
}
fn meta_mut(&mut self) -> &mut Self::Meta {
match self {
$(Self::$variant(i) => i.meta_mut(),)*
}
}

fn size(&self, include_header: bool) -> usize {
match self {
$(Self::$variant(i) => i.size(include_header),)*
}
}
fn size_no_header(&self) -> usize {
match self {
$(Self::$variant(i) => i.size_no_header(),)*
}
}
}

$(
impl<M> From<values::$variant<M>> for PropertyValueEnum<M> {
fn from(other: values::$variant<M>) -> Self {
Self::$variant(other)
}
}
)*
};
}

Expand Down
60 changes: 59 additions & 1 deletion crates/ltk_meta/src/property/values/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ macro_rules! define_container_enum {
})*
}
}

type Meta = M;
fn meta(&self) -> &Self::Meta {
match &self {
$(Self::$variant{meta,..} => {
meta
})*
}
}
fn meta_mut(&mut self) -> &mut Self::Meta {
match self {
$(Self::$variant{meta,..} => {
meta
})*
}
}
}

$(
Expand Down Expand Up @@ -108,6 +124,48 @@ macro_rules! define_container_enum {
}

impl<M> Container<M> {
#[inline(always)]
pub fn empty(item_kind: Kind) -> Result<Self, Error>
where
M: Default
{
match item_kind {
$(Kind::$variant => Ok(Self::$variant {
items: vec![],
meta: M::default(),
}),)*
kind => Err(Error::InvalidNesting(kind)),

}
}

#[inline(always)]
#[must_use]
pub fn no_meta(self) -> Container<NoMeta> {
match self {
$(Self::$variant{items,..} => {
Container::$variant {
items: items.into_iter().map(|i| i.no_meta()).collect(),
meta: NoMeta
}
})*
}
}

pub fn push(&mut self, value: PropertyValueEnum<M>) -> Result<(), Error>{
let got = value.kind();
let expected = self.item_kind();
match (self, value) {
$((Self::$variant{items,..}, PropertyValueEnum::$variant(item)) => {
items.push(item);
Ok(())
})*
_ => {
Err(Error::MismatchedContainerTypes { got, expected })
}
}
}

/// Iterator that returns each item as a [`PropertyValueEnum`] for convenience.
#[inline(always)]
#[must_use]
Expand Down Expand Up @@ -149,7 +207,7 @@ impl<M> Container<M> {
Self::from(items)
}

pub fn empty<T>() -> Self
pub fn empty_const<T>() -> Self
where
Self: From<Vec<T>>,
{
Expand Down
4 changes: 2 additions & 2 deletions crates/ltk_meta/src/property/values/container/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{

pub struct ItemsDyn<'a, M>(ItemsDynInner<'a, M>);
impl<'a, M> Iterator for ItemsDyn<'a, M> {
type Item = &'a dyn PropertyValueDyn;
type Item = &'a dyn PropertyValueDyn<Meta = M>;

fn next(&mut self) -> Option<Self::Item> {
self.0.next()
Expand Down Expand Up @@ -39,7 +39,7 @@ macro_rules! define_dyn_iter {
}

impl<'a, M> Iterator for ItemsDynInner<'a, M> {
type Item = &'a dyn PropertyValueDyn;
type Item = &'a dyn PropertyValueDyn<Meta = M>;

fn next(&mut self) -> Option<Self::Item> {
match self {
Expand Down
72 changes: 36 additions & 36 deletions crates/ltk_meta/src/property/values/container/variants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,42 @@ macro_rules! container_variants {
};
}

macro_rules! match_property {
($value:expr, $on:ident, $inner:pat => $body:expr, $def:pat => $def_body: expr) => {
container_variants!(match_property_arms, ($value, $on, $inner => $body, $def => $def_body))
};
($value:expr, $on:ident, $inner:pat => $body:expr) => {
container_variants!(match_property_arms, ($value, $on, $inner => $body))
};

($value:expr, $inner:pat => $body:expr, $def:pat => $def_body: expr) => {
container_variants!(match_property_arms, ($value, Self, $inner => $body, $def => $def_body))
};
($value:expr, $inner:pat => $body:expr) => {
container_variants!(match_property_arms, ($value, Self, $inner => $body))
};
}

macro_rules! match_property_arms {
(($value:expr, $on:ident, $inner:pat => $body:expr, $def:pat => $def_body: expr)
[$( $variant:ident, )*]) => {
match $value {
$(
$on::$variant($inner) => $body,
)*
$def => $def_body
}
};

(($value:expr, $on:ident, $inner:pat => $body:expr)
[$( $variant:ident, )*]) => {
match $value {
$(
$on::$variant($inner) => $body,
)*
}
};
}
// macro_rules! match_property {
// ($value:expr, $on:ident, $inner:pat => $body:expr, $def:pat => $def_body: expr) => {
// container_variants!(match_property_arms, ($value, $on, $inner => $body, $def => $def_body))
// };
// ($value:expr, $on:ident, $inner:pat => $body:expr) => {
// container_variants!(match_property_arms, ($value, $on, $inner => $body))
// };
//
// ($value:expr, $inner:pat => $body:expr, $def:pat => $def_body: expr) => {
// container_variants!(match_property_arms, ($value, Self, $inner => $body, $def => $def_body))
// };
// ($value:expr, $inner:pat => $body:expr) => {
// container_variants!(match_property_arms, ($value, Self, $inner => $body))
// };
// }
//
// macro_rules! match_property_arms {
// (($value:expr, $on:ident, $inner:pat => $body:expr, $def:pat => $def_body: expr)
// [$( $variant:ident, )*]) => {
// match $value {
// $(
// $on::$variant($inner) => $body,
// )*
// $def => $def_body
// }
// };
//
// (($value:expr, $on:ident, $inner:pat => $body:expr)
// [$( $variant:ident, )*]) => {
// match $value {
// $(
// $on::$variant($inner) => $body,
// )*
// }
// };
// }

// macro_rules! match_enum_inner {
// (($value:expr, $on:ident, ||, $body:expr)
Expand Down
17 changes: 16 additions & 1 deletion crates/ltk_meta/src/property/values/embedded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ use super::Struct;
#[derive(Clone, PartialEq, Debug, Default)]
pub struct Embedded<M = NoMeta>(pub Struct<M>);

impl<M> Embedded<M> {
#[inline(always)]
#[must_use]
pub fn no_meta(self) -> Embedded<NoMeta> {
Embedded(self.0.no_meta())
}
}

impl<M> PropertyValueExt for Embedded<M> {
const KIND: Kind = Kind::Embedded;
}
Expand All @@ -21,6 +29,13 @@ impl<M> PropertyExt for Embedded<M> {
fn size_no_header(&self) -> usize {
self.0.size_no_header()
}
type Meta = M;
fn meta(&self) -> &Self::Meta {
self.0.meta()
}
fn meta_mut(&mut self) -> &mut Self::Meta {
self.0.meta_mut()
}
}

impl<M: Default> ReadProperty for Embedded<M> {
Expand All @@ -31,7 +46,7 @@ impl<M: Default> ReadProperty for Embedded<M> {
Struct::<M>::from_reader(reader, legacy).map(Self)
}
}
impl<M> WriteProperty for Embedded<M> {
impl<M: Clone> WriteProperty for Embedded<M> {
fn to_writer<R: std::io::Write + std::io::Seek + ?Sized>(
&self,
writer: &mut R,
Expand Down
Loading
Loading