-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed methods with
self: &Self
consuming the object (#4178)
- Loading branch information
1 parent
61f1d96
commit 03c8e2d
Showing
6 changed files
with
164 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
export class Test { | ||
free(): void; | ||
constructor(); | ||
consume_self(): void; | ||
ref_self(): void; | ||
ref_mut_self(): void; | ||
self_Self(): void; | ||
self_ref_Self(): void; | ||
self_ref_mut_Self(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
let wasm; | ||
export function __wbg_set_wasm(val) { | ||
wasm = val; | ||
} | ||
|
||
|
||
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; | ||
|
||
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
|
||
cachedTextDecoder.decode(); | ||
|
||
let cachedUint8ArrayMemory0 = null; | ||
|
||
function getUint8ArrayMemory0() { | ||
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { | ||
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); | ||
} | ||
return cachedUint8ArrayMemory0; | ||
} | ||
|
||
function getStringFromWasm0(ptr, len) { | ||
ptr = ptr >>> 0; | ||
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); | ||
} | ||
|
||
const TestFinalization = (typeof FinalizationRegistry === 'undefined') | ||
? { register: () => {}, unregister: () => {} } | ||
: new FinalizationRegistry(ptr => wasm.__wbg_test_free(ptr >>> 0, 1)); | ||
|
||
export class Test { | ||
|
||
__destroy_into_raw() { | ||
const ptr = this.__wbg_ptr; | ||
this.__wbg_ptr = 0; | ||
TestFinalization.unregister(this); | ||
return ptr; | ||
} | ||
|
||
free() { | ||
const ptr = this.__destroy_into_raw(); | ||
wasm.__wbg_test_free(ptr, 0); | ||
} | ||
constructor() { | ||
const ret = wasm.test_new(); | ||
this.__wbg_ptr = ret >>> 0; | ||
TestFinalization.register(this, this.__wbg_ptr, this); | ||
return this; | ||
} | ||
consume_self() { | ||
const ptr = this.__destroy_into_raw(); | ||
wasm.test_consume_self(ptr); | ||
} | ||
ref_self() { | ||
wasm.test_ref_self(this.__wbg_ptr); | ||
} | ||
ref_mut_self() { | ||
wasm.test_ref_mut_self(this.__wbg_ptr); | ||
} | ||
self_Self() { | ||
const ptr = this.__destroy_into_raw(); | ||
wasm.test_self_Self(ptr); | ||
} | ||
self_ref_Self() { | ||
wasm.test_self_ref_Self(this.__wbg_ptr); | ||
} | ||
self_ref_mut_Self() { | ||
wasm.test_self_ref_mut_Self(this.__wbg_ptr); | ||
} | ||
} | ||
|
||
export function __wbindgen_throw(arg0, arg1) { | ||
throw new Error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
pub struct Test; | ||
|
||
#[wasm_bindgen] | ||
impl Test { | ||
#[wasm_bindgen(constructor)] | ||
pub fn new() -> Test { | ||
Test | ||
} | ||
|
||
pub fn consume_self(self) {} | ||
pub fn ref_self(&self) {} | ||
pub fn ref_mut_self(&mut self) {} | ||
|
||
pub fn self_Self(self: Self) {} | ||
pub fn self_ref_Self(self: &Self) {} | ||
pub fn self_ref_mut_Self(self: &mut Self) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
(module $reference_test.wasm | ||
(type (;0;) (func (result i32))) | ||
(type (;1;) (func (param i32))) | ||
(type (;2;) (func (param i32 i32))) | ||
(func $test_ref_self (;0;) (type 1) (param i32)) | ||
(func $test_ref_mut_self (;1;) (type 1) (param i32)) | ||
(func $test_self_ref_Self (;2;) (type 1) (param i32)) | ||
(func $test_self_ref_mut_Self (;3;) (type 1) (param i32)) | ||
(func $__wbg_test_free (;4;) (type 2) (param i32 i32)) | ||
(func $test_new (;5;) (type 0) (result i32)) | ||
(func $test_consume_self (;6;) (type 1) (param i32)) | ||
(func $test_self_Self (;7;) (type 1) (param i32)) | ||
(memory (;0;) 17) | ||
(export "memory" (memory 0)) | ||
(export "__wbg_test_free" (func $__wbg_test_free)) | ||
(export "test_new" (func $test_new)) | ||
(export "test_consume_self" (func $test_consume_self)) | ||
(export "test_ref_self" (func $test_ref_self)) | ||
(export "test_ref_mut_self" (func $test_ref_mut_self)) | ||
(export "test_self_Self" (func $test_self_Self)) | ||
(export "test_self_ref_Self" (func $test_self_ref_Self)) | ||
(export "test_self_ref_mut_Self" (func $test_self_ref_mut_Self)) | ||
(@custom "target_features" (after code) "\02+\0fmutable-globals+\08sign-ext") | ||
) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters