Rename __wasmPtr field to ptr

May as well have it be a bit shorter so minifiers can be a little smaller.
This commit is contained in:
Alex Crichton
2017-12-24 09:41:57 -08:00
parent 97be6d35ce
commit 240d3cd1a1

View File

@ -47,20 +47,20 @@ impl Js {
if self.debug { if self.debug {
self.expose_check_token(); self.expose_check_token();
dst.push_str(&format!(" dst.push_str(&format!("
constructor(public __wasmPtr: number, sym: Symbol) {{ constructor(public ptr: number, sym: Symbol) {{
_checkToken(sym); _checkToken(sym);
}} }}
")); "));
} else { } else {
dst.push_str(&format!(" dst.push_str(&format!("
constructor(public __wasmPtr: number) {{}} constructor(public ptr: number) {{}}
")); "));
} }
dst.push_str(&format!(" dst.push_str(&format!("
free(): void {{ free(): void {{
const ptr = this.__wasmPtr; const ptr = this.ptr;
this.__wasmPtr = 0; this.ptr = 0;
wasm_exports.{}(ptr); wasm_exports.{}(ptr);
}} }}
", s.free_function())); ", s.free_function()));
@ -111,7 +111,7 @@ impl Js {
let mut destructors = String::new(); let mut destructors = String::new();
if is_method { if is_method {
passed_args.push_str("this.__wasmPtr"); passed_args.push_str("this.ptr");
} }
for (i, arg) in arguments.iter().enumerate() { for (i, arg) in arguments.iter().enumerate() {
@ -173,7 +173,7 @@ impl Js {
_assertClass({arg}, {struct_}); _assertClass({arg}, {struct_});
", arg = name, struct_ = s)); ", arg = name, struct_ = s));
} }
pass(&format!("{}.__wasmPtr", name)); pass(&format!("{}.ptr", name));
} }
shared::Type::ByValue(ref s) => { shared::Type::ByValue(ref s) => {
dst.push_str(s); dst.push_str(s);
@ -184,8 +184,8 @@ impl Js {
", arg = name, struct_ = s)); ", arg = name, struct_ = s));
} }
arg_conversions.push_str(&format!("\ arg_conversions.push_str(&format!("\
const ptr{i} = {arg}.__wasmPtr; const ptr{i} = {arg}.ptr;
{arg}.__wasmPtr = 0; {arg}.ptr = 0;
", i = i, arg = name)); ", i = i, arg = name));
pass(&format!("ptr{}", i)); pass(&format!("ptr{}", i));
} }
@ -951,7 +951,7 @@ impl Js {
function _assertClass(instance: any, klass: any) { function _assertClass(instance: any, klass: any) {
if (!(instance instanceof klass)) if (!(instance instanceof klass))
throw new Error(`expected instance of ${klass.name}`); throw new Error(`expected instance of ${klass.name}`);
return instance.__wasmPtr; return instance.ptr;
} }
"); ");
} }