-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
preserve Rust docs in JS bindings (#13)
- Loading branch information
1 parent
777d3b2
commit 266a717
Showing
4 changed files
with
72 additions
and
38 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 |
---|---|---|
|
@@ -3,49 +3,47 @@ import { Plug } from "https://deno.land/x/[email protected]/mod.ts"; | |
const encode = (s: string) => new TextEncoder().encode(s); | ||
const opts = { | ||
name: "add", | ||
url: "target/debug", | ||
url: "target/debug" | ||
}; | ||
const _lib = await Plug.prepare(opts, { | ||
test_serde: { parameters: ["buffer", "usize"], result: "u8" }, | ||
test_mixed: { parameters: ["isize", "buffer", "usize"], result: "i32" }, | ||
add: { parameters: ["i32", "i32"], result: "i32" }, | ||
add2: { parameters: ["buffer", "usize"], result: "i32" }, | ||
test_mixed_order: { | ||
parameters: ["i32", "buffer", "usize", "i32"], | ||
result: "i32", | ||
}, | ||
}); | ||
export type MyStruct = { | ||
arr: Array<string>; | ||
}; | ||
add: { parameters: [ "i32", "i32" ], result: "i32" }, test_mixed: { parameters: [ "isize", "buffer", "usize" ], result: "i32" }, test_serde: { parameters: [ "buffer", "usize" ], result: "u8" }, add2: { parameters: [ "buffer", "usize" ], result: "i32" }, test_mixed_order: { parameters: [ "i32", "buffer", "usize", "i32" ], result: "i32" } }); | ||
export type OptionStruct = { | ||
maybe: string | undefined | null; | ||
maybe: string | undefined | null; | ||
}; | ||
/** | ||
* Doc comment for `Input` struct. | ||
* ...testing multiline | ||
**/ | ||
export type Input = { | ||
/** | ||
* Doc comments get | ||
* transformed to JS doc | ||
* comments. | ||
**/ | ||
a: number; | ||
b: number; | ||
}; | ||
export function test_serde(a0: MyStruct) { | ||
const a0_buf = encode(JSON.stringify(a0)); | ||
return _lib.symbols.test_serde(a0_buf, a0_buf.byteLength) as number; | ||
export type MyStruct = { | ||
arr: Array<string>; | ||
}; | ||
export function add(a0: number,a1: number) { | ||
|
||
return _lib.symbols.add(a0, a1) as number | ||
} | ||
export function test_mixed(a0: number, a1: Input) { | ||
export function test_mixed(a0: number,a1: Input) { | ||
const a1_buf = encode(JSON.stringify(a1)); | ||
return _lib.symbols.test_mixed(a0, a1_buf, a1_buf.byteLength) as number; | ||
return _lib.symbols.test_mixed(a0, a1_buf, a1_buf.byteLength) as number | ||
} | ||
export function add(a0: number, a1: number) { | ||
return _lib.symbols.add(a0, a1) as number; | ||
export function test_serde(a0: MyStruct) { | ||
const a0_buf = encode(JSON.stringify(a0)); | ||
return _lib.symbols.test_serde(a0_buf, a0_buf.byteLength) as number | ||
} | ||
export function add2(a0: Input) { | ||
const a0_buf = encode(JSON.stringify(a0)); | ||
return _lib.symbols.add2(a0_buf, a0_buf.byteLength) as number; | ||
return _lib.symbols.add2(a0_buf, a0_buf.byteLength) as number | ||
} | ||
export function test_mixed_order(a0: number, a1: Input, a2: number) { | ||
export function test_mixed_order(a0: number,a1: Input,a2: number) { | ||
const a1_buf = encode(JSON.stringify(a1)); | ||
return _lib.symbols.test_mixed_order( | ||
a0, | ||
a1_buf, | ||
a1_buf.byteLength, | ||
a2, | ||
) as number; | ||
return _lib.symbols.test_mixed_order(a0, a1_buf, a1_buf.byteLength, a2) as number | ||
} | ||
|
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