Remove lifetimes from wasm ast nodes.

This commit is contained in:
Tom Alexander 2023-12-29 12:49:43 -05:00
parent 9f4f8e79ce
commit a0a4f0eb90
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
68 changed files with 2438 additions and 2472 deletions

View File

@ -1,3 +1,4 @@
use std::borrow::Cow;
use std::collections::HashMap; use std::collections::HashMap;
use serde::Serialize; use serde::Serialize;
@ -10,30 +11,27 @@ use crate::types::AffiliatedKeywords;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum AdditionalPropertyValue<'s, 'p> { pub enum AdditionalPropertyValue {
SingleString(&'s str), SingleString(String),
ListOfStrings(Vec<&'s str>), ListOfStrings(Vec<String>),
OptionalPair { OptionalPair { optval: Option<String>, val: String },
optval: Option<&'s str>, ObjectTree(Vec<(Option<Vec<WasmAstNode>>, Vec<WasmAstNode>)>),
val: &'s str,
},
ObjectTree(Vec<(Option<Vec<WasmAstNode<'s, 'p>>>, Vec<WasmAstNode<'s, 'p>>)>),
} }
#[derive(Debug, Serialize, Default)] #[derive(Debug, Serialize, Default)]
pub struct AdditionalProperties<'s, 'p> { pub struct AdditionalProperties {
#[serde(flatten)] #[serde(flatten)]
pub(crate) properties: HashMap<String, AdditionalPropertyValue<'s, 'p>>, pub(crate) properties: HashMap<String, AdditionalPropertyValue>,
} }
impl<'s, 'p> AdditionalProperties<'s, 'p> { impl AdditionalProperties {
pub(crate) fn get_elisp_names<'c>(&'c self) -> impl Iterator<Item = String> + 'c { pub(crate) fn get_elisp_names<'c>(&'c self) -> impl Iterator<Item = String> + 'c {
self.properties.keys().map(move |key| format!(":{}", key)) self.properties.keys().map(move |key| format!(":{}", key))
} }
} }
to_wasm!( to_wasm!(
AdditionalProperties<'s, 'p>, AdditionalProperties,
AffiliatedKeywords<'s>, AffiliatedKeywords<'s>,
original, original,
wasm_context, wasm_context,
@ -42,15 +40,17 @@ to_wasm!(
for (name, val) in original.keywords.iter() { for (name, val) in original.keywords.iter() {
let converted_val = match val { let converted_val = match val {
AffiliatedKeywordValue::SingleString(val) => { AffiliatedKeywordValue::SingleString(val) => {
AdditionalPropertyValue::SingleString(val) AdditionalPropertyValue::SingleString((*val).to_owned())
} }
AffiliatedKeywordValue::ListOfStrings(val) => { AffiliatedKeywordValue::ListOfStrings(val) => {
AdditionalPropertyValue::ListOfStrings(val.clone()) AdditionalPropertyValue::ListOfStrings(
val.iter().map(|s| (*s).to_owned()).collect(),
)
} }
AffiliatedKeywordValue::OptionalPair { optval, val } => { AffiliatedKeywordValue::OptionalPair { optval, val } => {
AdditionalPropertyValue::OptionalPair { AdditionalPropertyValue::OptionalPair {
optval: optval.clone(), optval: optval.map(|s| (*s).to_owned()),
val: val, val: (*val).to_owned(),
} }
} }
AffiliatedKeywordValue::ObjectTree(val) => { AffiliatedKeywordValue::ObjectTree(val) => {
@ -64,7 +64,7 @@ to_wasm!(
.map(|child| { .map(|child| {
child child
.to_wasm(wasm_context.clone()) .to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode<'_, '_>>::into) .map(Into::<WasmAstNode>::into)
}) })
.collect::<Result<Vec<_>, _>>()?, .collect::<Result<Vec<_>, _>>()?,
) )
@ -76,7 +76,7 @@ to_wasm!(
.map(|child| { .map(|child| {
child child
.to_wasm(wasm_context.clone()) .to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode<'_, '_>>::into) .map(Into::<WasmAstNode>::into)
}) })
.collect::<Result<Vec<_>, _>>()?; .collect::<Result<Vec<_>, _>>()?;

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmAngleLink<'s, 'p> { pub struct WasmAngleLink {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmAngleLink<'s, 'p>, WasmAngleLink,
AngleLink<'s>, AngleLink<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmAngleLink<'s, 'p> { impl Into<WasmAstNode> for WasmAngleLink {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::AngleLink(self) WasmAstNode::AngleLink(self)
} }
} }

View File

@ -1,5 +1,3 @@
use std::borrow::Cow;
use serde::Serialize; use serde::Serialize;
use super::angle_link::WasmAngleLink; use super::angle_link::WasmAngleLink;
@ -60,99 +58,98 @@ use super::timestamp::WasmTimestamp;
use super::underline::WasmUnderline; use super::underline::WasmUnderline;
use super::verbatim::WasmVerbatim; use super::verbatim::WasmVerbatim;
use super::verse_block::WasmVerseBlock; use super::verse_block::WasmVerseBlock;
use super::WasmStandardProperties;
#[derive(Debug, Serialize)] // #[derive(Debug, Serialize)]
pub(crate) struct WasmAstWrapper<'b, 's, 'p, I> { // pub(crate) struct WasmAstWrapper<'b, 's, 'p, I> {
#[serde(rename = "ast-node")] // #[serde(rename = "ast-node")]
pub(crate) ast_node: Cow<'s, str>, // pub(crate) ast_node: Cow<'static, str>,
#[serde(rename = "standard-properties")] // #[serde(rename = "standard-properties")]
pub(crate) standard_properties: &'b WasmStandardProperties, // pub(crate) standard_properties: WasmStandardProperties,
#[serde(rename = "properties")] // #[serde(rename = "properties")]
pub(crate) inner: I, // pub(crate) inner: I,
pub(crate) children: &'b Vec<WasmAstNode<'s, 'p>>, // pub(crate) children: &'b Vec<WasmAstNode<'s, 'p>>,
} // }
impl<'b, 's, 'p, I> WasmAstWrapper<'b, 's, 'p, I> { // impl<'b, 's, 'p, I> WasmAstWrapper<'b, 's, 'p, I> {
pub(crate) fn new( // pub(crate) fn new(
ast_node: Cow<'s, str>, // ast_node: Cow<'s, str>,
standard_properties: &'b WasmStandardProperties, // standard_properties: &'b WasmStandardProperties,
inner: I, // inner: I,
children: &'b Vec<WasmAstNode<'s, 'p>>, // children: &'b Vec<WasmAstNode<'s, 'p>>,
) -> WasmAstWrapper<'b, 's, 'p, I> { // ) -> WasmAstWrapper<'b, 's, 'p, I> {
WasmAstWrapper { // WasmAstWrapper {
ast_node, // ast_node,
standard_properties, // standard_properties,
inner, // inner,
children, // children,
} // }
} // }
} // }
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(untagged)] #[serde(untagged)]
pub enum WasmAstNode<'s, 'p> { pub enum WasmAstNode {
// Document Nodes // Document Nodes
Document(WasmDocument<'s, 'p>), Document(WasmDocument),
Headline(WasmHeadline<'s, 'p>), Headline(WasmHeadline),
Section(WasmSection<'s, 'p>), Section(WasmSection),
// Elements // Elements
Paragraph(WasmParagraph<'s, 'p>), Paragraph(WasmParagraph),
PlainList(WasmPlainList<'s, 'p>), PlainList(WasmPlainList),
PlainListItem(WasmPlainListItem<'s, 'p>), PlainListItem(WasmPlainListItem),
CenterBlock(WasmCenterBlock<'s, 'p>), CenterBlock(WasmCenterBlock),
QuoteBlock(WasmQuoteBlock<'s, 'p>), QuoteBlock(WasmQuoteBlock),
SpecialBlock(WasmSpecialBlock<'s, 'p>), SpecialBlock(WasmSpecialBlock),
DynamicBlock(WasmDynamicBlock<'s, 'p>), DynamicBlock(WasmDynamicBlock),
FootnoteDefinition(WasmFootnoteDefinition<'s, 'p>), FootnoteDefinition(WasmFootnoteDefinition),
Comment(WasmComment<'s, 'p>), Comment(WasmComment),
Drawer(WasmDrawer<'s, 'p>), Drawer(WasmDrawer),
PropertyDrawer(WasmPropertyDrawer<'s, 'p>), PropertyDrawer(WasmPropertyDrawer),
NodeProperty(WasmNodeProperty<'s, 'p>), NodeProperty(WasmNodeProperty),
Table(WasmTable<'s, 'p>), Table(WasmTable),
TableRow(WasmTableRow<'s, 'p>), TableRow(WasmTableRow),
VerseBlock(WasmVerseBlock<'s, 'p>), VerseBlock(WasmVerseBlock),
CommentBlock(WasmCommentBlock<'s, 'p>), CommentBlock(WasmCommentBlock),
ExampleBlock(WasmExampleBlock<'s, 'p>), ExampleBlock(WasmExampleBlock),
ExportBlock(WasmExportBlock<'s, 'p>), ExportBlock(WasmExportBlock),
SrcBlock(WasmSrcBlock<'s, 'p>), SrcBlock(WasmSrcBlock),
Clock(WasmClock<'s, 'p>), Clock(WasmClock),
DiarySexp(WasmDiarySexp<'s, 'p>), DiarySexp(WasmDiarySexp),
Planning(WasmPlanning<'s, 'p>), Planning(WasmPlanning),
FixedWidthArea(WasmFixedWidthArea<'s, 'p>), FixedWidthArea(WasmFixedWidthArea),
HorizontalRule(WasmHorizontalRule<'s, 'p>), HorizontalRule(WasmHorizontalRule),
Keyword(WasmKeyword<'s, 'p>), Keyword(WasmKeyword),
BabelCall(WasmBabelCall<'s, 'p>), BabelCall(WasmBabelCall),
LatexEnvironment(WasmLatexEnvironment<'s, 'p>), LatexEnvironment(WasmLatexEnvironment),
// Objects // Objects
Bold(WasmBold<'s, 'p>), Bold(WasmBold),
Italic(WasmItalic<'s, 'p>), Italic(WasmItalic),
Underline(WasmUnderline<'s, 'p>), Underline(WasmUnderline),
StrikeThrough(WasmStrikeThrough<'s, 'p>), StrikeThrough(WasmStrikeThrough),
Code(WasmCode<'s, 'p>), Code(WasmCode),
Verbatim(WasmVerbatim<'s, 'p>), Verbatim(WasmVerbatim),
PlainText(WasmPlainText<'s, 'p>), PlainText(WasmPlainText),
RegularLink(WasmRegularLink<'s, 'p>), RegularLink(WasmRegularLink),
RadioLink(WasmRadioLink<'s, 'p>), RadioLink(WasmRadioLink),
RadioTarget(WasmRadioTarget<'s, 'p>), RadioTarget(WasmRadioTarget),
PlainLink(WasmPlainLink<'s, 'p>), PlainLink(WasmPlainLink),
AngleLink(WasmAngleLink<'s, 'p>), AngleLink(WasmAngleLink),
OrgMacro(WasmOrgMacro<'s, 'p>), OrgMacro(WasmOrgMacro),
Entity(WasmEntity<'s, 'p>), Entity(WasmEntity),
LatexFragment(WasmLatexFragment<'s, 'p>), LatexFragment(WasmLatexFragment),
ExportSnippet(WasmExportSnippet<'s, 'p>), ExportSnippet(WasmExportSnippet),
FootnoteReference(WasmFootnoteReference<'s, 'p>), FootnoteReference(WasmFootnoteReference),
Citation(WasmCitation<'s, 'p>), Citation(WasmCitation),
CitationReference(WasmCitationReference<'s, 'p>), CitationReference(WasmCitationReference),
InlineBabelCall(WasmInlineBabelCall<'s, 'p>), InlineBabelCall(WasmInlineBabelCall),
InlineSourceBlock(WasmInlineSourceBlock<'s, 'p>), InlineSourceBlock(WasmInlineSourceBlock),
LineBreak(WasmLineBreak<'s, 'p>), LineBreak(WasmLineBreak),
Target(WasmTarget<'s, 'p>), Target(WasmTarget),
StatisticsCookie(WasmStatisticsCookie<'s, 'p>), StatisticsCookie(WasmStatisticsCookie),
Subscript(WasmSubscript<'s, 'p>), Subscript(WasmSubscript),
Superscript(WasmSuperscript<'s, 'p>), Superscript(WasmSuperscript),
TableCell(WasmTableCell<'s, 'p>), TableCell(WasmTableCell),
Timestamp(WasmTimestamp<'s, 'p>), Timestamp(WasmTimestamp),
} }
impl<'s, 'p> WasmAstNode<'s, 'p> {} impl WasmAstNode {}

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmBabelCall<'s, 'p> { pub struct WasmBabelCall {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmBabelCall<'s, 'p>, WasmBabelCall,
BabelCall<'s>, BabelCall<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmBabelCall<'s, 'p> { impl Into<WasmAstNode> for WasmBabelCall {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::BabelCall(self) WasmAstNode::BabelCall(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmBold<'s, 'p> { pub struct WasmBold {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmBold<'s, 'p>, WasmBold,
Bold<'s>, Bold<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmBold<'s, 'p> { impl Into<WasmAstNode> for WasmBold {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Bold(self) WasmAstNode::Bold(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmCenterBlock<'s, 'p> { pub struct WasmCenterBlock {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmCenterBlock<'s, 'p>, WasmCenterBlock,
CenterBlock<'s>, CenterBlock<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmCenterBlock<'s, 'p> { impl Into<WasmAstNode> for WasmCenterBlock {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::CenterBlock(self) WasmAstNode::CenterBlock(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmCitation<'s, 'p> { pub struct WasmCitation {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmCitation<'s, 'p>, WasmCitation,
Citation<'s>, Citation<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmCitation<'s, 'p> { impl Into<WasmAstNode> for WasmCitation {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Citation(self) WasmAstNode::Citation(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmCitationReference<'s, 'p> { pub struct WasmCitationReference {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmCitationReference<'s, 'p>, WasmCitationReference,
CitationReference<'s>, CitationReference<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmCitationReference<'s, 'p> { impl Into<WasmAstNode> for WasmCitationReference {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::CitationReference(self) WasmAstNode::CitationReference(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmClock<'s, 'p> { pub struct WasmClock {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmClock<'s, 'p>, WasmClock,
Clock<'s>, Clock<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmClock<'s, 'p> { impl Into<WasmAstNode> for WasmClock {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Clock(self) WasmAstNode::Clock(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmCode<'s, 'p> { pub struct WasmCode {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmCode<'s, 'p>, WasmCode,
Code<'s>, Code<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmCode<'s, 'p> { impl Into<WasmAstNode> for WasmCode {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Code(self) WasmAstNode::Code(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmComment<'s, 'p> { pub struct WasmComment {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmComment<'s, 'p>, WasmComment,
Comment<'s>, Comment<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmComment<'s, 'p> { impl Into<WasmAstNode> for WasmComment {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Comment(self) WasmAstNode::Comment(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmCommentBlock<'s, 'p> { pub struct WasmCommentBlock {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmCommentBlock<'s, 'p>, WasmCommentBlock,
CommentBlock<'s>, CommentBlock<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmCommentBlock<'s, 'p> { impl Into<WasmAstNode> for WasmCommentBlock {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::CommentBlock(self) WasmAstNode::CommentBlock(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmDiarySexp<'s, 'p> { pub struct WasmDiarySexp {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmDiarySexp<'s, 'p>, WasmDiarySexp,
DiarySexp<'s>, DiarySexp<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmDiarySexp<'s, 'p> { impl Into<WasmAstNode> for WasmDiarySexp {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::DiarySexp(self) WasmAstNode::DiarySexp(self)
} }
} }

View File

@ -5,7 +5,6 @@ use serde::Serialize;
use super::additional_property::AdditionalProperties; use super::additional_property::AdditionalProperties;
use super::additional_property::AdditionalPropertyValue; use super::additional_property::AdditionalPropertyValue;
use super::ast_node::WasmAstNode; use super::ast_node::WasmAstNode;
use super::ast_node::WasmAstWrapper;
use super::macros::to_wasm; use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties; use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm; use super::to_wasm::ToWasm;
@ -15,22 +14,22 @@ use crate::types::Document;
use crate::wasm::to_wasm::ToWasmStandardProperties; use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "__ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmDocument<'s, 'p> { pub struct WasmDocument {
#[serde(rename = "standard-properties")] #[serde(rename = "standard-properties")]
pub(crate) standard_properties: WasmStandardProperties, pub(crate) standard_properties: WasmStandardProperties,
#[serde(flatten)] #[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties<'s, 'p>, pub(crate) additional_properties: AdditionalProperties,
#[serde(rename = "__children")] #[serde(rename = "__children")]
pub(crate) children: Vec<WasmAstNode<'s, 'p>>, pub(crate) children: Vec<WasmAstNode>,
#[serde(rename = "CATEGORY")] #[serde(rename = "CATEGORY")]
pub(crate) category: Option<&'p str>, pub(crate) category: Option<String>,
pub(crate) path: Option<PathBuf>, pub(crate) path: Option<PathBuf>,
} }
to_wasm!( to_wasm!(
WasmDocument<'s, 'p>, WasmDocument,
Document<'s>, Document<'s>,
original, original,
wasm_context, wasm_context,
@ -43,7 +42,7 @@ to_wasm!(
for (name, val) in original.get_additional_properties().map(|node_property| { for (name, val) in original.get_additional_properties().map(|node_property| {
( (
node_property.property_name.to_uppercase(), node_property.property_name.to_uppercase(),
AdditionalPropertyValue::SingleString(node_property.value.unwrap_or("")), AdditionalPropertyValue::SingleString(node_property.value.unwrap_or("").to_owned()),
) )
}) { }) {
additional_properties.properties.insert(name, val); additional_properties.properties.insert(name, val);
@ -55,12 +54,12 @@ to_wasm!(
.map(|child| { .map(|child| {
child child
.to_wasm(wasm_context.clone()) .to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode<'_, '_>>::into) .map(Into::<WasmAstNode>::into)
}) })
.chain(original.children.iter().map(|child| { .chain(original.children.iter().map(|child| {
child child
.to_wasm(wasm_context.clone()) .to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode<'_, '_>>::into) .map(Into::<WasmAstNode>::into)
})) }))
.collect::<Result<Vec<_>, _>>()?; .collect::<Result<Vec<_>, _>>()?;
@ -68,34 +67,21 @@ to_wasm!(
standard_properties, standard_properties,
additional_properties, additional_properties,
children, children,
category, category: category.map(str::to_owned),
path, path,
}) })
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmDocument<'s, 'p> { impl Into<WasmAstNode> for WasmDocument {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Document(self) WasmAstNode::Document(self)
} }
} }
#[cfg(feature = "wasm_test")] #[cfg(feature = "wasm_test")]
impl<'s, 'p> ElispFact<'s> for WasmDocument<'s, 'p> { impl<'s> ElispFact<'s> for WasmDocument {
fn get_elisp_name<'b>(&'b self) -> std::borrow::Cow<'s, str> { fn get_elisp_name<'b>(&'b self) -> std::borrow::Cow<'s, str> {
"org-data".into() "org-data".into()
} }
} }
impl<'b, 's, 'p> Into<WasmAstWrapper<'b, 's, 'p, &'b WasmDocument<'s, 'p>>>
for &'b WasmDocument<'s, 'p>
{
fn into(self) -> WasmAstWrapper<'b, 's, 'p, &'b WasmDocument<'s, 'p>> {
WasmAstWrapper::new(
self.get_elisp_name(),
&self.standard_properties,
self,
&self.children,
)
}
}

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmDrawer<'s, 'p> { pub struct WasmDrawer {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmDrawer<'s, 'p>, WasmDrawer,
Drawer<'s>, Drawer<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmDrawer<'s, 'p> { impl Into<WasmAstNode> for WasmDrawer {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Drawer(self) WasmAstNode::Drawer(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmDynamicBlock<'s, 'p> { pub struct WasmDynamicBlock {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmDynamicBlock<'s, 'p>, WasmDynamicBlock,
DynamicBlock<'s>, DynamicBlock<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmDynamicBlock<'s, 'p> { impl Into<WasmAstNode> for WasmDynamicBlock {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::DynamicBlock(self) WasmAstNode::DynamicBlock(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmEntity<'s, 'p> { pub struct WasmEntity {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmEntity<'s, 'p>, WasmEntity,
Entity<'s>, Entity<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmEntity<'s, 'p> { impl Into<WasmAstNode> for WasmEntity {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Entity(self) WasmAstNode::Entity(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmExampleBlock<'s, 'p> { pub struct WasmExampleBlock {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmExampleBlock<'s, 'p>, WasmExampleBlock,
ExampleBlock<'s>, ExampleBlock<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmExampleBlock<'s, 'p> { impl Into<WasmAstNode> for WasmExampleBlock {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::ExampleBlock(self) WasmAstNode::ExampleBlock(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmExportBlock<'s, 'p> { pub struct WasmExportBlock {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmExportBlock<'s, 'p>, WasmExportBlock,
ExportBlock<'s>, ExportBlock<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmExportBlock<'s, 'p> { impl Into<WasmAstNode> for WasmExportBlock {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::ExportBlock(self) WasmAstNode::ExportBlock(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmExportSnippet<'s, 'p> { pub struct WasmExportSnippet {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmExportSnippet<'s, 'p>, WasmExportSnippet,
ExportSnippet<'s>, ExportSnippet<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmExportSnippet<'s, 'p> { impl Into<WasmAstNode> for WasmExportSnippet {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::ExportSnippet(self) WasmAstNode::ExportSnippet(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmFixedWidthArea<'s, 'p> { pub struct WasmFixedWidthArea {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmFixedWidthArea<'s, 'p>, WasmFixedWidthArea,
FixedWidthArea<'s>, FixedWidthArea<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmFixedWidthArea<'s, 'p> { impl Into<WasmAstNode> for WasmFixedWidthArea {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::FixedWidthArea(self) WasmAstNode::FixedWidthArea(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmFootnoteDefinition<'s, 'p> { pub struct WasmFootnoteDefinition {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmFootnoteDefinition<'s, 'p>, WasmFootnoteDefinition,
FootnoteDefinition<'s>, FootnoteDefinition<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmFootnoteDefinition<'s, 'p> { impl Into<WasmAstNode> for WasmFootnoteDefinition {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::FootnoteDefinition(self) WasmAstNode::FootnoteDefinition(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmFootnoteReference<'s, 'p> { pub struct WasmFootnoteReference {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmFootnoteReference<'s, 'p>, WasmFootnoteReference,
FootnoteReference<'s>, FootnoteReference<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmFootnoteReference<'s, 'p> { impl Into<WasmAstNode> for WasmFootnoteReference {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::FootnoteReference(self) WasmAstNode::FootnoteReference(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "headline")] #[serde(rename = "headline")]
pub struct WasmHeadline<'s, 'p> { pub struct WasmHeadline {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmHeadline<'s, 'p>, WasmHeadline,
Heading<'s>, Heading<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmHeadline<'s, 'p> { impl Into<WasmAstNode> for WasmHeadline {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Headline(self) WasmAstNode::Headline(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmHorizontalRule<'s, 'p> { pub struct WasmHorizontalRule {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmHorizontalRule<'s, 'p>, WasmHorizontalRule,
HorizontalRule<'s>, HorizontalRule<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmHorizontalRule<'s, 'p> { impl Into<WasmAstNode> for WasmHorizontalRule {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::HorizontalRule(self) WasmAstNode::HorizontalRule(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmInlineBabelCall<'s, 'p> { pub struct WasmInlineBabelCall {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmInlineBabelCall<'s, 'p>, WasmInlineBabelCall,
InlineBabelCall<'s>, InlineBabelCall<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmInlineBabelCall<'s, 'p> { impl Into<WasmAstNode> for WasmInlineBabelCall {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::InlineBabelCall(self) WasmAstNode::InlineBabelCall(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmInlineSourceBlock<'s, 'p> { pub struct WasmInlineSourceBlock {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmInlineSourceBlock<'s, 'p>, WasmInlineSourceBlock,
InlineSourceBlock<'s>, InlineSourceBlock<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmInlineSourceBlock<'s, 'p> { impl Into<WasmAstNode> for WasmInlineSourceBlock {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::InlineSourceBlock(self) WasmAstNode::InlineSourceBlock(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmItalic<'s, 'p> { pub struct WasmItalic {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmItalic<'s, 'p>, WasmItalic,
Italic<'s>, Italic<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmItalic<'s, 'p> { impl Into<WasmAstNode> for WasmItalic {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Italic(self) WasmAstNode::Italic(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmKeyword<'s, 'p> { pub struct WasmKeyword {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmKeyword<'s, 'p>, WasmKeyword,
Keyword<'s>, Keyword<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmKeyword<'s, 'p> { impl Into<WasmAstNode> for WasmKeyword {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Keyword(self) WasmAstNode::Keyword(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmLatexEnvironment<'s, 'p> { pub struct WasmLatexEnvironment {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmLatexEnvironment<'s, 'p>, WasmLatexEnvironment,
LatexEnvironment<'s>, LatexEnvironment<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmLatexEnvironment<'s, 'p> { impl Into<WasmAstNode> for WasmLatexEnvironment {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::LatexEnvironment(self) WasmAstNode::LatexEnvironment(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmLatexFragment<'s, 'p> { pub struct WasmLatexFragment {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmLatexFragment<'s, 'p>, WasmLatexFragment,
LatexFragment<'s>, LatexFragment<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmLatexFragment<'s, 'p> { impl Into<WasmAstNode> for WasmLatexFragment {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::LatexFragment(self) WasmAstNode::LatexFragment(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmLineBreak<'s, 'p> { pub struct WasmLineBreak {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmLineBreak<'s, 'p>, WasmLineBreak,
LineBreak<'s>, LineBreak<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmLineBreak<'s, 'p> { impl Into<WasmAstNode> for WasmLineBreak {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::LineBreak(self) WasmAstNode::LineBreak(self)
} }
} }

