Skip to content

Commit

Permalink
0.2.0 (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
littledivy authored Oct 20, 2021
1 parent 38b23a2 commit bdcdaca
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 6 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
[package]
name = "deno_bindgen"
version = "0.2.0"
description = "This tool aims to simplify glue code generation for Deno FFI libraries written in Rust."
license = "MIT"
edition = "2018"

[dependencies]
deno_bindgen_macro = { path = "./macro/" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
[workspace]
members = [
"deno_bindgen_macro",
"deno_bindgen",
]
exclude = ["example/"]

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ deno install -Afq -n deno_bindgen https://deno.land/x/deno_bindgen/cli.ts
```toml
# Cargo.toml
[dependencies]
deno_bindgen = "0.1"
deno_bindgen = "0.2"
serde = { version = "1", features = ["derive"] }
```

```rust
// add.rs
use deno_bindgen::*;
use deno_bindgen::deno_bindgen;

#[deno_bindgen]
pub struct Input {
Expand Down
1 change: 0 additions & 1 deletion cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ async function generate() {
// Nothing to update.
return;
}
console.log(conf);

const pkgName = conf.name;

Expand Down
15 changes: 15 additions & 0 deletions deno_bindgen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "deno_bindgen"
version = "0.2.0"
description = "This tool aims to simplify glue code generation for Deno FFI libraries written in Rust."
license = "MIT"
edition = "2018"

[lib]
path = "./lib.rs"

[dependencies]
deno_bindgen_macro = { path = "../deno_bindgen_macro", version = "0.2.0" }
serde = { version = "1", features = ["derive"] }
serde_json = "1"

File renamed without changes.
2 changes: 1 addition & 1 deletion macro/Cargo.toml → deno_bindgen_macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "deno_bindgen_macro"
version = "0.1.1"
version = "0.2.0"
description = "This tool aims to simplify glue code generation for Deno FFI libraries written in Rust."
license = "MIT"
edition = "2018"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion example/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
deno_bindgen = { path = "../" }
deno_bindgen = { path = "../deno_bindgen/" }
serde = { version = "1", features = ["derive"] }

[lib]
Expand Down
64 changes: 32 additions & 32 deletions example/bindings/bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,38 @@ const opts = {
url: "target/debug",
}
const _lib = await Plug.prepare(opts, {
test_buf: {
parameters: ["buffer", "usize"],
result: "u8",
nonblocking: false,
},
add2: { parameters: ["buffer", "usize"], result: "i32", nonblocking: false },
test_mixed_order: {
parameters: ["i32", "buffer", "usize", "i32"],
result: "i32",
nonblocking: false,
},
test_serde: {
parameters: ["buffer", "usize"],
result: "u8",
test_mixed: {
parameters: ["isize", "buffer", "usize"],
result: "i32",
nonblocking: false,
},
sleep: { parameters: ["u64"], result: "void", nonblocking: true },
test_str: {
parameters: ["buffer", "usize"],
result: "void",
nonblocking: false,
},
add: { parameters: ["i32", "i32"], result: "i32", nonblocking: false },
sleep: { parameters: ["u64"], result: "void", nonblocking: true },
add2: { parameters: ["buffer", "usize"], result: "i32", nonblocking: false },
test_buf: {
test_serde: {
parameters: ["buffer", "usize"],
result: "u8",
nonblocking: false,
},
test_mixed: {
parameters: ["isize", "buffer", "usize"],
result: "i32",
nonblocking: false,
},
add: { parameters: ["i32", "i32"], result: "i32", nonblocking: false },
})
export type OptionStruct = {
maybe: string | undefined | null
}
export type MyStruct = {
arr: Array<string>
}
Expand All @@ -62,8 +65,13 @@ export type Input = {
a: number
b: number
}
export type OptionStruct = {
maybe: string | undefined | null
export function test_buf(a0: Uint8Array) {
const a0_buf = encode(a0)
return _lib.symbols.test_buf(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
}
export function test_mixed_order(a0: number, a1: Input, a2: number) {
const a1_buf = encode(JSON.stringify(a1))
Expand All @@ -74,29 +82,21 @@ export function test_mixed_order(a0: number, a1: Input, a2: number) {
a2,
) 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 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
}
export function sleep(a0: number) {
return _lib.symbols.sleep(a0) as Promise<null>
}
export function test_str(a0: string) {
const a0_buf = encode(a0)
return _lib.symbols.test_str(a0_buf, a0_buf.byteLength) as null
}
export function add(a0: number, a1: number) {
return _lib.symbols.add(a0, a1) as number
}
export function sleep(a0: number) {
return _lib.symbols.sleep(a0) as Promise<null>
}
export function add2(a0: Input) {
export function test_serde(a0: MyStruct) {
const a0_buf = encode(JSON.stringify(a0))
return _lib.symbols.add2(a0_buf, a0_buf.byteLength) as number
}
export function test_buf(a0: Uint8Array) {
const a0_buf = encode(a0)
return _lib.symbols.test_buf(a0_buf, a0_buf.byteLength) as number
return _lib.symbols.test_serde(a0_buf, a0_buf.byteLength) as number
}
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
export function add(a0: number, a1: number) {
return _lib.symbols.add(a0, a1) as number
}

0 comments on commit bdcdaca

Please sign in to comment.