-
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.
fix: workaround for this rust-lang/docs.rs#1823 (#52)
- Loading branch information
Showing
2 changed files
with
25 additions
and
22 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 |
---|---|---|
@@ -1,39 +1,39 @@ | ||
// Auto-generated with deno_bindgen | ||
import { CachePolicy, prepare } from "https://deno.land/x/[email protected]/plug.ts" | ||
import { CachePolicy, prepare } from "https://deno.land/x/[email protected]/plug.ts"; | ||
|
||
function encode(v: string | Uint8Array): Uint8Array { | ||
if (typeof v !== "string") return v | ||
return new TextEncoder().encode(v) | ||
if (typeof v !== "string") return v; | ||
return new TextEncoder().encode(v); | ||
} | ||
|
||
function decode(v: Uint8Array): string { | ||
return new TextDecoder().decode(v) | ||
return new TextDecoder().decode(v); | ||
} | ||
|
||
function readPointer(v: any): Uint8Array { | ||
const ptr = new Deno.UnsafePointerView(v as bigint) | ||
const lengthBe = new Uint8Array(4) | ||
const view = new DataView(lengthBe.buffer) | ||
ptr.copyInto(lengthBe, 0) | ||
const buf = new Uint8Array(view.getUint32(0)) | ||
ptr.copyInto(buf, 4) | ||
return buf | ||
const ptr = new Deno.UnsafePointerView(v as bigint); | ||
const lengthBe = new Uint8Array(4); | ||
const view = new DataView(lengthBe.buffer); | ||
ptr.copyInto(lengthBe, 0); | ||
const buf = new Uint8Array(view.getUint32(0)); | ||
ptr.copyInto(buf, 4); | ||
return buf; | ||
} | ||
|
||
const url = new URL("../target/debug", import.meta.url) | ||
let uri = url.toString() | ||
if (!uri.endsWith("/")) uri += "/" | ||
const url = new URL("../target/debug", import.meta.url); | ||
let uri = url.toString(); | ||
if (!uri.endsWith("/")) uri += "/"; | ||
|
||
let darwin: string | { aarch64: string; x86_64: string } = uri | ||
+ "libflowscripter_template_deno_rust_library.dylib" | ||
let darwin: string | { aarch64: string; x86_64: string } = uri + | ||
"libflowscripter_template_deno_rust_library.dylib"; | ||
|
||
if (url.protocol !== "file:") { | ||
// Assume that remote assets follow naming scheme | ||
// for each macOS artifact. | ||
darwin = { | ||
aarch64: uri + "libflowscripter_template_deno_rust_library_arm64.dylib", | ||
x86_64: uri + "libflowscripter_template_deno_rust_library.dylib", | ||
} | ||
}; | ||
} | ||
|
||
const opts = { | ||
|
@@ -44,13 +44,13 @@ const opts = { | |
linux: uri + "libflowscripter_template_deno_rust_library.so", | ||
}, | ||
policy: CachePolicy.NONE, | ||
} | ||
}; | ||
const _lib = await prepare(opts, { | ||
add: { parameters: ["i32", "i32"], result: "i32", nonblocking: false }, | ||
}) | ||
}); | ||
|
||
export function add(a0: number, a1: number) { | ||
let rawResult = _lib.symbols.add(a0, a1) | ||
const result = rawResult | ||
return result | ||
let rawResult = _lib.symbols.add(a0, a1); | ||
const result = rawResult; | ||
return result; | ||
} |
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,3 @@ | ||
// empty build script to ensure OUT_DIR is set when deno_bindgen proc macro is run | ||
// to work around this problem: https://github.com/rust-lang/docs.rs/issues/1823 | ||
fn main() {} |