Skip to content

Commit 240d3cd

Browse files
committed
Rename __wasmPtr field to ptr
May as well have it be a bit shorter so minifiers can be a little smaller.
1 parent 97be6d3 commit 240d3cd

File tree

1 file changed

+9
-9
lines changed
  • crates/wasm-bindgen-cli-support/src

1 file changed

+9
-9
lines changed

crates/wasm-bindgen-cli-support/src/ts.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,20 @@ impl Js {
4747
if self.debug {
4848
self.expose_check_token();
4949
dst.push_str(&format!("
50-
constructor(public __wasmPtr: number, sym: Symbol) {{
50+
constructor(public ptr: number, sym: Symbol) {{
5151
_checkToken(sym);
5252
}}
5353
"));
5454
} else {
5555
dst.push_str(&format!("
56-
constructor(public __wasmPtr: number) {{}}
56+
constructor(public ptr: number) {{}}
5757
"));
5858
}
5959

6060
dst.push_str(&format!("
6161
free(): void {{
62-
const ptr = this.__wasmPtr;
63-
this.__wasmPtr = 0;
62+
const ptr = this.ptr;
63+
this.ptr = 0;
6464
wasm_exports.{}(ptr);
6565
}}
6666
", s.free_function()));
@@ -111,7 +111,7 @@ impl Js {
111111
let mut destructors = String::new();
112112

113113
if is_method {
114-
passed_args.push_str("this.__wasmPtr");
114+
passed_args.push_str("this.ptr");
115115
}
116116

117117
for (i, arg) in arguments.iter().enumerate() {
@@ -173,7 +173,7 @@ impl Js {
173173
_assertClass({arg}, {struct_});
174174
", arg = name, struct_ = s));
175175
}
176-
pass(&format!("{}.__wasmPtr", name));
176+
pass(&format!("{}.ptr", name));
177177
}
178178
shared::Type::ByValue(ref s) => {
179179
dst.push_str(s);
@@ -184,8 +184,8 @@ impl Js {
184184
", arg = name, struct_ = s));
185185
}
186186
arg_conversions.push_str(&format!("\
187-
const ptr{i} = {arg}.__wasmPtr;
188-
{arg}.__wasmPtr = 0;
187+
const ptr{i} = {arg}.ptr;
188+
{arg}.ptr = 0;
189189
", i = i, arg = name));
190190
pass(&format!("ptr{}", i));
191191
}
@@ -951,7 +951,7 @@ impl Js {
951951
function _assertClass(instance: any, klass: any) {
952952
if (!(instance instanceof klass))
953953
throw new Error(`expected instance of ${klass.name}`);
954-
return instance.__wasmPtr;
954+
return instance.ptr;
955955
}
956956
");
957957
}

0 commit comments

Comments
 (0)