-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Arithmetic working with WASM! (#188)
This is the first cut of a Rust generator, enough to run the `fixture/arithmetic`. Unfortunately due to mozilla/uniffi-rs#2329 not yet released, we have to introduce a procmacro version of the fixture. In this PR: 1. Introduce a Rust crate generator; this uses 2. a runtime which uses typealiasing and import renaming to use `wasm-bindgen` indirectly in the generated code. 3. the generated code needs a CallStatus to be defined in Rust; this differs from the JSI version where the CallStatus is defined in typescript. So the `rust-call.ts` module is made into a class with three methods instead of three functions. 4. the generated Rust is then compiled and put through wasm-bindgen-cli where it generates a low-level JS file. 5. the high level typescript now uses the flavor to decide whether it uses the JSI generated typescript or the WASM, and which implementation of the CallStatus. 6. Uses `tsx` to run the whole thing.
- Loading branch information
Showing
40 changed files
with
1,320 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
*/ | ||
use anyhow::Result; | ||
|
||
use crate::{AbiFlavor, ModuleMetadata, SwitchArgs}; | ||
|
||
use super::gen_cpp; | ||
#[cfg(feature = "wasm")] | ||
use super::gen_rust; | ||
|
||
pub fn generate_entrypoint(switches: &SwitchArgs, modules: &Vec<ModuleMetadata>) -> Result<String> { | ||
match &switches.flavor { | ||
AbiFlavor::Jsi => gen_cpp::generate_entrypoint(modules), | ||
#[cfg(feature = "wasm")] | ||
AbiFlavor::Wasm => gen_rust::generate_entrypoint(modules), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/ | ||
*/ | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, Default, Serialize, Deserialize)] | ||
#[serde(rename_all = "camelCase")] | ||
pub(crate) struct RustConfig {} |
Oops, something went wrong.