-
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.
Allow ex/importing more raw identifier names (#4025)
- Loading branch information
Showing
8 changed files
with
192 additions
and
5 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
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,21 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* @param {number} test | ||
* @returns {number} | ||
*/ | ||
export function test1(test: number): number; | ||
/** | ||
*/ | ||
export class Test { | ||
free(): void; | ||
/** | ||
* @param {number} test | ||
* @returns {Test} | ||
*/ | ||
static test1(test: number): Test; | ||
/** | ||
* @param {number} test | ||
*/ | ||
test2(test: number): 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,120 @@ | ||
import { test2 } from 'test'; | ||
|
||
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 heap = new Array(128).fill(undefined); | ||
|
||
heap.push(undefined, null, true, false); | ||
|
||
function getObject(idx) { return heap[idx]; } | ||
|
||
let heap_next = heap.length; | ||
|
||
function dropObject(idx) { | ||
if (idx < 132) return; | ||
heap[idx] = heap_next; | ||
heap_next = idx; | ||
} | ||
|
||
function takeObject(idx) { | ||
const ret = getObject(idx); | ||
dropObject(idx); | ||
return ret; | ||
} | ||
/** | ||
* @param {number} test | ||
* @returns {number} | ||
*/ | ||
export function test1(test) { | ||
const ret = wasm.test1(test); | ||
return ret >>> 0; | ||
} | ||
|
||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
|
||
heap[idx] = obj; | ||
return idx; | ||
} | ||
|
||
const TestFinalization = (typeof FinalizationRegistry === 'undefined') | ||
? { register: () => {}, unregister: () => {} } | ||
: new FinalizationRegistry(ptr => wasm.__wbg_test_free(ptr >>> 0, 1)); | ||
/** | ||
*/ | ||
export class Test { | ||
|
||
static __wrap(ptr) { | ||
ptr = ptr >>> 0; | ||
const obj = Object.create(Test.prototype); | ||
obj.__wbg_ptr = ptr; | ||
TestFinalization.register(obj, obj.__wbg_ptr, obj); | ||
return obj; | ||
} | ||
|
||
__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); | ||
} | ||
/** | ||
* @param {number} test | ||
* @returns {Test} | ||
*/ | ||
static test1(test) { | ||
const ret = wasm.test_test1(test); | ||
return Test.__wrap(ret); | ||
} | ||
/** | ||
* @param {number} test | ||
*/ | ||
test2(test) { | ||
wasm.test_test2(this.__wbg_ptr, test); | ||
} | ||
} | ||
|
||
export function __wbg_test2_39fe629b9aa739cf() { | ||
const ret = test2(); | ||
return addHeapObject(ret); | ||
}; | ||
|
||
export function __wbindgen_throw(arg0, arg1) { | ||
throw new Error(getStringFromWasm0(arg0, arg1)); | ||
}; | ||
|
||
export function __wbindgen_object_drop_ref(arg0) { | ||
takeObject(arg0); | ||
}; | ||
|
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,24 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
pub fn r#test1(r#test: u32) -> u32 { | ||
r#test2(); | ||
r#test | ||
} | ||
|
||
#[wasm_bindgen] | ||
pub struct r#Test; | ||
|
||
#[wasm_bindgen] | ||
impl r#Test { | ||
pub fn r#test1(r#test: u32) -> Self { | ||
Self | ||
} | ||
|
||
pub fn r#test2(&self, r#test: u32) {} | ||
} | ||
|
||
#[wasm_bindgen(module = "test")] | ||
extern "C" { | ||
fn r#test2() -> JsValue; | ||
} |
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,14 @@ | ||
(module $reference_test.wasm | ||
(type (;0;) (func (param i32) (result i32))) | ||
(type (;1;) (func (param i32 i32))) | ||
(func $test_test2 (;0;) (type 1) (param i32 i32)) | ||
(func $test1 (;1;) (type 0) (param i32) (result i32)) | ||
(func $test_test1 (;2;) (type 0) (param i32) (result i32)) | ||
(func $__wbg_test_free (;3;) (type 1) (param i32 i32)) | ||
(memory (;0;) 17) | ||
(export "memory" (memory 0)) | ||
(export "test1" (func $test1)) | ||
(export "__wbg_test_free" (func $__wbg_test_free)) | ||
(export "test_test1" (func $test_test1)) | ||
(export "test_test2" (func $test_test2)) | ||
) |
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