forked from rustwasm/wasm-bindgen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0f3a47
commit 576da64
Showing
4 changed files
with
101 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
/** | ||
* @param {Color} color | ||
* @returns {Color} | ||
*/ | ||
export function enum_echo(color: Color): Color; | ||
/** | ||
* @param {Color | undefined} [color] | ||
* @returns {Color | undefined} | ||
*/ | ||
export function option_enum_echo(color?: Color): Color | undefined; | ||
/** | ||
*/ | ||
export enum Color { | ||
Green = 0, | ||
Yellow = 1, | ||
Red = 2, | ||
} |
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,54 @@ | ||
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 cachedUint8Memory0 = null; | ||
|
||
function getUint8Memory0() { | ||
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { | ||
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); | ||
} | ||
return cachedUint8Memory0; | ||
} | ||
|
||
function getStringFromWasm0(ptr, len) { | ||
ptr = ptr >>> 0; | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
/** | ||
* @param {Color} color | ||
* @returns {Color} | ||
*/ | ||
export function enum_echo(color) { | ||
const ret = wasm.enum_echo(color); | ||
return ret; | ||
} | ||
|
||
function isLikeNone(x) { | ||
return x === undefined || x === null; | ||
} | ||
/** | ||
* @param {Color | undefined} [color] | ||
* @returns {Color | undefined} | ||
*/ | ||
export function option_enum_echo(color) { | ||
const ret = wasm.option_enum_echo(isLikeNone(color) ? 3 : color); | ||
return ret === 3 ? undefined : ret; | ||
} | ||
|
||
/** | ||
*/ | ||
export const Color = Object.freeze({ Green:0,"0":"Green",Yellow:1,"1":"Yellow",Red:2,"2":"Red", }); | ||
|
||
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,19 @@ | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
#[derive(PartialEq, Debug)] | ||
pub enum Color { | ||
Green, | ||
Yellow, | ||
Red, | ||
} | ||
|
||
#[wasm_bindgen] | ||
pub fn enum_echo(color: Color) -> Color { | ||
color | ||
} | ||
|
||
#[wasm_bindgen] | ||
pub fn option_enum_echo(color: Option<Color>) -> Option<Color> { | ||
color | ||
} |
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,9 @@ | ||
(module | ||
(type (;0;) (func (param i32) (result i32))) | ||
(func $enum_echo (;0;) (type 0) (param i32) (result i32)) | ||
(func $option_enum_echo (;1;) (type 0) (param i32) (result i32)) | ||
(memory (;0;) 17) | ||
(export "memory" (memory 0)) | ||
(export "enum_echo" (func $enum_echo)) | ||
(export "option_enum_echo" (func $option_enum_echo)) | ||
) |