8 Commits

Author SHA1 Message Date
Tom Alexander
13863a68f7 Add placeholders for all the wasm ast nodes. 2023-12-25 11:33:43 -05:00
Tom Alexander
2962f76c81 Add lifetime to wasm objects. 2023-12-25 11:19:09 -05:00
Tom Alexander
b9b3ef6e74 Populate standard properties. 2023-12-25 10:47:10 -05:00
Tom Alexander
310ab2eab2 Add standard properties to wasm. 2023-12-24 15:26:45 -05:00
Tom Alexander
53320070da Define a wasm document. 2023-12-24 15:17:41 -05:00
Tom Alexander
2d5593681f Start defining the return type. 2023-12-24 13:02:34 -05:00
Tom Alexander
b3f97dbb40 Add wasm-bindgen. 2023-12-24 00:59:41 -05:00
Tom Alexander
a48d76321e Building basic wasm. 2023-12-24 00:47:32 -05:00
66 changed files with 2158 additions and 0 deletions

View File

@@ -39,17 +39,25 @@ path = "src/lib.rs"
path = "src/bin_foreign_document_test.rs"
required-features = ["foreign_document_test"]
[[bin]]
name = "wasm"
path = "src/bin_wasm.rs"
required-features = ["wasm"]
[dependencies]
futures = { version = "0.3.28", optional = true }
nom = "7.1.1"
opentelemetry = { version = "0.20.0", optional = true, default-features = false, features = ["trace", "rt-tokio"] }
opentelemetry-otlp = { version = "0.13.0", optional = true }
opentelemetry-semantic-conventions = { version = "0.12.0", optional = true }
serde = { version = "1.0.193", optional = true, features = ["derive"] }
serde-wasm-bindgen = { version = "0.6.3", optional = true }
tokio = { version = "1.30.0", optional = true, default-features = false, features = ["rt", "rt-multi-thread"] }
tracing = { version = "0.1.37", optional = true }
tracing-opentelemetry = { version = "0.20.0", optional = true }
tracing-subscriber = { version = "0.3.17", optional = true, features = ["env-filter"] }
walkdir = { version = "2.3.3", optional = true }
wasm-bindgen = { version = "0.2.89", optional = true }
[build-dependencies]
walkdir = "2.3.3"
@@ -60,6 +68,7 @@ compare = ["tokio/process", "tokio/macros"]
foreign_document_test = ["compare", "dep:futures", "tokio/sync", "dep:walkdir", "tokio/process"]
tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"]
event_count = []
wasm = ["dep:serde", "dep:wasm-bindgen", "dep:serde-wasm-bindgen"]
# Optimized build for any sort of release.
[profile.release-lto]
@@ -79,3 +88,8 @@ strip = "symbols"
inherits = "release"
lto = true
debug = true
[profile.wasm]
inherits = "release"
lto = true
strip = true

View File

@@ -29,6 +29,11 @@ build:
release:
> cargo build --release $(RELEASEFLAGS)
.PHONY: wasm
wasm:
> cargo build --target=wasm32-unknown-unknown --profile wasm --bin wasm --features wasm
> wasm-bindgen --target web --out-dir target/wasm32-unknown-unknown/js target/wasm32-unknown-unknown/wasm/wasm.wasm
.PHONY: clean
clean:
> cargo clean

27
src/bin_wasm.rs Normal file
View File

@@ -0,0 +1,27 @@
#![no_main]
use organic::parser::parse_with_settings;
use organic::settings::GlobalSettings;
use wasm::ParseResult;
use wasm::ToWasm;
use wasm::ToWasmContext;
use wasm_bindgen::prelude::wasm_bindgen;
mod error;
mod wasm;
#[wasm_bindgen]
pub fn parse_org(org_contents: &str) -> wasm_bindgen::JsValue {
let global_settings = GlobalSettings::default();
let to_wasm_context = ToWasmContext::new(org_contents);
let rust_parsed = match parse_with_settings(org_contents, &global_settings)
.map(|document| document.to_wasm(to_wasm_context))
.map(|wasm_document| match wasm_document {
Ok(wasm_document) => ParseResult::Success(wasm_document),
Err(err) => ParseResult::Error(format!("{:?}", err)),
}) {
Ok(wasm_document) => wasm_document,
Err(err) => ParseResult::Error(format!("{:?}", err)),
};
serde_wasm_bindgen::to_value(&rust_parsed).unwrap()
}

33
src/wasm/angle_link.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/babel_call.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/bold.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/center_block.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/citation.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/clock.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/code.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/comment.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/comment_block.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/diary_sexp.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/document.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/drawer.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/dynamic_block.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/entity.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/example_block.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/export_block.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/headline.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/italic.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/keyword.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/line_break.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

20
src/wasm/macros.rs Normal file
View File

@@ -0,0 +1,20 @@
/// Write the implementation for the intermediate ast node.
///
/// This exists to make changing the type signature easier.
macro_rules! to_wasm {
($ostruct:ty, $istruct:ty, $wasm_context:ident, $standard_properties:ident, $fnbody:tt) => {
impl<'s> ToWasm for $istruct {
type Output = $ostruct;
fn to_wasm(
&self,
$wasm_context: crate::wasm::to_wasm::ToWasmContext<'_>,
) -> Result<Self::Output, crate::error::CustomError> {
let $standard_properties = self.to_wasm_standard_properties($wasm_context)?;
$fnbody
}
}
};
}
pub(crate) use to_wasm;

66
src/wasm/mod.rs Normal file
View File

