diff --git a/font-codegen/src/table.rs b/font-codegen/src/table.rs index 6d20da363..fdeb09916 100644 --- a/font-codegen/src/table.rs +++ b/font-codegen/src/table.rs @@ -190,7 +190,7 @@ pub(crate) fn generate_group(item: &GenericGroup) -> syn::Result { let mut variant_decls = Vec::new(); let mut read_match_arms = Vec::new(); - let mut as_some_table_arms = Vec::new(); + let mut dyn_inner_arms = Vec::new(); for var in &item.variants { let var_name = &var.name; let type_id = &var.type_id; @@ -198,7 +198,7 @@ pub(crate) fn generate_group(item: &GenericGroup) -> syn::Result { variant_decls.push(quote! { #var_name ( #inner <'a, #typ<'a>> ) }); read_match_arms .push(quote! { #type_id => Ok(#name :: #var_name (untyped.into_concrete())) }); - as_some_table_arms.push(quote! { #name :: #var_name(table) => table }); + dyn_inner_arms.push(quote! { #name :: #var_name(table) => table }); } Ok(quote! { @@ -219,23 +219,29 @@ pub(crate) fn generate_group(item: &GenericGroup) -> syn::Result { #[cfg(feature = "traversal")] impl<'a> #name <'a> { - fn as_some_table(&self) -> &(dyn SomeTable<'a> + 'a) { + fn dyn_inner(&self) -> &(dyn SomeTable<'a> + 'a) { match self { - #( #as_some_table_arms, )* + #( #dyn_inner_arms, )* } } } #[cfg(feature = "traversal")] - impl<'a> SomeTable<'a> for #name <'a> { fn get_field(&self, idx: usize) -> Option> { - self.as_some_table().get_field(idx) + self.dyn_inner().get_field(idx) } fn type_name(&self) -> &str { - self.as_some_table().type_name() + self.dyn_inner().type_name() + } + } + + #[cfg(feature = "traversal")] + impl<'a> std::fmt::Debug for #name<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.dyn_inner().fmt(f) } } }) diff --git a/read-fonts/generated/generated_gpos.rs b/read-fonts/generated/generated_gpos.rs index 7bfafd8f9..bd7953293 100644 --- a/read-fonts/generated/generated_gpos.rs +++ b/read-fonts/generated/generated_gpos.rs @@ -193,7 +193,7 @@ impl<'a> FontRead<'a> for PositionLookup<'a> { #[cfg(feature = "traversal")] impl<'a> PositionLookup<'a> { - fn as_some_table(&self) -> &(dyn SomeTable<'a> + 'a) { + fn dyn_inner(&self) -> &(dyn SomeTable<'a> + 'a) { match self { PositionLookup::Single(table) => table, PositionLookup::Pair(table) => table, @@ -211,10 +211,17 @@ impl<'a> PositionLookup<'a> { #[cfg(feature = "traversal")] impl<'a> SomeTable<'a> for PositionLookup<'a> { fn get_field(&self, idx: usize) -> Option> { - self.as_some_table().get_field(idx) + self.dyn_inner().get_field(idx) } fn type_name(&self) -> &str { - self.as_some_table().type_name() + self.dyn_inner().type_name() + } +} + +#[cfg(feature = "traversal")] +impl<'a> std::fmt::Debug for PositionLookup<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.dyn_inner().fmt(f) } } @@ -3571,7 +3578,7 @@ impl<'a> FontRead<'a> for ExtensionSubtable<'a> { #[cfg(feature = "traversal")] impl<'a> ExtensionSubtable<'a> { - fn as_some_table(&self) -> &(dyn SomeTable<'a> + 'a) { + fn dyn_inner(&self) -> &(dyn SomeTable<'a> + 'a) { match self { ExtensionSubtable::Single(table) => table, ExtensionSubtable::Pair(table) => table, @@ -3588,9 +3595,16 @@ impl<'a> ExtensionSubtable<'a> { #[cfg(feature = "traversal")] impl<'a> SomeTable<'a> for ExtensionSubtable<'a> { fn get_field(&self, idx: usize) -> Option> { - self.as_some_table().get_field(idx) + self.dyn_inner().get_field(idx) } fn type_name(&self) -> &str { - self.as_some_table().type_name() + self.dyn_inner().type_name() + } +} + +#[cfg(feature = "traversal")] +impl<'a> std::fmt::Debug for ExtensionSubtable<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.dyn_inner().fmt(f) } } diff --git a/read-fonts/generated/generated_gsub.rs b/read-fonts/generated/generated_gsub.rs index b8d698fe7..da9367372 100644 --- a/read-fonts/generated/generated_gsub.rs +++ b/read-fonts/generated/generated_gsub.rs @@ -191,7 +191,7 @@ impl<'a> FontRead<'a> for SubstitutionLookup<'a> { #[cfg(feature = "traversal")] impl<'a> SubstitutionLookup<'a> { - fn as_some_table(&self) -> &(dyn SomeTable<'a> + 'a) { + fn dyn_inner(&self) -> &(dyn SomeTable<'a> + 'a) { match self { SubstitutionLookup::Single(table) => table, SubstitutionLookup::Multiple(table) => table, @@ -208,10 +208,17 @@ impl<'a> SubstitutionLookup<'a> { #[cfg(feature = "traversal")] impl<'a> SomeTable<'a> for SubstitutionLookup<'a> { fn get_field(&self, idx: usize) -> Option> { - self.as_some_table().get_field(idx) + self.dyn_inner().get_field(idx) } fn type_name(&self) -> &str { - self.as_some_table().type_name() + self.dyn_inner().type_name() + } +} + +#[cfg(feature = "traversal")] +impl<'a> std::fmt::Debug for SubstitutionLookup<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.dyn_inner().fmt(f) } } @@ -1309,7 +1316,7 @@ impl<'a> FontRead<'a> for ExtensionSubtable<'a> { #[cfg(feature = "traversal")] impl<'a> ExtensionSubtable<'a> { - fn as_some_table(&self) -> &(dyn SomeTable<'a> + 'a) { + fn dyn_inner(&self) -> &(dyn SomeTable<'a> + 'a) { match self { ExtensionSubtable::Single(table) => table, ExtensionSubtable::Multiple(table) => table, @@ -1325,10 +1332,17 @@ impl<'a> ExtensionSubtable<'a> { #[cfg(feature = "traversal")] impl<'a> SomeTable<'a> for ExtensionSubtable<'a> { fn get_field(&self, idx: usize) -> Option> { - self.as_some_table().get_field(idx) + self.dyn_inner().get_field(idx) } fn type_name(&self) -> &str { - self.as_some_table().type_name() + self.dyn_inner().type_name() + } +} + +#[cfg(feature = "traversal")] +impl<'a> std::fmt::Debug for ExtensionSubtable<'a> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + self.dyn_inner().fmt(f) } }