Skip to content

Commit 9eda4ae

Browse files
Hash full signature for imported functions (#4269)
1 parent 50c7504 commit 9eda4ae

File tree

14 files changed

+143
-15
lines changed

14 files changed

+143
-15
lines changed

crates/cli/tests/reference/anyref-import-catch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export function exported() {
5252
}
5353
}
5454

55-
export function __wbg_foo_95fe1a04017077db() { return handleError(function () {
55+
export function __wbg_foo_4e8309b1aa95a4ac() { return handleError(function () {
5656
foo();
5757
}, arguments) };
5858

crates/cli/tests/reference/import.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,28 +68,28 @@ export function exported() {
6868
}
6969
}
7070

71-
export function __wbg_add_dd5307a7ca6818d5(arg0, arg1) {
71+
export function __wbg_add_7fbfb2c172506d12(arg0, arg1) {
7272
const ret = add(arg0, arg1);
7373
return ret;
7474
};
7575

76-
export function __wbg_barfromfoo_d097f3ec35aab47c() {
76+
export function __wbg_barfromfoo_29614885590bfb6f() {
7777
bar_from_foo();
7878
};
7979

80-
export function __wbg_catchme_a7bca7f3d5a5f319() { return handleError(function () {
80+
export function __wbg_catchme_f7d87ea824a61e87() { return handleError(function () {
8181
catch_me();
8282
}, arguments) };
8383

84-
export function __wbg_nocatch_62552fa42a58590b() {
84+
export function __wbg_nocatch_be850a8dddd9599d() {
8585
no_catch();
8686
};
8787

88-
export function __wbg_reload_90d82b22b83c1d99() {
88+
export function __wbg_reload_84c12f152ad689f0() {
8989
window.location.reload();
9090
};
9191

92-
export function __wbg_write_d258674ff6f0ea8d(arg0, arg1) {
92+
export function __wbg_write_c2ce0ce33a6087d5(arg0, arg1) {
9393
window.document.write(getStringFromWasm0(arg0, arg1));
9494
};
9595

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
export function exported(): void;

crates/cli/tests/reference/modules.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
let wasm;
2+
export function __wbg_set_wasm(val) {
3+
wasm = val;
4+
}
5+
6+
7+
const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder;
8+
9+
let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true });
10+
11+
cachedTextDecoder.decode();
12+
13+
let cachedUint8ArrayMemory0 = null;
14+
15+
function getUint8ArrayMemory0() {
16+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
17+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
18+
}
19+
return cachedUint8ArrayMemory0;
20+
}
21+
22+
function getStringFromWasm0(ptr, len) {
23+
ptr = ptr >>> 0;
24+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
25+
}
26+
27+
const heap = new Array(128).fill(undefined);
28+
29+
heap.push(undefined, null, true, false);
30+
31+
function getObject(idx) { return heap[idx]; }
32+
33+
let heap_next = heap.length;
34+
35+
function dropObject(idx) {
36+
if (idx < 132) return;
37+
heap[idx] = heap_next;
38+
heap_next = idx;
39+
}
40+
41+
function takeObject(idx) {
42+
const ret = getObject(idx);
43+
dropObject(idx);
44+
return ret;
45+
}
46+
47+
function addHeapObject(obj) {
48+
if (heap_next === heap.length) heap.push(heap.length + 1);
49+
const idx = heap_next;
50+
heap_next = heap[idx];
51+
52+
heap[idx] = obj;
53+
return idx;
54+
}
55+
56+
export function exported() {
57+
wasm.exported();
58+
}
59+
60+
export function __wbg_parseFloat_2be7f01c31025438(arg0, arg1) {
61+
const ret = parseFloat(getStringFromWasm0(arg0, arg1));
62+
return ret;
63+
};
64+
65+
export function __wbg_parseFloat_7bc8aecd47f33642(arg0) {
66+
const ret = parseFloat(getObject(arg0));
67+
return ret;
68+
};
69+
70+
export function __wbindgen_object_drop_ref(arg0) {
71+
takeObject(arg0);
72+
};
73+
74+
export function __wbindgen_string_new(arg0, arg1) {
75+
const ret = getStringFromWasm0(arg0, arg1);
76+
return addHeapObject(ret);
77+
};
78+

crates/cli/tests/reference/modules.rs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use wasm_bindgen::prelude::*;
2+
3+
mod a {
4+
use wasm_bindgen::prelude::*;
5+
6+
#[wasm_bindgen]
7+
extern "C" {
8+
#[wasm_bindgen(js_name = parseFloat)]
9+
pub fn parse_float(text: &JsValue) -> f64;
10+
}
11+
}
12+
13+
mod b {
14+
use wasm_bindgen::prelude::*;
15+
16+
#[wasm_bindgen]
17+
extern "C" {
18+
#[wasm_bindgen(js_name = parseFloat)]
19+
pub fn parse_float(text: &str) -> f64;
20+
}
21+
}
22+
23+
mod a_again {
24+
use wasm_bindgen::prelude::*;
25+
26+
#[wasm_bindgen]
27+
extern "C" {
28+
#[wasm_bindgen(js_name = parseFloat)]
29+
pub fn parse_float(text: &JsValue) -> f64;
30+
}
31+
}
32+
33+
#[wasm_bindgen]
34+
pub fn exported() {
35+
let _ = a::parse_float(&JsValue::from_str("3.14"));
36+
let _ = b::parse_float("3.14");
37+
let _ = a_again::parse_float(&JsValue::from_str("3.14"));
38+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(module $reference_test.wasm
2+
(type (;0;) (func))
3+
(func $exported (;0;) (type 0))
4+
(memory (;0;) 17)
5+
(export "memory" (memory 0))
6+
(export "exported" (func $exported))
7+
(@custom "target_features" (after code) "\04+\0amultivalue+\0fmutable-globals+\0freference-types+\08sign-ext")
8+
)
9+

crates/cli/tests/reference/raw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class Test {
104104
}
105105
}
106106

107-
export function __wbg_test2_39fe629b9aa739cf() {
107+
export function __wbg_test2_ae36e154b7589768() {
108108
const ret = test2();
109109
return addHeapObject(ret);
110110
};

crates/cli/tests/reference/targets-0.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function add_that_might_fail(a, b) {
1313
return ret >>> 0;
1414
}
1515

16-
export function __wbg_random_5d40be260a2cfbac() {
16+
export function __wbg_random_8be0a899673d8681() {
1717
const ret = Math.random();
1818
return ret;
1919
};

crates/cli/tests/reference/targets-1.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ async function __wbg_load(module, imports) {
4444
function __wbg_get_imports() {
4545
const imports = {};
4646
imports.wbg = {};
47-
imports.wbg.__wbg_random_5d40be260a2cfbac = function() {
47+
imports.wbg.__wbg_random_8be0a899673d8681 = function() {
4848
const ret = Math.random();
4949
return ret;
5050
};

crates/cli/tests/reference/targets-2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ let wasm_bindgen;
5050
function __wbg_get_imports() {
5151
const imports = {};
5252
imports.wbg = {};
53-
imports.wbg.__wbg_random_5d40be260a2cfbac = function() {
53+
imports.wbg.__wbg_random_8be0a899673d8681 = function() {
5454
const ret = Math.random();
5555
return ret;
5656
};

crates/cli/tests/reference/targets-3.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ module.exports.add_that_might_fail = function(a, b) {
1212
return ret >>> 0;
1313
};
1414

15-
module.exports.__wbg_random_5d40be260a2cfbac = function() {
15+
module.exports.__wbg_random_8be0a899673d8681 = function() {
1616
const ret = Math.random();
1717
return ret;
1818
};

crates/cli/tests/reference/targets-4.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export function add_that_might_fail(a, b) {
1010

1111
const imports = {
1212
__wbindgen_placeholder__: {
13-
__wbg_random_5d40be260a2cfbac: function() {
13+
__wbg_random_8be0a899673d8681: function() {
1414
const ret = Math.random();
1515
return ret;
1616
},

crates/cli/tests/reference/web-sys.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export function get_media_source() {
210210

211211
const __wbindgen_enum_MediaSourceEnum = ["camera", "screen", "application", "window", "browser", "microphone", "audioCapture", "other"];
212212

213-
export function __wbg_new_1cabf49927794f50() { return handleError(function (arg0, arg1) {
213+
export function __wbg_new_561a91ce53f10a66() { return handleError(function (arg0, arg1) {
214214
const ret = new URL(getStringFromWasm0(arg0, arg1));
215215
return addHeapObject(ret);
216216
}, arguments) };

crates/macro-support/src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ impl<'a> ConvertToAst<(&ast::Program, BindgenAttrs, &'a Option<ast::ImportModule
618618
ast::ImportFunctionKind::Normal => (0, "n"),
619619
ast::ImportFunctionKind::Method { ref class, .. } => (1, &class[..]),
620620
};
621-
let data = (ns, &self.sig.ident, module);
621+
let data = (ns, self.sig.to_token_stream().to_string(), module);
622622
format!(
623623
"__wbg_{}_{}",
624624
wasm.name

0 commit comments

Comments
 (0)