Skip to content

Commit c498dca

Browse files
author
Guy Bedford
authored
deps: update to [email protected] (#152)
1 parent 2506561 commit c498dca

File tree

6 files changed

+587
-575
lines changed

6 files changed

+587
-575
lines changed

StarlingMonkey

Submodule StarlingMonkey updated 47 files

crates/spidermonkey-embedding-splicer/src/lib.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ impl Guest for SpidermonkeyEmbeddingSplicerComponent {
157157
let maybe_run = engine_resolve.worlds[engine_world]
158158
.exports
159159
.iter()
160-
.find(|(key, _)| engine_resolve.name_world_key(key) == "wasi:cli/[email protected]")
160+
.find(|(key, _)| {
161+
engine_resolve
162+
.name_world_key(key)
163+
.starts_with("wasi:cli/[email protected]")
164+
})
161165
.map(|(key, _)| key.clone());
162166
if let Some(run) = maybe_run {
163167
engine_resolve.worlds[engine_world]
@@ -169,7 +173,9 @@ impl Guest for SpidermonkeyEmbeddingSplicerComponent {
169173
.exports
170174
.iter()
171175
.find(|(key, _)| {
172-
engine_resolve.name_world_key(key) == "wasi:http/[email protected]"
176+
engine_resolve
177+
.name_world_key(key)
178+
.starts_with("wasi:http/[email protected]")
173179
})
174180
.map(|(key, _)| key.clone());
175181

crates/spidermonkey-embedding-splicer/src/splice.rs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ use wasmparser::Operator;
1111

1212
use crate::*;
1313

14+
const WASI_VERSIONS: [&str; 3] = ["0.2.0", "0.2.1", "0.2.2"];
15+
1416
//
1517
// Parses the Spidermonkey binary into section data for reserialization
1618
// into an output binary, and in the process:
@@ -44,31 +46,25 @@ pub fn splice(
4446

4547
// since StarlingMonkey implements CLI Run and incoming handler,
4648
// we override them only if the guest content exports those functions
47-
if exports
48-
.iter()
49-
.any(|(name, _)| name == "wasi:cli/[email protected]#run")
50-
{
51-
if let Some(run) = module
52-
.exports
53-
.get_func_by_name("wasi:cli/[email protected]#run".to_string())
54-
{
55-
let expt = module.exports.get_func_by_id(run).unwrap();
56-
module.exports.delete(expt);
57-
module.delete_func(run); // TODO: Look at the intended behaviour here. Need to pass function ID to delete from functions. Was Previously passing Exports ID
49+
for wasi_version in WASI_VERSIONS {
50+
let import = format!("wasi:cli/run@{wasi_version}#run");
51+
if exports.iter().any(|(name, _)| *name == import) {
52+
if let Some(run) = module.exports.get_func_by_name(import) {
53+
let expt = module.exports.get_func_by_id(run).unwrap();
54+
module.exports.delete(expt);
55+
module.delete_func(run); // TODO: Look at the intended behaviour here. Need to pass function ID to delete from functions. Was Previously passing Exports ID
56+
}
5857
}
5958
}
6059

61-
if exports
62-
.iter()
63-
.any(|(name, _)| name == "wasi:http/[email protected]#handle")
64-
{
65-
if let Some(serve) = module
66-
.exports
67-
.get_func_by_name("wasi:http/[email protected]#handle".to_string())
68-
{
69-
let expt = module.exports.get_func_by_id(serve).unwrap();
70-
module.exports.delete(expt);
71-
module.delete_func(serve); // TODO: Look at the intended behaviour here. Same as above comment
60+
for wasi_version in WASI_VERSIONS {
61+
let import = format!("wasi:http/incoming-handler@{wasi_version}#handle");
62+
if exports.iter().any(|(name, _)| *name == import) {
63+
if let Some(serve) = module.exports.get_func_by_name(import) {
64+
let expt = module.exports.get_func_by_id(serve).unwrap();
65+
module.exports.delete(expt);
66+
module.delete_func(serve); // TODO: Look at the intended behaviour here. Same as above comment
67+
}
7268
}
7369
}
7470

0 commit comments

Comments
 (0)