From e83417b243416eb6cdc275d6f5aefa097f78d621 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Wed, 27 Dec 2023 12:38:21 -0500 Subject: [PATCH] Introducing a trait for running compares. This should enable us to invoke compares without needing a reference ast node type. --- src/wasm_test/compare.rs | 48 ++++++++++++++++------------------ src/wasm_test/elisp_compare.rs | 10 +++++++ src/wasm_test/mod.rs | 1 + 3 files changed, 33 insertions(+), 26 deletions(-) create mode 100644 src/wasm_test/elisp_compare.rs diff --git a/src/wasm_test/compare.rs b/src/wasm_test/compare.rs index 697ba27..1665206 100644 --- a/src/wasm_test/compare.rs +++ b/src/wasm_test/compare.rs @@ -1,5 +1,6 @@ use std::borrow::Cow; +use super::elisp_compare::WasmElispCompare; use crate::compare::Token; use crate::wasm::WasmAstNode; use crate::wasm::WasmDocument; @@ -9,8 +10,7 @@ pub fn wasm_compare_document<'b, 's, 'p>( emacs: &'b Token<'s>, wasm: WasmDocument<'s, 'p>, ) -> Result, Box> { - // wasm_compare_ast_node( - todo!() + wasm.compare_ast_node(source, emacs) } #[derive(Debug)] @@ -153,33 +153,29 @@ fn wasm_compare_ast_node<'b, 's, 'p>( todo!() } -// fn wasm_compare_list<'b, 's, EI, WI, WC>( -// source: &'s str, -// emacs: EI, -// wasm: WI, -// // emacs: &'b Token<'s>, -// // wasm: WasmDocument<'s>, -// ) -> Result, Box> -// where -// EI: Iterator> + ExactSizeIterator, -// WI: Iterator, -// WasmAstNode<'b, 's>: From, -// { -// let mut this_status = WasmDiffStatus::Good; -// let mut child_status = Vec::new(); -// let mut message = None; - -// todo!() -// } - -fn impl_wasm_compare_document<'b, 's, 'p>( +fn wasm_compare_list<'b, 's, 'p, EI, WI, WC>( source: &'s str, - emacs: &'b Token<'s>, - wasm: WasmDocument<'s, 'p>, -) -> Result, Box> { - let mut this_status = WasmDiffStatus::Good; + emacs: EI, + wasm: WI, +) -> Result, Box> +where + EI: Iterator> + ExactSizeIterator, + WI: Iterator + ExactSizeIterator, + WC: WasmElispCompare<'s, 'p>, +{ + // let mut this_status = WasmDiffStatus::Good; // let mut child_status = Vec::new(); // let mut message = None; todo!() } + +impl<'s, 'p> WasmElispCompare<'s, 'p> for WasmDocument<'s, 'p> { + fn compare_ast_node<'b>( + &self, + source: &'s str, + emacs: &'b Token<'s>, + ) -> Result, Box> { + todo!() + } +} diff --git a/src/wasm_test/elisp_compare.rs b/src/wasm_test/elisp_compare.rs new file mode 100644 index 0000000..bda867e --- /dev/null +++ b/src/wasm_test/elisp_compare.rs @@ -0,0 +1,10 @@ +use super::compare::WasmDiffEntry; +use crate::compare::Token; + +pub trait WasmElispCompare<'s, 'p> { + fn compare_ast_node<'b>( + &'p self, + source: &'s str, + emacs: &'b Token<'s>, + ) -> Result, Box>; +} diff --git a/src/wasm_test/mod.rs b/src/wasm_test/mod.rs index 8a434dc..0d26459 100644 --- a/src/wasm_test/mod.rs +++ b/src/wasm_test/mod.rs @@ -1,4 +1,5 @@ mod compare; +mod elisp_compare; mod runner; pub use runner::wasm_run_anonymous_compare;