Implement org macro.

This commit is contained in:
Tom Alexander 2023-12-30 12:40:12 -05:00
parent f2292f1c07
commit d0a008ed22
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
2 changed files with 31 additions and 10 deletions

View File

@ -4,15 +4,15 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::types::OrgMacro;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
pub struct WasmOrgMacro {
#[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties,
pub(crate) key: String,
pub(crate) value: String,
pub(crate) args: Vec<String>,
}
to_wasm!(
@ -21,12 +21,14 @@ to_wasm!(
original,
wasm_context,
{ WasmAstNode::OrgMacro(original) },
{ "TODO".into() },
{ "macro".into() },
{
Ok((
Vec::new(),
WasmOrgMacro {
additional_properties: AdditionalProperties::default(),
key: original.key.to_lowercase(),
value: original.value.to_owned(),
args: original.get_args().map(|s| s.into_owned()).collect(),
},
))
}

View File

@ -4,15 +4,23 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::types::LinkType;
use crate::types::PlainLink;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
#[serde(tag = "format")]
#[serde(rename = "plain")]
pub struct WasmPlainLink {
#[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties,
#[serde(rename = "type")]
pub(crate) link_type: String,
pub(crate) path: String,
#[serde(rename = "raw-link")]
pub(crate) raw_link: String,
pub(crate) application: Option<String>,
#[serde(rename = "search-option")]
pub(crate) search_option: Option<String>,
}
to_wasm!(
@ -21,12 +29,23 @@ to_wasm!(
original,
wasm_context,
{ WasmAstNode::PlainLink(original) },
{ "TODO".into() },
{ "link".into() },
{
Ok((
Vec::new(),
WasmPlainLink {
additional_properties: AdditionalProperties::default(),
link_type: match &original.link_type {
LinkType::File => "file".to_owned(),
LinkType::Protocol(protocol) => protocol.clone().into_owned(),
LinkType::Id => "id".to_owned(),
LinkType::CustomId => "custom-id".to_owned(),
LinkType::CodeRef => "coderef".to_owned(),
LinkType::Fuzzy => "fuzzy".to_owned(),
},
path: original.path.to_owned(),
raw_link: original.raw_link.to_owned(),
application: original.application.map(str::to_owned),
search_option: original.search_option.map(str::to_owned),
},
))
}