diff --git a/Cargo.lock b/Cargo.lock index 9138b8b..e5903c6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -23,7 +23,7 @@ dependencies = [ [[package]] name = "deno_bindgen" -version = "0.2.0" +version = "0.3.1" dependencies = [ "deno_bindgen_macro", "serde", @@ -32,7 +32,7 @@ dependencies = [ [[package]] name = "deno_bindgen_macro" -version = "0.2.0" +version = "0.3.1" dependencies = [ "Inflector", "proc-macro2", diff --git a/example/bindings/bindings.ts b/example/bindings/bindings.ts index 4d2a24e..b0bc7f3 100644 --- a/example/bindings/bindings.ts +++ b/example/bindings/bindings.ts @@ -10,9 +10,10 @@ const opts = { policy: CachePolicy.NONE, } const _lib = await prepare(opts, { - test_lifetime: { + add: { parameters: ["i32", "i32"], result: "i32", nonblocking: false }, + test_buf: { parameters: ["buffer", "usize"], - result: "usize", + result: "u8", nonblocking: false, }, test_mixed_order: { @@ -20,26 +21,19 @@ const _lib = await prepare(opts, { result: "i32", nonblocking: false, }, - add2: { parameters: ["buffer", "usize"], result: "i32", nonblocking: false }, - sleep: { parameters: ["u64"], result: "void", nonblocking: true }, test_str: { parameters: ["buffer", "usize"], result: "void", nonblocking: false, }, - test_mut_buf: { - parameters: ["buffer", "usize"], - result: "void", - nonblocking: false, - }, - test_tag_and_content: { + test_serde: { parameters: ["buffer", "usize"], - result: "i32", + result: "u8", nonblocking: false, }, - test_serde: { + test_lifetime: { parameters: ["buffer", "usize"], - result: "u8", + result: "usize", nonblocking: false, }, test_mixed: { @@ -47,13 +41,25 @@ const _lib = await prepare(opts, { result: "i32", nonblocking: false, }, - add: { parameters: ["i32", "i32"], result: "i32", nonblocking: false }, - test_buf: { + sleep: { parameters: ["u64"], result: "void", nonblocking: true }, + add2: { parameters: ["buffer", "usize"], result: "i32", nonblocking: false }, + test_tag_and_content: { parameters: ["buffer", "usize"], - result: "u8", + result: "i32", + nonblocking: false, + }, + test_mut_buf: { + parameters: ["buffer", "usize"], + result: "void", nonblocking: false, }, }) +export type TagAndContent = + | { key: "A"; value: { b: number } } + | { key: "C"; value: { d: number } } +export type MyStruct = { + arr: Array +} /** * Doc comment for `Input` struct. * ...testing multiline @@ -67,8 +73,19 @@ export type Input = { a: number b: number } -export type MyStruct = { - arr: Array +export type TestLifetimeWrap = { + _a: TestLifetimeEnums +} +export type OptionStruct = { + maybe: string | undefined | null +} +export type TestLifetimes = { + text: string +} +export type TestLifetimeEnums = { + Text: { + _text: string + } } export type PlainEnum = | { @@ -78,26 +95,12 @@ export type PlainEnum = } | "b" | "c" -export type TestLifetimeEnums = { - Text: { - _text: string - } -} -export type OptionStruct = { - maybe: string | undefined | null -} -export type TestLifetimeWrap = { - _a: TestLifetimeEnums -} -export type TestLifetimes = { - text: string +export function add(a0: number, a1: number) { + return _lib.symbols.add(a0, a1) as number } -export type TagAndContent = - | { key: "A"; value: { b: number } } - | { key: "C"; value: { d: number } } -export function test_lifetime(a0: TestLifetimes) { - const a0_buf = encode(JSON.stringify(a0)) - return _lib.symbols.test_lifetime(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 } export function test_mixed_order(a0: number, a1: Input, a2: number) { const a1_buf = encode(JSON.stringify(a1)) @@ -108,37 +111,34 @@ export function test_mixed_order(a0: number, a1: Input, a2: number) { a2, ) 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 sleep(a0: number) { - return _lib.symbols.sleep(a0) as Promise -} 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 test_mut_buf(a0: Uint8Array) { - const a0_buf = encode(a0) - return _lib.symbols.test_mut_buf(a0_buf, a0_buf.byteLength) as null -} -export function test_tag_and_content(a0: TagAndContent) { - const a0_buf = encode(JSON.stringify(a0)) - return _lib.symbols.test_tag_and_content(a0_buf, a0_buf.byteLength) 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_lifetime(a0: TestLifetimes) { + const a0_buf = encode(JSON.stringify(a0)) + return _lib.symbols.test_lifetime(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 +export function sleep(a0: number) { + return _lib.symbols.sleep(a0) as Promise } -export function test_buf(a0: Uint8Array) { +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_tag_and_content(a0: TagAndContent) { + const a0_buf = encode(JSON.stringify(a0)) + return _lib.symbols.test_tag_and_content(a0_buf, a0_buf.byteLength) as number +} +export function test_mut_buf(a0: Uint8Array) { const a0_buf = encode(a0) - return _lib.symbols.test_buf(a0_buf, a0_buf.byteLength) as number + return _lib.symbols.test_mut_buf(a0_buf, a0_buf.byteLength) as null } diff --git a/release.sh b/release.sh new file mode 100644 index 0000000..42ed6b7 --- /dev/null +++ b/release.sh @@ -0,0 +1,6 @@ +cd deno_bindgen_macro && cargo publish +# wait for crates.io to update +sleep 2 +cargo publish +# update lockfile +make test