2023-12-29 15:03:36 -05:00
|
|
|
use serde::Deserialize;
|
2023-12-25 11:33:43 -05:00
|
|
|
use serde::Serialize;
|
|
|
|
|
|
2023-12-29 15:03:36 -05:00
|
|
|
use super::ast_node::WasmAstNode;
|
2023-12-25 11:33:43 -05:00
|
|
|
use super::macros::to_wasm;
|
2023-12-30 17:50:38 -05:00
|
|
|
use super::src_block::WasmNumberLines;
|
|
|
|
|
use super::src_block::WasmNumberLinesWrapper;
|
|
|
|
|
use super::src_block::WasmRetainLabels;
|
2023-12-25 11:33:43 -05:00
|
|
|
use super::to_wasm::ToWasm;
|
2023-12-29 15:03:36 -05:00
|
|
|
use super::AdditionalProperties;
|
2023-12-30 17:50:38 -05:00
|
|
|
use crate::types::CharOffsetInLine;
|
2023-12-27 11:36:47 -05:00
|
|
|
use crate::types::ExampleBlock;
|
2023-12-30 17:50:38 -05:00
|
|
|
use crate::types::GetAffiliatedKeywords;
|
|
|
|
|
use crate::types::RetainLabels;
|
|
|
|
|
use crate::types::SwitchNumberLines;
|
2023-12-30 22:42:14 -05:00
|
|
|
use crate::util::elisp_fact::ElispFact;
|
2023-12-25 11:33:43 -05:00
|
|
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
|
|
|
|
|
2023-12-29 15:03:36 -05:00
|
|
|
#[derive(Debug, Serialize, Deserialize)]
|
2023-12-29 12:49:43 -05:00
|
|
|
pub struct WasmExampleBlock {
|
2023-12-29 15:03:36 -05:00
|
|
|
#[serde(flatten)]
|
|
|
|
|
pub(crate) additional_properties: AdditionalProperties,
|
2023-12-30 17:50:38 -05:00
|
|
|
pub(crate) value: String,
|
|
|
|
|
pub(crate) switches: Option<String>,
|
|
|
|
|
#[serde(rename = "number-lines")]
|
|
|
|
|
pub(crate) number_lines: Option<WasmNumberLinesWrapper>,
|
|
|
|
|
#[serde(rename = "preserve-indent")]
|
|
|
|
|
pub(crate) preserve_indent: Option<CharOffsetInLine>,
|
|
|
|
|
#[serde(rename = "retain-labels")]
|
|
|
|
|
pub(crate) retain_labels: WasmRetainLabels,
|
|
|
|
|
#[serde(rename = "use-labels")]
|
|
|
|
|
pub(crate) use_labels: bool,
|
|
|
|
|
#[serde(rename = "label-fmt")]
|
|
|
|
|
pub(crate) label_format: Option<String>,
|
2023-12-25 11:33:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
to_wasm!(
|
2023-12-29 12:49:43 -05:00
|
|
|
WasmExampleBlock,
|
2023-12-25 11:51:39 -05:00
|
|
|
ExampleBlock<'s>,
|
2023-12-25 12:32:35 -05:00
|
|
|
original,
|
2023-12-25 11:33:43 -05:00
|
|
|
wasm_context,
|
2023-12-29 15:03:36 -05:00
|
|
|
{ WasmAstNode::ExampleBlock(original) },
|
2023-12-30 17:50:38 -05:00
|
|
|
{ "example-block".into() },
|
2023-12-25 11:33:43 -05:00
|
|
|
{
|
2023-12-30 17:50:38 -05:00
|
|
|
let additional_properties = original
|
|
|
|
|
.get_affiliated_keywords()
|
|
|
|
|
.to_wasm(wasm_context.clone())?;
|
|
|
|
|
|
2023-12-29 15:03:36 -05:00
|
|
|
Ok((
|
|
|
|
|
Vec::new(),
|
|
|
|
|
WasmExampleBlock {
|
2023-12-30 17:50:38 -05:00
|
|
|
additional_properties,
|
|
|
|
|
value: original.get_value().into_owned(),
|
|
|
|
|
switches: original.switches.map(|s| s.to_owned()),
|
|
|
|
|
number_lines: match original.number_lines {
|
|
|
|
|
None => None,
|
|
|
|
|
Some(SwitchNumberLines::New(n)) => Some(WasmNumberLinesWrapper {
|
|
|
|
|
inner: WasmNumberLines::New(n),
|
|
|
|
|
}),
|
|
|
|
|
Some(SwitchNumberLines::Continued(n)) => Some(WasmNumberLinesWrapper {
|
2023-12-30 22:42:14 -05:00
|
|
|
inner: WasmNumberLines::Continued(n),
|
2023-12-30 17:50:38 -05:00
|
|
|
}),
|
|
|
|
|
},
|
|
|
|
|
preserve_indent: original.preserve_indent,
|
|
|
|
|
retain_labels: match original.retain_labels {
|
|
|
|
|
RetainLabels::No => WasmRetainLabels::YesNo(false),
|
|
|
|
|
RetainLabels::Yes => WasmRetainLabels::YesNo(true),
|
|
|
|
|
RetainLabels::Keep(n) => WasmRetainLabels::Keep(n),
|
|
|
|
|
},
|
|
|
|
|
use_labels: original.use_labels,
|
|
|
|
|
label_format: original.label_format.map(|s| s.to_owned()),
|
2023-12-29 15:03:36 -05:00
|
|
|
},
|
|
|
|
|
))
|
2023-12-25 11:33:43 -05:00
|
|
|
}
|
|
|
|
|
);
|