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
68 changed files with 2438 additions and 2472 deletions

View File

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