Skip to content
Closed
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
20 changes: 9 additions & 11 deletions crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1193,16 +1193,14 @@ __wbg_set_wasm(wasm);"
wasm_bindgen_shared::free_function(name),
));
ts_dst.push_str(" free(): void;\n");
if self.config.symbol_dispose {
dst.push_str(
"
[Symbol.dispose]() {{
this.free();
}}
",
);
ts_dst.push_str(" [Symbol.dispose](): void;\n");
}
dst.push_str(
"
[Symbol.dispose]() {{
this.free();
}}
",
);
ts_dst.push_str(" [Symbol.dispose](): void;\n");
dst.push_str(&class.contents);
ts_dst.push_str(&class.typescript);

Expand Down Expand Up @@ -2724,7 +2722,7 @@ __wbg_set_wasm(wasm);"
pub fn generate(&mut self) -> Result<(), Error> {
self.prestore_global_import_identifiers()?;
// conditionally override Symbol.dispose
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the wording here is misleading, as its not actually overriding anything.

Am I missing something here?
Or is this just JS terminology?

if self.config.symbol_dispose && !self.aux.structs.is_empty() {
if !self.aux.structs.is_empty() {
self.expose_symbol_dispose()?;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not completely sure if I should remove expose_symbol_dispose() as well.

}

Expand Down
3 changes: 0 additions & 3 deletions crates/cli-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pub struct Bindgen {
multi_value: bool,
encode_into: EncodeInto,
split_linked_modules: bool,
symbol_dispose: bool,
}

pub struct Output {
Expand Down Expand Up @@ -86,7 +85,6 @@ impl Bindgen {
let externref =
env::var("WASM_BINDGEN_ANYREF").is_ok() || env::var("WASM_BINDGEN_EXTERNREF").is_ok();
let multi_value = env::var("WASM_BINDGEN_MULTI_VALUE").is_ok();
let symbol_dispose = env::var("WASM_BINDGEN_EXPERIMENTAL_SYMBOL_DISPOSE").is_ok();
Bindgen {
input: Input::None,
out_name: None,
Expand All @@ -107,7 +105,6 @@ impl Bindgen {
encode_into: EncodeInto::Test,
omit_default_module_path: true,
split_linked_modules: false,
symbol_dispose,
}
}

Expand Down
2 changes: 1 addition & 1 deletion examples/explicit-resource-management/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
set -eux

cargo build --target wasm32-unknown-unknown --release
WASM_BINDGEN_EXPERIMENTAL_SYMBOL_DISPOSE=1 cargo run --package wasm-bindgen-cli --bin wasm-bindgen -- \
cargo run --package wasm-bindgen-cli --bin wasm-bindgen -- \
--out-dir pkg --target deno ${CARGO_TARGET_DIR:-../../target}/wasm32-unknown-unknown/release/explicit_resource_management.wasm
Loading