diff --git a/Cargo.toml b/Cargo.toml index 33b11d0d..bc507dc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,6 @@ documentation = "https://nsoiffer.github.io/MathCAT/" edition = "2018" exclude = ["src/main.rs"] # should have "Rules/", but then one can't run build.rs to build the zip file - # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] @@ -34,6 +33,7 @@ env_logger = "0.8.4" cfg-if = "1.0" zip = { version = "0.6.2", default-features = false, features = ["deflate"] } getrandom = { version = "0.2.3", features = ["js"] } +ext-php-rs = "0.10.0" # # dependencies because of need to build wasm version for file i/o # yew = "0.18.0" @@ -56,14 +56,15 @@ getrandom = { version = "0.2.3", features = ["js"] } # ] - [build-dependencies] bitflags = "1.2.1" phf = { version = "0.8.0", features = ["macros"] } zip = { version = "0.6.2", default-features = false, features = ["deflate"] } +cc = "1.0.79" +bindgen = "0.64.0" [lib] -name = "libmathcat" +name = "mathcat" crate-type = ["rlib", "cdylib"] [profile.release] diff --git a/src/lib.rs b/src/lib.rs index e68df217..f241a21f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,6 +61,7 @@ mod chemistry; pub mod shim_filesystem; // really just for override_file_for_debugging_rules, but the config seems to throw it off pub use shim_filesystem::ZIPPED_RULE_FILES; pub use interface::*; +pub use ext_php_rs::prelude::*; #[cfg(test)] pub fn init_logger() { @@ -115,3 +116,28 @@ pub fn are_strs_canonically_equal(test: &str, target: &str) -> bool { return are_strs_canonically_equal_with_locale(test, target, ", \u{00A0}\u{202F}", "."); } +#[php_function] +pub fn mathcat_set_rules_dir(dir: String) { + let _ = set_rules_dir(dir); +} + +#[php_function] +pub fn mathcat_set_mathml(mathml_str: String) -> String { + return set_mathml(mathml_str).unwrap(); +} + +#[php_function] +pub fn mathcat_get_spoken_text() -> String { + return get_spoken_text().unwrap(); +} + +#[php_function] +pub fn mathcat_set_preference(name: String, value: String) { + let _ = set_preference(name, value); +} + +#[php_module] +pub fn get_module(module: ModuleBuilder) -> ModuleBuilder { + module +} +