working on porting ean/ups support

This commit is contained in:
Henry Schimke
2022-12-08 17:33:12 -06:00
parent e23a2768cb
commit c795a0ceca
3 changed files with 113 additions and 86 deletions

View File

@@ -77,4 +77,31 @@ fn impl_one_d_reader_macro(ast: &syn::DeriveInput) -> TokenStream {
}
};
gen.into()
}
#[proc_macro_derive(EANReader)]
pub fn ean_reader_derive(input: TokenStream) -> TokenStream {
// Construct a representation of Rust code as a syntax tree
// that we can manipulate
let ast = syn::parse(input).unwrap();
// Build the trait implementation
impl_ean_reader_macro(&ast)
}
fn impl_ean_reader_macro(ast: &syn::DeriveInput) -> TokenStream {
let name = &ast.ident;
let gen = quote! {
impl OneDReader for #name {
fn decodeRow(
&mut self,
rowNumber: u32,
row: &crate::common::BitArray,
hints: &crate::DecodingHintDictionary,
) -> Result<crate::RXingResult, crate::Exceptions> {
self.decodeRowWithGuardRange(rowNumber, row, Self::findStartGuardPattern(row), hints)
}
}
};
gen.into()
}