Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take a byte slice instead of a vec in transpile #113

Merged
merged 3 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/self_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn main() -> Result<()> {
valid_lifting_optimization: false,
};

let transpiled = js_component_bindgen::transpile(adapted_component, opts)?;
let transpiled = js_component_bindgen::transpile(&adapted_component, opts)?;

for (filename, contents) in transpiled.files.iter() {
let outfile = PathBuf::from("./obj").join(filename);
Expand Down
2 changes: 1 addition & 1 deletion crates/js-component-bindgen-component/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl JsComponentBindgen for JsComponentBindgenComponent {
files,
imports,
mut exports,
} = transpile(component, opts)
} = transpile(&component, opts)
.map_err(|e| format!("{:?}", e))
.map_err(|e| e.to_string())?;

Expand Down
6 changes: 3 additions & 3 deletions crates/js-component-bindgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn generate_types(
/// Generate the JS transpilation bindgen for a given Wasm component binary
/// Outputs the file map and import and export metadata for the Transpilation
#[cfg(feature = "transpile-bindgen")]
pub fn transpile(component: Vec<u8>, opts: TranspileOpts) -> Result<Transpiled, anyhow::Error> {
pub fn transpile(component: &[u8], opts: TranspileOpts) -> Result<Transpiled, anyhow::Error> {
let name = opts.name.clone();
let mut files = files::Files::default();

Expand All @@ -89,7 +89,7 @@ pub fn transpile(component: Vec<u8>, opts: TranspileOpts) -> Result<Transpiled,
// package which has a single document and `world` within it which describes
// the state of the component. This is then further used afterwards for
// bindings Transpilation as-if a `*.wit` file was input.
let decoded = wit_component::decode(&component)
let decoded = wit_component::decode(component)
.context("failed to extract interface information from component")?;

let (resolve, world_id) = match decoded {
Expand Down Expand Up @@ -120,7 +120,7 @@ pub fn transpile(component: Vec<u8>, opts: TranspileOpts) -> Result<Transpiled,
});

let (component, modules) = Translator::new(&tunables, &mut validator, &mut types, &scope)
.translate(&component)
.translate(component)
.context("failed to parse the input component")?;

// Insert all core wasm modules into the generated `Files` which will
Expand Down
Loading