View File

@ -3,11 +3,11 @@
/// This exists to make changing the type signature easier. /// This exists to make changing the type signature easier.
macro_rules! to_wasm { macro_rules! to_wasm {
($ostruct:ty, $istruct:ty, $original:ident, $wasm_context:ident, $fnbody:tt) => { ($ostruct:ty, $istruct:ty, $original:ident, $wasm_context:ident, $fnbody:tt) => {
impl<'s, 'p> ToWasm<'p> for $istruct { impl<'s> ToWasm for $istruct {
type Output = $ostruct; type Output = $ostruct;
fn to_wasm( fn to_wasm(
&'p self, &self,
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>, $wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
) -> Result<Self::Output, crate::error::CustomError> { ) -> Result<Self::Output, crate::error::CustomError> {
let $original = self; let $original = self;
@ -16,11 +16,11 @@ macro_rules! to_wasm {
} }
}; };
($ostruct:ty, $istruct:ty, $original:ident, $wasm_context:ident, $standard_properties:ident, $fnbody:tt) => { ($ostruct:ty, $istruct:ty, $original:ident, $wasm_context:ident, $standard_properties:ident, $fnbody:tt) => {
impl<'s, 'p> ToWasm<'p> for $istruct { impl<'s> ToWasm for $istruct {
type Output = $ostruct; type Output = $ostruct;
fn to_wasm( fn to_wasm(
&'p self, &self,
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>, $wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
) -> Result<Self::Output, crate::error::CustomError> { ) -> Result<Self::Output, crate::error::CustomError> {
let $original = self; let $original = self;

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmNodeProperty<'s, 'p> { pub struct WasmNodeProperty {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmNodeProperty<'s, 'p>, WasmNodeProperty,
NodeProperty<'s>, NodeProperty<'s>,
original, original,
wasm_context, wasm_context,

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmOrgMacro<'s, 'p> { pub struct WasmOrgMacro {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmOrgMacro<'s, 'p>, WasmOrgMacro,
OrgMacro<'s>, OrgMacro<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmOrgMacro<'s, 'p> { impl Into<WasmAstNode> for WasmOrgMacro {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::OrgMacro(self) WasmAstNode::OrgMacro(self)
} }
} }

View File

@ -14,15 +14,15 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "paragraph")] #[serde(rename = "paragraph")]
pub struct WasmParagraph<'s, 'p> { pub struct WasmParagraph {
pub(crate) standard_properties: WasmStandardProperties, pub(crate) standard_properties: WasmStandardProperties,
#[serde(flatten)] #[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties<'s, 'p>, pub(crate) additional_properties: AdditionalProperties,
pub(crate) children: Vec<WasmAstNode<'s, 'p>>, pub(crate) children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmParagraph<'s, 'p>, WasmParagraph,
Paragraph<'s>, Paragraph<'s>,
original, original,
wasm_context, wasm_context,
@ -38,7 +38,7 @@ to_wasm!(
.map(|child| { .map(|child| {
child child
.to_wasm(wasm_context.clone()) .to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode<'_, '_>>::into) .map(Into::<WasmAstNode>::into)
}) })
.collect::<Result<Vec<_>, _>>()?; .collect::<Result<Vec<_>, _>>()?;
@ -50,14 +50,14 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmParagraph<'s, 'p> { impl Into<WasmAstNode> for WasmParagraph {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Paragraph(self) WasmAstNode::Paragraph(self)
} }
} }
#[cfg(feature = "wasm_test")] #[cfg(feature = "wasm_test")]
impl<'s, 'p> ElispFact<'s> for WasmParagraph<'s, 'p> { impl<'s> ElispFact<'s> for WasmParagraph {
fn get_elisp_name<'b>(&'b self) -> std::borrow::Cow<'s, str> { fn get_elisp_name<'b>(&'b self) -> std::borrow::Cow<'s, str> {
"paragraph".into() "paragraph".into()
} }

View File

@ -4,9 +4,9 @@ use super::document::WasmDocument;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "status", content = "content")] #[serde(tag = "status", content = "content")]
pub enum ParseResult<'s, 'p> { pub enum ParseResult {
#[serde(rename = "success")] #[serde(rename = "success")]
Success(WasmDocument<'s, 'p>), Success(WasmDocument),
#[serde(rename = "error")] #[serde(rename = "error")]
Error(String), Error(String),

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmPlainLink<'s, 'p> { pub struct WasmPlainLink {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmPlainLink<'s, 'p>, WasmPlainLink,
PlainLink<'s>, PlainLink<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmPlainLink<'s, 'p> { impl Into<WasmAstNode> for WasmPlainLink {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::PlainLink(self) WasmAstNode::PlainLink(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmPlainList<'s, 'p> { pub struct WasmPlainList {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmPlainList<'s, 'p>, WasmPlainList,
PlainList<'s>, PlainList<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmPlainList<'s, 'p> { impl Into<WasmAstNode> for WasmPlainList {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::PlainList(self) WasmAstNode::PlainList(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmPlainListItem<'s, 'p> { pub struct WasmPlainListItem {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmPlainListItem<'s, 'p>, WasmPlainListItem,
PlainListItem<'s>, PlainListItem<'s>,
original, original,
wasm_context, wasm_context,

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmPlainText<'s, 'p> { pub struct WasmPlainText {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmPlainText<'s, 'p>, WasmPlainText,
PlainText<'s>, PlainText<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmPlainText<'s, 'p> { impl Into<WasmAstNode> for WasmPlainText {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::PlainText(self) WasmAstNode::PlainText(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmPlanning<'s, 'p> { pub struct WasmPlanning {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmPlanning<'s, 'p>, WasmPlanning,
Planning<'s>, Planning<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmPlanning<'s, 'p> { impl Into<WasmAstNode> for WasmPlanning {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Planning(self) WasmAstNode::Planning(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmPropertyDrawer<'s, 'p> { pub struct WasmPropertyDrawer {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmPropertyDrawer<'s, 'p>, WasmPropertyDrawer,
PropertyDrawer<'s>, PropertyDrawer<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmPropertyDrawer<'s, 'p> { impl Into<WasmAstNode> for WasmPropertyDrawer {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::PropertyDrawer(self) WasmAstNode::PropertyDrawer(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmQuoteBlock<'s, 'p> { pub struct WasmQuoteBlock {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmQuoteBlock<'s, 'p>, WasmQuoteBlock,
QuoteBlock<'s>, QuoteBlock<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmQuoteBlock<'s, 'p> { impl Into<WasmAstNode> for WasmQuoteBlock {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::QuoteBlock(self) WasmAstNode::QuoteBlock(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmRadioLink<'s, 'p> { pub struct WasmRadioLink {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmRadioLink<'s, 'p>, WasmRadioLink,
RadioLink<'s>, RadioLink<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmRadioLink<'s, 'p> { impl Into<WasmAstNode> for WasmRadioLink {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::RadioLink(self) WasmAstNode::RadioLink(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmRadioTarget<'s, 'p> { pub struct WasmRadioTarget {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmRadioTarget<'s, 'p>, WasmRadioTarget,
RadioTarget<'s>, RadioTarget<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmRadioTarget<'s, 'p> { impl Into<WasmAstNode> for WasmRadioTarget {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::RadioTarget(self) WasmAstNode::RadioTarget(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmRegularLink<'s, 'p> { pub struct WasmRegularLink {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmRegularLink<'s, 'p>, WasmRegularLink,
RegularLink<'s>, RegularLink<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmRegularLink<'s, 'p> { impl Into<WasmAstNode> for WasmRegularLink {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::RegularLink(self) WasmAstNode::RegularLink(self)
} }
} }

View File

@ -13,15 +13,15 @@ use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "section")] #[serde(rename = "section")]
pub struct WasmSection<'s, 'p> { pub struct WasmSection {
pub(crate) standard_properties: WasmStandardProperties, pub(crate) standard_properties: WasmStandardProperties,
#[serde(flatten)] #[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties<'s, 'p>, pub(crate) additional_properties: AdditionalProperties,
pub(crate) children: Vec<WasmAstNode<'s, 'p>>, pub(crate) children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmSection<'s, 'p>, WasmSection,
Section<'s>, Section<'s>,
original, original,
wasm_context, wasm_context,
@ -33,7 +33,7 @@ to_wasm!(
.map(|child| { .map(|child| {
child child
.to_wasm(wasm_context.clone()) .to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode<'_, '_>>::into) .map(Into::<WasmAstNode>::into)
}) })
.collect::<Result<Vec<_>, _>>()?; .collect::<Result<Vec<_>, _>>()?;
@ -45,14 +45,14 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmSection<'s, 'p> { impl Into<WasmAstNode> for WasmSection {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Section(self) WasmAstNode::Section(self)
} }
} }
#[cfg(feature = "wasm_test")] #[cfg(feature = "wasm_test")]
impl<'s, 'p> ElispFact<'s> for WasmSection<'s, 'p> { impl<'s> ElispFact<'s> for WasmSection {
fn get_elisp_name<'b>(&'b self) -> std::borrow::Cow<'s, str> { fn get_elisp_name<'b>(&'b self) -> std::borrow::Cow<'s, str> {
"section".into() "section".into()
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmSpecialBlock<'s, 'p> { pub struct WasmSpecialBlock {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmSpecialBlock<'s, 'p>, WasmSpecialBlock,
SpecialBlock<'s>, SpecialBlock<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmSpecialBlock<'s, 'p> { impl Into<WasmAstNode> for WasmSpecialBlock {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::SpecialBlock(self) WasmAstNode::SpecialBlock(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmSrcBlock<'s, 'p> { pub struct WasmSrcBlock {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmSrcBlock<'s, 'p>, WasmSrcBlock,
SrcBlock<'s>, SrcBlock<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmSrcBlock<'s, 'p> { impl Into<WasmAstNode> for WasmSrcBlock {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::SrcBlock(self) WasmAstNode::SrcBlock(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmStatisticsCookie<'s, 'p> { pub struct WasmStatisticsCookie {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmStatisticsCookie<'s, 'p>, WasmStatisticsCookie,
StatisticsCookie<'s>, StatisticsCookie<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmStatisticsCookie<'s, 'p> { impl Into<WasmAstNode> for WasmStatisticsCookie {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::StatisticsCookie(self) WasmAstNode::StatisticsCookie(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmStrikeThrough<'s, 'p> { pub struct WasmStrikeThrough {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmStrikeThrough<'s, 'p>, WasmStrikeThrough,
StrikeThrough<'s>, StrikeThrough<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmStrikeThrough<'s, 'p> { impl Into<WasmAstNode> for WasmStrikeThrough {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::StrikeThrough(self) WasmAstNode::StrikeThrough(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmSubscript<'s, 'p> { pub struct WasmSubscript {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmSubscript<'s, 'p>, WasmSubscript,
Subscript<'s>, Subscript<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmSubscript<'s, 'p> { impl Into<WasmAstNode> for WasmSubscript {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Subscript(self) WasmAstNode::Subscript(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmSuperscript<'s, 'p> { pub struct WasmSuperscript {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmSuperscript<'s, 'p>, WasmSuperscript,
Superscript<'s>, Superscript<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmSuperscript<'s, 'p> { impl Into<WasmAstNode> for WasmSuperscript {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Superscript(self) WasmAstNode::Superscript(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmTable<'s, 'p> { pub struct WasmTable {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmTable<'s, 'p>, WasmTable,
Table<'s>, Table<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmTable<'s, 'p> { impl Into<WasmAstNode> for WasmTable {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Table(self) WasmAstNode::Table(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmTableCell<'s, 'p> { pub struct WasmTableCell {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmTableCell<'s, 'p>, WasmTableCell,
TableCell<'s>, TableCell<'s>,
original, original,
wasm_context, wasm_context,

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmTableRow<'s, 'p> { pub struct WasmTableRow {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmTableRow<'s, 'p>, WasmTableRow,
TableRow<'s>, TableRow<'s>,
original, original,
wasm_context, wasm_context,

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmTarget<'s, 'p> { pub struct WasmTarget {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmTarget<'s, 'p>, WasmTarget,
Target<'s>, Target<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmTarget<'s, 'p> { impl Into<WasmAstNode> for WasmTarget {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Target(self) WasmAstNode::Target(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmTimestamp<'s, 'p> { pub struct WasmTimestamp {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmTimestamp<'s, 'p>, WasmTimestamp,
Timestamp<'s>, Timestamp<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmTimestamp<'s, 'p> { impl Into<WasmAstNode> for WasmTimestamp {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Timestamp(self) WasmAstNode::Timestamp(self)
} }
} }

View File

@ -4,10 +4,10 @@ use crate::error::CustomError;
use crate::types::Element; use crate::types::Element;
use crate::types::Object; use crate::types::Object;
pub trait ToWasm<'p> { pub trait ToWasm {
type Output; type Output;
fn to_wasm(&'p self, full_document: ToWasmContext<'_>) -> Result<Self::Output, CustomError>; fn to_wasm(&self, full_document: ToWasmContext<'_>) -> Result<Self::Output, CustomError>;
} }
pub(crate) trait ToWasmStandardProperties { pub(crate) trait ToWasmStandardProperties {
@ -31,7 +31,7 @@ impl<'s> ToWasmContext<'s> {
} }
to_wasm!( to_wasm!(
WasmAstNode<'s, 'p>, WasmAstNode,
Element<'s>, Element<'s>,
original, original,
wasm_context, wasm_context,
@ -93,7 +93,7 @@ to_wasm!(
); );
to_wasm!( to_wasm!(
WasmAstNode<'s, 'p>, WasmAstNode,
Object<'s>, Object<'s>,
original, original,
wasm_context, wasm_context,

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmUnderline<'s, 'p> { pub struct WasmUnderline {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmUnderline<'s, 'p>, WasmUnderline,
Underline<'s>, Underline<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmUnderline<'s, 'p> { impl Into<WasmAstNode> for WasmUnderline {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Underline(self) WasmAstNode::Underline(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmVerbatim<'s, 'p> { pub struct WasmVerbatim {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmVerbatim<'s, 'p>, WasmVerbatim,
Verbatim<'s>, Verbatim<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmVerbatim<'s, 'p> { impl Into<WasmAstNode> for WasmVerbatim {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::Verbatim(self) WasmAstNode::Verbatim(self)
} }
} }

View File

@ -10,13 +10,13 @@ use crate::wasm::WasmAstNode;
#[derive(Debug, Serialize)] #[derive(Debug, Serialize)]
#[serde(tag = "ast_node")] #[serde(tag = "ast_node")]
#[serde(rename = "org-data")] #[serde(rename = "org-data")]
pub struct WasmVerseBlock<'s, 'p> { pub struct WasmVerseBlock {
standard_properties: WasmStandardProperties, standard_properties: WasmStandardProperties,
children: Vec<WasmAstNode<'s, 'p>>, children: Vec<WasmAstNode>,
} }
to_wasm!( to_wasm!(
WasmVerseBlock<'s, 'p>, WasmVerseBlock,
VerseBlock<'s>, VerseBlock<'s>,
original, original,
wasm_context, wasm_context,
@ -29,8 +29,8 @@ to_wasm!(
} }
); );
impl<'s, 'p> Into<WasmAstNode<'s, 'p>> for WasmVerseBlock<'s, 'p> { impl Into<WasmAstNode> for WasmVerseBlock {
fn into(self) -> WasmAstNode<'s, 'p> { fn into(self) -> WasmAstNode {
WasmAstNode::VerseBlock(self) WasmAstNode::VerseBlock(self)
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,10 +0,0 @@
use super::diff::WasmDiffResult;
use crate::compare::Token;
pub trait WasmElispCompare<'s, 'p> {
fn compare_ast_node<'b>(
&self,
source: &'s str,
emacs: &'b Token<'s>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>>;
}

View File

@ -1,6 +1,5 @@
use super::diff::WasmDiffResult; use super::diff::WasmDiffResult;
use super::diff::WasmDiffStatus; use super::diff::WasmDiffStatus;
use super::elisp_compare::WasmElispCompare;
use crate::compare::get_emacs_standard_properties; use crate::compare::get_emacs_standard_properties;
use crate::compare::get_property; use crate::compare::get_property;
use crate::compare::get_property_quoted_string; use crate::compare::get_property_quoted_string;
@ -10,378 +9,378 @@ use crate::wasm::AdditionalProperties;
use crate::wasm::AdditionalPropertyValue; use crate::wasm::AdditionalPropertyValue;
use crate::wasm::WasmStandardProperties; use crate::wasm::WasmStandardProperties;
pub(crate) fn wasm_compare_list<'b, 's: 'b, 'p, EI, WI, WC>( // pub(crate) fn wasm_compare_list<'b, 's: 'b, 'p, EI, WI, WC>(
source: &'s str, // source: &'s str,
emacs: EI, // emacs: EI,
wasm: WI, // wasm: WI,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> // ) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>>
where // where
EI: Iterator<Item = &'b Token<'s>> + ExactSizeIterator, // EI: Iterator<Item = &'b Token<'s>> + ExactSizeIterator,
WI: Iterator<Item = WC> + ExactSizeIterator, // WI: Iterator<Item = WC> + ExactSizeIterator,
WC: WasmElispCompare<'s, 'p>, // WC: WasmElispCompare<'s, 'p>,
{ // {
let status = Vec::new(); // let status = Vec::new();
let emacs_length = emacs.len(); // let emacs_length = emacs.len();
let wasm_length = wasm.len(); // let wasm_length = wasm.len();
if emacs_length != wasm_length { // if emacs_length != wasm_length {
return Ok(WasmDiffResult { // return Ok(WasmDiffResult {
status: vec![WasmDiffStatus::Bad( // status: vec![WasmDiffStatus::Bad(
format!( // format!(
"Child length mismatch (emacs != rust) {:?} != {:?}", // "Child length mismatch (emacs != rust) {:?} != {:?}",
emacs_length, wasm_length // emacs_length, wasm_length
) // )
.into(), // .into(),
)], // )],
children: Vec::new(), // children: Vec::new(),
name: "".into(), // name: "".into(),
}); // });
} // }
let mut child_status = Vec::with_capacity(emacs_length); // let mut child_status = Vec::with_capacity(emacs_length);
for (emacs_child, wasm_child) in emacs.zip(wasm) { // for (emacs_child, wasm_child) in emacs.zip(wasm) {
child_status.push(wasm_child.compare_ast_node(source, emacs_child)?); // child_status.push(wasm_child.compare_ast_node(source, emacs_child)?);
} // }
Ok(WasmDiffResult { // Ok(WasmDiffResult {
status, // status,
children: child_status, // children: child_status,
name: "".into(), // name: "".into(),
}) // })
} // }
pub(crate) fn wasm_compare_property_quoted_string< // pub(crate) fn wasm_compare_property_quoted_string<
'b, // 'b,
's, // 's,
W, // W,
WV: AsRef<str> + std::fmt::Debug, // WV: AsRef<str> + std::fmt::Debug,
WG: Fn(W) -> Option<WV>, // WG: Fn(W) -> Option<WV>,
>( // >(
_source: &'s str, // _source: &'s str,
emacs: &'b Token<'s>, // emacs: &'b Token<'s>,
wasm_node: W, // wasm_node: W,
emacs_field: &str, // emacs_field: &str,
wasm_value_getter: WG, // wasm_value_getter: WG,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> { // ) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default(); // let mut result = WasmDiffResult::default();
let emacs_value = get_property_quoted_string(emacs, emacs_field)?; // let emacs_value = get_property_quoted_string(emacs, emacs_field)?;
let wasm_value = wasm_value_getter(wasm_node); // let wasm_value = wasm_value_getter(wasm_node);
if wasm_value.as_ref().map(|s| s.as_ref()) != emacs_value.as_deref() { // if wasm_value.as_ref().map(|s| s.as_ref()) != emacs_value.as_deref() {
result.status.push(WasmDiffStatus::Bad( // result.status.push(WasmDiffStatus::Bad(
format!( // format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = emacs_field, // property = emacs_field,
emacs = emacs_value, // emacs = emacs_value,
wasm = wasm_value, // wasm = wasm_value,
) // )
.into(), // .into(),
)) // ))
} // }
Ok(result) // Ok(result)
} // }
pub(crate) fn wasm_compare_property_list_of_quoted_string< // pub(crate) fn wasm_compare_property_list_of_quoted_string<
'b, // 'b,
's, // 's,
WI: Iterator<Item = WV> + ExactSizeIterator, // WI: Iterator<Item = WV> + ExactSizeIterator,
W, // W,
WV: AsRef<str> + std::fmt::Debug, // WV: AsRef<str> + std::fmt::Debug,
WG: Fn(W) -> Option<WI>, // WG: Fn(W) -> Option<WI>,
>( // >(
_source: &'s str, // _source: &'s str,
emacs: &'b Token<'s>, // emacs: &'b Token<'s>,
wasm_node: W, // wasm_node: W,
emacs_field: &str, // emacs_field: &str,
wasm_value_getter: WG, // wasm_value_getter: WG,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> { // ) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default(); // let mut result = WasmDiffResult::default();
let emacs_value = get_property(emacs, emacs_field)? // let emacs_value = get_property(emacs, emacs_field)?
.map(Token::as_list) // .map(Token::as_list)
.map_or(Ok(None), |r| r.map(Some))?; // .map_or(Ok(None), |r| r.map(Some))?;
let wasm_value = wasm_value_getter(wasm_node); // let wasm_value = wasm_value_getter(wasm_node);
match (emacs_value, wasm_value) { // match (emacs_value, wasm_value) {
(None, None) => {} // (None, None) => {}
(None, Some(_)) | (Some(_), None) => { // (None, Some(_)) | (Some(_), None) => {
return Ok(WasmDiffResult { // return Ok(WasmDiffResult {
status: vec![WasmDiffStatus::Bad( // status: vec![WasmDiffStatus::Bad(
format!( // format!(
"Property list length mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property list length mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = emacs_field, // property = emacs_field,
emacs = if emacs_value.is_some() {"Some"} else {"None"}, // emacs = if emacs_value.is_some() {"Some"} else {"None"},
wasm = if !emacs_value.is_some() {"Some"} else {"None"} // wasm = if !emacs_value.is_some() {"Some"} else {"None"}
) // )
.into(), // .into(),
)], // )],
children: Vec::new(), // children: Vec::new(),
name: "".into(), // name: "".into(),
}); // });
} // }
(Some(el), Some(wl)) if el.len() != wl.len() => { // (Some(el), Some(wl)) if el.len() != wl.len() => {
return Ok(WasmDiffResult { // return Ok(WasmDiffResult {
status: vec![WasmDiffStatus::Bad( // status: vec![WasmDiffStatus::Bad(
format!( // format!(
"Property list length mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property list length mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = emacs_field, // property = emacs_field,
emacs = el.len(), // emacs = el.len(),
wasm = wl.len() // wasm = wl.len()
) // )
.into(), // .into(),
)], // )],
children: Vec::new(), // children: Vec::new(),
name: "".into(), // name: "".into(),
}); // });
} // }
(Some(el), Some(wl)) => { // (Some(el), Some(wl)) => {
for (e, w) in el.iter().zip(wl) { // for (e, w) in el.iter().zip(wl) {
let e = unquote(e.as_atom()?)?; // let e = unquote(e.as_atom()?)?;
let w = w.as_ref(); // let w = w.as_ref();
if e != w { // if e != w {
result.status.push(WasmDiffStatus::Bad( // result.status.push(WasmDiffStatus::Bad(
format!( // format!(
"Property list value mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property list value mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = emacs_field, // property = emacs_field,
emacs = e, // emacs = e,
wasm = w // wasm = w
) // )
.into(), // .into(),
)); // ));
} // }
} // }
} // }
}; // };
Ok(result) // Ok(result)
} // }
pub(crate) fn wasm_compare_property_optional_pair< // pub(crate) fn wasm_compare_property_optional_pair<
'b, // 'b,
's, // 's,
W, // W,
WV: AsRef<str> + std::fmt::Debug, // WV: AsRef<str> + std::fmt::Debug,
WOV: AsRef<str> + std::fmt::Debug, // WOV: AsRef<str> + std::fmt::Debug,
WG: Fn(W) -> Option<(Option<WOV>, WV)>, // WG: Fn(W) -> Option<(Option<WOV>, WV)>,
>( // >(
_source: &'s str, // _source: &'s str,
emacs: &'b Token<'s>, // emacs: &'b Token<'s>,
wasm_node: W, // wasm_node: W,
emacs_field: &str, // emacs_field: &str,
wasm_value_getter: WG, // wasm_value_getter: WG,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> { // ) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default(); // let mut result = WasmDiffResult::default();
let emacs_value = get_property(emacs, emacs_field)? // let emacs_value = get_property(emacs, emacs_field)?
.map(Token::as_list) // .map(Token::as_list)
.map_or(Ok(None), |r| r.map(Some))?; // .map_or(Ok(None), |r| r.map(Some))?;
let wasm_value = wasm_value_getter(wasm_node); // let wasm_value = wasm_value_getter(wasm_node);
match (emacs_value, &wasm_value) { // match (emacs_value, &wasm_value) {
(None, None) => {} // (None, None) => {}
(None, Some(_)) | (Some(_), None) => { // (None, Some(_)) | (Some(_), None) => {
return Ok(WasmDiffResult { // return Ok(WasmDiffResult {
status: vec![WasmDiffStatus::Bad( // status: vec![WasmDiffStatus::Bad(
format!( // format!(
"Property list length mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property list length mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = emacs_field, // property = emacs_field,
emacs = if emacs_value.is_some() {"Some"} else {"None"}, // emacs = if emacs_value.is_some() {"Some"} else {"None"},
wasm = if !emacs_value.is_some() {"Some"} else {"None"} // wasm = if !emacs_value.is_some() {"Some"} else {"None"}
) // )
.into(), // .into(),
)], // )],
children: Vec::new(), // children: Vec::new(),
name: "".into(), // name: "".into(),
}); // });
} // }
(Some(el), Some((Some(owl), wl))) if el.len() == 3 => { // (Some(el), Some((Some(owl), wl))) if el.len() == 3 => {
let e = el // let e = el
.first() // .first()
.map(Token::as_atom) // .map(Token::as_atom)
.map_or(Ok(None), |r| r.map(Some))? // .map_or(Ok(None), |r| r.map(Some))?
.map(unquote) // .map(unquote)
.map_or(Ok(None), |r| r.map(Some))? // .map_or(Ok(None), |r| r.map(Some))?
.expect("Above match proved length to be 3."); // .expect("Above match proved length to be 3.");
let oe = el // let oe = el
.get(2) // .get(2)
.map(Token::as_atom) // .map(Token::as_atom)
.map_or(Ok(None), |r| r.map(Some))? // .map_or(Ok(None), |r| r.map(Some))?
.map(unquote) // .map(unquote)
.map_or(Ok(None), |r| r.map(Some))? // .map_or(Ok(None), |r| r.map(Some))?
.expect("Above match proved length to be 3."); // .expect("Above match proved length to be 3.");
let w = wl.as_ref(); // let w = wl.as_ref();
let ow = owl.as_ref(); // let ow = owl.as_ref();
if e != w { // if e != w {
result.status.push(WasmDiffStatus::Bad( // result.status.push(WasmDiffStatus::Bad(
format!( // format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "end", // property = "end",
emacs = e, // emacs = e,
wasm = w, // wasm = w,
) // )
.into(), // .into(),
)); // ));
} // }
if oe != ow { // if oe != ow {
result.status.push(WasmDiffStatus::Bad( // result.status.push(WasmDiffStatus::Bad(
format!( // format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "end", // property = "end",
emacs = oe, // emacs = oe,
wasm = ow, // wasm = ow,
) // )
.into(), // .into(),
)); // ));
} // }
} // }
(Some(el), Some((None, wl))) if el.len() == 1 => { // (Some(el), Some((None, wl))) if el.len() == 1 => {
let e = el // let e = el
.first() // .first()
.map(Token::as_atom) // .map(Token::as_atom)
.map_or(Ok(None), |r| r.map(Some))? // .map_or(Ok(None), |r| r.map(Some))?
.map(unquote) // .map(unquote)
.map_or(Ok(None), |r| r.map(Some))? // .map_or(Ok(None), |r| r.map(Some))?
.expect("Above match proved length to be 3."); // .expect("Above match proved length to be 3.");
let w = wl.as_ref(); // let w = wl.as_ref();
if e != w { // if e != w {
result.status.push(WasmDiffStatus::Bad( // result.status.push(WasmDiffStatus::Bad(
format!( // format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "end", // property = "end",
emacs = e, // emacs = e,
wasm = w, // wasm = w,
) // )
.into(), // .into(),
)); // ));
} // }
} // }
(Some(el), Some(_)) => { // (Some(el), Some(_)) => {
return Ok(WasmDiffResult { // return Ok(WasmDiffResult {
status: vec![WasmDiffStatus::Bad( // status: vec![WasmDiffStatus::Bad(
format!( // format!(
"Property list length mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property list length mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = emacs_field, // property = emacs_field,
emacs = el.len(), // emacs = el.len(),
wasm = wasm_value // wasm = wasm_value
) // )
.into(), // .into(),
)], // )],
children: Vec::new(), // children: Vec::new(),
name: "".into(), // name: "".into(),
}); // });
} // }
} // }
Ok(result) // Ok(result)
} // }
pub(crate) fn wasm_compare_standard_properties<'b, 's>( // pub(crate) fn wasm_compare_standard_properties<'b, 's>(
_source: &'s str, // _source: &'s str,
emacs: &'b Token<'s>, // emacs: &'b Token<'s>,
wasm: &WasmStandardProperties, // wasm: &WasmStandardProperties,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> { // ) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default(); // let mut result = WasmDiffResult::default();
let mut layer = WasmDiffResult::default(); // let mut layer = WasmDiffResult::default();
layer.name = "standard-properties".into(); // layer.name = "standard-properties".into();
let standard_properties = get_emacs_standard_properties(emacs)?; // let standard_properties = get_emacs_standard_properties(emacs)?;
if Some(wasm.begin) != standard_properties.begin { // if Some(wasm.begin) != standard_properties.begin {
layer.status.push(WasmDiffStatus::Bad( // layer.status.push(WasmDiffStatus::Bad(
format!( // format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "begin", // property = "begin",
emacs = standard_properties.begin, // emacs = standard_properties.begin,
wasm = Some(wasm.begin), // wasm = Some(wasm.begin),
) // )
.into(), // .into(),
)); // ));
} // }
if Some(wasm.end) != standard_properties.end { // if Some(wasm.end) != standard_properties.end {
layer.status.push(WasmDiffStatus::Bad( // layer.status.push(WasmDiffStatus::Bad(
format!( // format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "end", // property = "end",
emacs = standard_properties.end, // emacs = standard_properties.end,
wasm = Some(wasm.end), // wasm = Some(wasm.end),
) // )
.into(), // .into(),
)); // ));
} // }
if wasm.contents_begin != standard_properties.contents_begin { // if wasm.contents_begin != standard_properties.contents_begin {
layer.status.push(WasmDiffStatus::Bad( // layer.status.push(WasmDiffStatus::Bad(
format!( // format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "contents-begin", // property = "contents-begin",
emacs = standard_properties.contents_begin, // emacs = standard_properties.contents_begin,
wasm = wasm.contents_begin, // wasm = wasm.contents_begin,
) // )
.into(), // .into(),
)); // ));
} // }
if wasm.contents_end != standard_properties.contents_end { // if wasm.contents_end != standard_properties.contents_end {
layer.status.push(WasmDiffStatus::Bad( // layer.status.push(WasmDiffStatus::Bad(
format!( // format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "contents-end", // property = "contents-end",
emacs = standard_properties.contents_end, // emacs = standard_properties.contents_end,
wasm = wasm.contents_end, // wasm = wasm.contents_end,
) // )
.into(), // .into(),
)); // ));
} // }
if Some(wasm.post_blank).map(|post_blank| post_blank as usize) != standard_properties.post_blank // if Some(wasm.post_blank).map(|post_blank| post_blank as usize) != standard_properties.post_blank
{ // {
layer.status.push(WasmDiffStatus::Bad( // layer.status.push(WasmDiffStatus::Bad(
format!( // format!(
"Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).", // "Property mismatch. Property=({property}) Emacs=({emacs:?}) Wasm=({wasm:?}).",
property = "post-blank", // property = "post-blank",
emacs = standard_properties.post_blank, // emacs = standard_properties.post_blank,
wasm = Some(wasm.post_blank), // wasm = Some(wasm.post_blank),
) // )
.into(), // .into(),
)); // ));
} // }
result.children.push(layer); // result.children.push(layer);
Ok(result) // Ok(result)
} // }
pub(crate) fn wasm_compare_additional_properties<'b, 's>( // pub(crate) fn wasm_compare_additional_properties<'b, 's>(
source: &'s str, // source: &'s str,
emacs: &'b Token<'s>, // emacs: &'b Token<'s>,
wasm: &AdditionalProperties<'_, '_>, // wasm: &AdditionalProperties<'_, '_>,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> { // ) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
let mut result = WasmDiffResult::default(); // let mut result = WasmDiffResult::default();
let mut layer = WasmDiffResult::default(); // let mut layer = WasmDiffResult::default();
layer.name = "additional-properties".into(); // layer.name = "additional-properties".into();
for (property_name, property_value) in wasm.properties.iter() { // for (property_name, property_value) in wasm.properties.iter() {
let emacs_property_name = format!(":{property_name}", property_name = property_name); // let emacs_property_name = format!(":{property_name}", property_name = property_name);
match property_value { // match property_value {
AdditionalPropertyValue::SingleString(wasm_value) => { // AdditionalPropertyValue::SingleString(wasm_value) => {
layer.extend(wasm_compare_property_quoted_string( // layer.extend(wasm_compare_property_quoted_string(
source, // source,
emacs, // emacs,
wasm, // wasm,
&emacs_property_name, // &emacs_property_name,
|_| Some(wasm_value), // |_| Some(wasm_value),
)?)?; // )?)?;
} // }
AdditionalPropertyValue::ListOfStrings(wasm_value) => { // AdditionalPropertyValue::ListOfStrings(wasm_value) => {
layer.extend(wasm_compare_property_list_of_quoted_string( // layer.extend(wasm_compare_property_list_of_quoted_string(
source, // source,
emacs, // emacs,
wasm, // wasm,
&emacs_property_name, // &emacs_property_name,
|_| Some(wasm_value.iter()), // |_| Some(wasm_value.iter()),
)?)?; // )?)?;
} // }
// TODO: similar to compare_affiliated_keywords // // TODO: similar to compare_affiliated_keywords
AdditionalPropertyValue::OptionalPair { optval, val } => { // AdditionalPropertyValue::OptionalPair { optval, val } => {
layer.extend(wasm_compare_property_optional_pair( // layer.extend(wasm_compare_property_optional_pair(
source, // source,
emacs, // emacs,
wasm, // wasm,
&emacs_property_name, // &emacs_property_name,
|_| Some((*optval, *val)), // |_| Some((*optval, *val)),
)?)?; // )?)?;
} // }
AdditionalPropertyValue::ObjectTree(_) => todo!(), // AdditionalPropertyValue::ObjectTree(_) => todo!(),
} // }
} // }
result.children.push(layer); // result.children.push(layer);
Ok(result) // Ok(result)
} // }

View File

@ -1,6 +1,5 @@
mod compare; mod compare;
mod diff; mod diff;
mod elisp_compare;
mod logic; mod logic;
mod macros; mod macros;
mod runner; mod runner;

View File

@ -47,7 +47,7 @@ pub async fn wasm_run_anonymous_compare_with_settings<'g, 's, P: AsRef<str>>(
} }
// We do the diffing after printing out both parsed forms in case the diffing panics // We do the diffing after printing out both parsed forms in case the diffing panics
let diff_result = wasm_compare_document(org_contents, &parsed_sexp, wasm_parsed)?; let diff_result = wasm_compare_document(org_contents, &parsed_sexp, &wasm_parsed)?;
if !silent { if !silent {
diff_result.print(org_contents)?; diff_result.print(org_contents)?;
} }
@ -112,7 +112,7 @@ pub async fn wasm_run_compare_on_file_with_settings<'g, 's, P: AsRef<Path>>(
} }
// We do the diffing after printing out both parsed forms in case the diffing panics // We do the diffing after printing out both parsed forms in case the diffing panics
let diff_result = wasm_compare_document(org_contents, &parsed_sexp, wasm_parsed)?; let diff_result = wasm_compare_document(org_contents, &parsed_sexp, &wasm_parsed)?;
if !silent { if !silent {
diff_result.print(org_contents)?; diff_result.print(org_contents)?;
} }