File tree Expand file tree Collapse file tree 8 files changed +15
-28
lines changed Expand file tree Collapse file tree 8 files changed +15
-28
lines changed Original file line number Diff line number Diff line change @@ -1080,15 +1080,20 @@ impl<'a> Context<'a> {
1080
1080
const ptr = this.__destroy_into_raw();
1081
1081
wasm.{}(ptr, 0);
1082
1082
}}
1083
-
1084
- [Symbol.dispose]() {{
1085
- this.free();
1086
- }}
1087
1083
" ,
1088
1084
wasm_bindgen_shared:: free_function( name) ,
1089
1085
) ) ;
1090
1086
ts_dst. push_str ( " free(): void;\n " ) ;
1091
- ts_dst. push_str ( " [Symbol.dispose](): void;\n " ) ;
1087
+ if self . config . symbol_dispose {
1088
+ dst. push_str (
1089
+ "
1090
+ [Symbol.dispose]() {{
1091
+ this.free();
1092
+ }}
1093
+ " ,
1094
+ ) ;
1095
+ ts_dst. push_str ( " [Symbol.dispose](): void;\n " ) ;
1096
+ }
1092
1097
dst. push_str ( & class. contents ) ;
1093
1098
ts_dst. push_str ( & class. typescript ) ;
1094
1099
@@ -1495,7 +1500,7 @@ impl<'a> Context<'a> {
1495
1500
if !self . should_write_global ( "symbol_dispose" ) {
1496
1501
return Ok ( ( ) ) ;
1497
1502
}
1498
- self . global ( & "if(!Symbol.dispose) { Symbol.dispose = Symbol('Symbol.dispose'); }" ) ;
1503
+ self . global ( "if(!Symbol.dispose) { Symbol.dispose = Symbol('Symbol.dispose'); }" ) ;
1499
1504
Ok ( ( ) )
1500
1505
}
1501
1506
@@ -2490,7 +2495,7 @@ impl<'a> Context<'a> {
2490
2495
pub fn generate ( & mut self ) -> Result < ( ) , Error > {
2491
2496
self . prestore_global_import_identifiers ( ) ?;
2492
2497
// conditionally override Symbol.dispose
2493
- if !self . aux . structs . is_empty ( ) {
2498
+ if self . config . symbol_dispose && !self . aux . structs . is_empty ( ) {
2494
2499
self . expose_symbol_dispose ( ) ?;
2495
2500
}
2496
2501
for ( id, adapter) in crate :: sorted_iter ( & self . wit . adapters ) {
Original file line number Diff line number Diff line change @@ -42,6 +42,7 @@ pub struct Bindgen {
42
42
multi_value : bool ,
43
43
encode_into : EncodeInto ,
44
44
split_linked_modules : bool ,
45
+ symbol_dispose : bool ,
45
46
}
46
47
47
48
pub struct Output {
@@ -88,6 +89,7 @@ impl Bindgen {
88
89
let externref =
89
90
env:: var ( "WASM_BINDGEN_ANYREF" ) . is_ok ( ) || env:: var ( "WASM_BINDGEN_EXTERNREF" ) . is_ok ( ) ;
90
91
let multi_value = env:: var ( "WASM_BINDGEN_MULTI_VALUE" ) . is_ok ( ) ;
92
+ let symbol_dispose = env:: var ( "WASM_BINDGEN_SYMBOL_DISPOSE" ) . is_ok ( ) ;
91
93
Bindgen {
92
94
input : Input :: None ,
93
95
out_name : None ,
@@ -109,6 +111,7 @@ impl Bindgen {
109
111
encode_into : EncodeInto :: Test ,
110
112
omit_default_module_path : true ,
111
113
split_linked_modules : false ,
114
+ symbol_dispose,
112
115
}
113
116
}
114
117
Original file line number Diff line number Diff line change 4
4
*/
5
5
export class ClassBuilder {
6
6
free ( ) : void ;
7
- [ Symbol . dispose ] ( ) : void ;
8
7
/**
9
8
* @returns {ClassBuilder }
10
9
*/
Original file line number Diff line number Diff line change @@ -4,8 +4,6 @@ export function __wbg_set_wasm(val) {
4
4
}
5
5
6
6
7
- if ( ! Symbol . dispose ) { Symbol . dispose = Symbol ( 'Symbol.dispose' ) ; }
8
-
9
7
const lTextDecoder = typeof TextDecoder === 'undefined' ? ( 0 , module . require ) ( 'util' ) . TextDecoder : TextDecoder ;
10
8
11
9
let cachedTextDecoder = new lTextDecoder ( 'utf-8' , { ignoreBOM : true , fatal : true } ) ;
@@ -52,10 +50,6 @@ export class ClassBuilder {
52
50
const ptr = this . __destroy_into_raw ( ) ;
53
51
wasm . __wbg_classbuilder_free ( ptr , 0 ) ;
54
52
}
55
-
56
- [ Symbol . dispose ] ( ) {
57
- this . free ( ) ;
58
- }
59
53
/**
60
54
* @returns {ClassBuilder }
61
55
*/
Original file line number Diff line number Diff line change 4
4
*/
5
5
export class ClassConstructor {
6
6
free ( ) : void ;
7
- [ Symbol . dispose ] ( ) : void ;
8
7
/**
9
8
*/
10
9
constructor ( ) ;
Original file line number Diff line number Diff line change @@ -4,8 +4,6 @@ export function __wbg_set_wasm(val) {
4
4
}
5
5
6
6
7
- if ( ! Symbol . dispose ) { Symbol . dispose = Symbol ( 'Symbol.dispose' ) ; }
8
-
9
7
const lTextDecoder = typeof TextDecoder === 'undefined' ? ( 0 , module . require ) ( 'util' ) . TextDecoder : TextDecoder ;
10
8
11
9
let cachedTextDecoder = new lTextDecoder ( 'utf-8' , { ignoreBOM : true , fatal : true } ) ;
@@ -44,10 +42,6 @@ export class ClassConstructor {
44
42
const ptr = this . __destroy_into_raw ( ) ;
45
43
wasm . __wbg_classconstructor_free ( ptr , 0 ) ;
46
44
}
47
-
48
- [ Symbol . dispose ] ( ) {
49
- this . free ( ) ;
50
- }
51
45
/**
52
46
*/
53
47
constructor ( ) {
Original file line number Diff line number Diff line change @@ -9,7 +9,6 @@ export function test1(test: number): number;
9
9
*/
10
10
export class Test {
11
11
free ( ) : void ;
12
- [ Symbol . dispose ] ( ) : void ;
13
12
/**
14
13
* @param {number } test
15
14
* @returns {Test }
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ export function __wbg_set_wasm(val) {
6
6
}
7
7
8
8
9
- if ( ! Symbol . dispose ) { Symbol . dispose = Symbol ( 'Symbol.dispose' ) ; }
10
-
11
9
const heap = new Array ( 128 ) . fill ( undefined ) ;
12
10
13
11
heap . push ( undefined , null , true , false ) ;
@@ -91,10 +89,6 @@ export class Test {
91
89
const ptr = this . __destroy_into_raw ( ) ;
92
90
wasm . __wbg_test_free ( ptr , 0 ) ;
93
91
}
94
-
95
- [ Symbol . dispose ] ( ) {
96
- this . free ( ) ;
97
- }
98
92
/**
99
93
* @param {number } test
100
94
* @returns {Test }
You can’t perform that action at this time.
0 commit comments