Implement table.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
|
||||
@@ -6,6 +8,7 @@ use super::macros::to_wasm;
|
||||
use super::to_wasm::ToWasm;
|
||||
use super::AdditionalProperties;
|
||||
use crate::compare::ElispFact;
|
||||
use crate::types::GetAffiliatedKeywords;
|
||||
use crate::types::Table;
|
||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||
|
||||
@@ -13,6 +16,18 @@ use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||
pub struct WasmTable {
|
||||
#[serde(flatten)]
|
||||
pub(crate) additional_properties: AdditionalProperties,
|
||||
#[serde(rename = "tblfm")]
|
||||
pub(crate) formulas: Option<WasmStringSet>,
|
||||
#[serde(rename = "type")]
|
||||
pub(crate) table_type: String,
|
||||
pub(crate) value: Option<String>, // Always None
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
#[serde(tag = "string-set")]
|
||||
#[serde(rename = "string-set")]
|
||||
struct WasmStringSet {
|
||||
value: BTreeSet<String>,
|
||||
}
|
||||
|
||||
to_wasm!(
|
||||
@@ -21,8 +36,12 @@ to_wasm!(
|
||||
original,
|
||||
wasm_context,
|
||||
{ WasmAstNode::Table(original) },
|
||||
{ "TODO".into() },
|
||||
{ "table".into() },
|
||||
{
|
||||
let additional_properties = original
|
||||
.get_affiliated_keywords()
|
||||
.to_wasm(wasm_context.clone())?;
|
||||
|
||||
let children = original
|
||||
.children
|
||||
.iter()
|
||||
@@ -36,7 +55,20 @@ to_wasm!(
|
||||
Ok((
|
||||
children,
|
||||
WasmTable {
|
||||
additional_properties: AdditionalProperties::default(),
|
||||
additional_properties,
|
||||
formulas: if original.formulas.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(WasmStringSet {
|
||||
value: original
|
||||
.formulas
|
||||
.iter()
|
||||
.map(|kw| kw.value.to_owned())
|
||||
.collect(),
|
||||
})
|
||||
},
|
||||
table_type: "org".to_owned(),
|
||||
value: None,
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user