/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use anyhow::{Context, Result}; use askama::Template; use camino::{Utf8Path, Utf8PathBuf}; use clap::Parser; use serde::{Deserialize, Serialize}; use std::collections::HashSet; use std::fs::File; use std::io::Write;
mod ci_list; mod docs; mod render;
use ci_list::{CallbackIds, ComponentUniverse, FunctionIds, ObjectIds}; use render::cpp::CPPScaffoldingTemplate; use render::js::JSBindingsTemplate;
#[derive(Debug, Parser)] #[clap(name = "uniffi-bindgen-gecko-js")] #[clap(version = clap::crate_version!())] #[clap(about = "JS bindings generator for Rust")] #[clap(propagate_version = true)] struct CliArgs { // This is a really convoluted set of arguments, but we're only expecting to be called by // `mach_commands.py` #[clap(long, value_name = "FILE")]
library_path: Utf8PathBuf,
type Component = uniffi_bindgen::Component<Config>;
/// Configuration for a single Component #[derive(Clone, Debug, Default, Deserialize, Serialize)] pubstruct Config { #[serde(default)]
async_wrappers: AsyncWrappersConfig,
}
#[derive(Clone, Debug, Default, Deserialize, Serialize)] struct AsyncWrappersConfig { /// This converts synchronous Rust functions into async JS functions, by wrapping them at the /// C++ layer. #[serde(default)]
enable: bool, /// Functions that should be run on the main thread and not be wrapped #[serde(default)]
main_thread: HashSet<String>,
}
fn render(out_path: Utf8PathBuf, template: impl Template) -> Result<()> {
println!("rendering {}", out_path); let contents = template.render()?; letmut f =
File::create(&out_path).context(format!("Failed to create {:?}", out_path.file_name()))?;
write!(f, "{}\n", contents).context(format!("Failed to write to {}", out_path))
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.