Implement example block and export block.
This commit is contained in:
parent
60a4835590
commit
3131f8ac64
@ -3,16 +3,35 @@ use serde::Serialize;
|
|||||||
|
|
||||||
use super::ast_node::WasmAstNode;
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
|
use super::src_block::WasmNumberLines;
|
||||||
|
use super::src_block::WasmNumberLinesWrapper;
|
||||||
|
use super::src_block::WasmRetainLabels;
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use super::AdditionalProperties;
|
use super::AdditionalProperties;
|
||||||
use crate::compare::ElispFact;
|
use crate::compare::ElispFact;
|
||||||
|
use crate::types::CharOffsetInLine;
|
||||||
use crate::types::ExampleBlock;
|
use crate::types::ExampleBlock;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
|
use crate::types::RetainLabels;
|
||||||
|
use crate::types::SwitchNumberLines;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct WasmExampleBlock {
|
pub struct WasmExampleBlock {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub(crate) additional_properties: AdditionalProperties,
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
|
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>,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
@ -21,12 +40,35 @@ to_wasm!(
|
|||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
{ WasmAstNode::ExampleBlock(original) },
|
{ WasmAstNode::ExampleBlock(original) },
|
||||||
{ "TODO".into() },
|
{ "example-block".into() },
|
||||||
{
|
{
|
||||||
|
let additional_properties = original
|
||||||
|
.get_affiliated_keywords()
|
||||||
|
.to_wasm(wasm_context.clone())?;
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
WasmExampleBlock {
|
WasmExampleBlock {
|
||||||
additional_properties: AdditionalProperties::default(),
|
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 {
|
||||||
|
inner: WasmNumberLines::continued(n),
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
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()),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -7,12 +7,16 @@ use super::to_wasm::ToWasm;
|
|||||||
use super::AdditionalProperties;
|
use super::AdditionalProperties;
|
||||||
use crate::compare::ElispFact;
|
use crate::compare::ElispFact;
|
||||||
use crate::types::ExportBlock;
|
use crate::types::ExportBlock;
|
||||||
|
use crate::types::GetAffiliatedKeywords;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct WasmExportBlock {
|
pub struct WasmExportBlock {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub(crate) additional_properties: AdditionalProperties,
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
|
#[serde(rename = "type")]
|
||||||
|
pub(crate) export_type: Option<String>,
|
||||||
|
pub(crate) value: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
@ -21,12 +25,18 @@ to_wasm!(
|
|||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
{ WasmAstNode::ExportBlock(original) },
|
{ WasmAstNode::ExportBlock(original) },
|
||||||
{ "TODO".into() },
|
{ "export-block".into() },
|
||||||
{
|
{
|
||||||
|
let additional_properties = original
|
||||||
|
.get_affiliated_keywords()
|
||||||
|
.to_wasm(wasm_context.clone())?;
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
WasmExportBlock {
|
WasmExportBlock {
|
||||||
additional_properties: AdditionalProperties::default(),
|
additional_properties,
|
||||||
|
export_type: original.get_export_type(),
|
||||||
|
value: original.get_value().into_owned(),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -36,13 +36,13 @@ pub struct WasmSrcBlock {
|
|||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(untagged)]
|
#[serde(untagged)]
|
||||||
enum WasmRetainLabels {
|
pub(crate) enum WasmRetainLabels {
|
||||||
YesNo(bool),
|
YesNo(bool),
|
||||||
Keep(CharOffsetInLine),
|
Keep(CharOffsetInLine),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
enum WasmNumberLines {
|
pub(crate) enum WasmNumberLines {
|
||||||
#[serde(rename = "new")]
|
#[serde(rename = "new")]
|
||||||
New(LineNumber),
|
New(LineNumber),
|
||||||
#[serde(rename = "continued")]
|
#[serde(rename = "continued")]
|
||||||
@ -52,9 +52,9 @@ enum WasmNumberLines {
|
|||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[serde(rename = "number-lines")]
|
#[serde(rename = "number-lines")]
|
||||||
#[serde(tag = "number-lines")]
|
#[serde(tag = "number-lines")]
|
||||||
struct WasmNumberLinesWrapper {
|
pub(crate) struct WasmNumberLinesWrapper {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
inner: WasmNumberLines,
|
pub(crate) inner: WasmNumberLines,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user