@@ -0,0 +1,66 @@
mod angle_link;
mod babel_call;
mod bold;
mod center_block;
mod citation;
mod citation_reference;
mod clock;
mod code;
mod comment;
mod comment_block;
mod diary_sexp;
mod document;
mod drawer;
mod dynamic_block;
mod entity;
mod example_block;
mod export_block;
mod export_snippet;
mod fixed_width_area;
mod footnote_definition;
mod footnote_reference;
mod headline;
mod horizontal_rule;
mod inline_babel_call;
mod inline_source_block;
mod italic;
mod keyword;
mod latex_environment;
mod latex_fragment;
mod line_break;
mod macros;
mod node_property;
mod org_macro;
mod paragraph;
mod parse_result;
mod plain_link;
mod plain_list;
mod plain_list_item;
mod plain_text;
mod planning;
mod property_drawer;
mod quote_block;
mod radio_link;
mod radio_target;
mod regular_link;
mod section;
mod special_block;
mod src_block;
mod standard_properties;
mod statistics_cookie;
mod strike_through;
mod subscript;
mod superscript;
mod table;
mod table_cell;
mod table_row;
mod target;
mod timestamp;
mod to_wasm;
mod underline;
mod verbatim;
mod verse_block;
pub(crate) use parse_result::ParseResult;
pub(crate) use to_wasm::ToWasm;
pub(crate) use to_wasm::ToWasmContext;

33
src/wasm/node_property.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/org_macro.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/paragraph.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

14
src/wasm/parse_result.rs Normal file
View File

@@ -0,0 +1,14 @@
use serde::Deserialize;
use serde::Serialize;
use super::document::WasmDocument;
#[derive(Serialize, Deserialize)]
#[serde(tag = "status", content = "content")]
pub(crate) enum ParseResult<'s> {
#[serde(rename = "success")]
Success(WasmDocument<'s>),
#[serde(rename = "error")]
Error(String),
}

33
src/wasm/plain_link.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/plain_list.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/plain_text.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/planning.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/quote_block.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/radio_link.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/radio_target.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/regular_link.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/section.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/special_block.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/src_block.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,71 @@
use organic::types::PostBlank;
use organic::types::StandardProperties;
use serde::Deserialize;
use serde::Serialize;
use super::to_wasm::ToWasmContext;
use super::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
pub(crate) struct WasmStandardProperties {
begin: usize,
end: usize,
contents_begin: Option<usize>,
contents_end: Option<usize>,
post_blank: PostBlank,
}
impl<'s, SP: StandardProperties<'s>> ToWasmStandardProperties for SP {
type Output = WasmStandardProperties;
fn to_wasm_standard_properties(
&self,
wasm_context: ToWasmContext<'_>,
) -> Result<Self::Output, crate::error::CustomError> {
let (begin, end) = get_char_indices(wasm_context.full_document, self.get_source());
let (contents_begin, contents_end) = match self.get_contents() {
Some(contents) => {
let (begin, end) = get_char_indices(wasm_context.full_document, contents);
(Some(begin), Some(end))
}
None => (None, None),
};
let post_blank = self.get_post_blank();
Ok(WasmStandardProperties {
begin,
end,
contents_begin,
contents_end,
post_blank,
})
}
}
fn get_char_indices(original_document: &str, subset: &str) -> (usize, usize) {
let (begin_byte, end_byte) = get_rust_byte_offsets(original_document, subset);
// Add 1 to make this 1-based to match emacs.
let begin_char = original_document[..begin_byte].chars().count() + 1;
// Also 1-based:
let end_char = begin_char + original_document[begin_byte..end_byte].chars().count();
(begin_char, end_char)
}
/// Get the byte offset into source that the string slice exists at.
///
/// These offsets are zero-based.
fn get_rust_byte_offsets(original_document: &str, subset: &str) -> (usize, usize) {
debug_assert!(is_slice_of(original_document, subset));
let offset = subset.as_ptr() as usize - original_document.as_ptr() as usize;
let end = offset + subset.len();
(offset, end)
}
/// Check if the child string slice is a slice of the parent string slice.
fn is_slice_of(parent: &str, child: &str) -> bool {
let parent_start = parent.as_ptr() as usize;
let parent_end = parent_start + parent.len();
let child_start = child.as_ptr() as usize;
let child_end = child_start + child.len();
child_start >= parent_start && child_end <= parent_end
}

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/subscript.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/superscript.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/table.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/table_cell.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/table_row.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/target.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/timestamp.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

27
src/wasm/to_wasm.rs Normal file
View File

@@ -0,0 +1,27 @@
use crate::error::CustomError;
pub(crate) trait ToWasm {
type Output;
fn to_wasm(&self, full_document: ToWasmContext<'_>) -> Result<Self::Output, CustomError>;
}
pub(crate) trait ToWasmStandardProperties {
type Output;
fn to_wasm_standard_properties(
&self,
wasm_context: ToWasmContext<'_>,
) -> Result<Self::Output, CustomError>;
}
#[derive(Debug, Clone)]
pub(crate) struct ToWasmContext<'s> {
pub(crate) full_document: &'s str,
}
impl<'s> ToWasmContext<'s> {
pub(crate) fn new(full_document: &'s str) -> ToWasmContext<'s> {
ToWasmContext { full_document }
}
}

33
src/wasm/underline.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/verbatim.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);

33
src/wasm/verse_block.rs Normal file
View File

@@ -0,0 +1,33 @@
use std::marker::PhantomData;
use organic::types::Document;
use serde::Deserialize;
use serde::Serialize;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Serialize, Deserialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
children: Vec<()>,
phantom: PhantomData<&'s ()>,
}
to_wasm!(
WasmDocument<'s>,
Document<'s>,
wasm_context,
standard_properties,
{
Ok(WasmDocument {
standard_properties,
children: Vec::new(),
phantom: PhantomData,
})
}
);