Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ffi string and buffer support #11648

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: update typings
eliassjogreen committed Aug 11, 2021
commit 24a13d43db447df13f9d41cc5e24ed98923319be
12 changes: 9 additions & 3 deletions cli/dts/lib.deno.unstable.d.ts
Original file line number Diff line number Diff line change
@@ -121,13 +121,19 @@ declare namespace Deno {
| "usize"
| "isize"
| "f32"
| "f64";
| "f64"
| "string"
| "buffer";

/** A foreign function as defined by its parameter and result types */
export interface ForeignFunction {
export type ForeignFunction = {
parameters: NativeType[];
result: NativeType;
}
} | {
parameters: NativeType[];
result: "buffer";
resultLength?: number;
};

/** A dynamic library resource */
export interface DynamicLibrary<S extends Record<string, ForeignFunction>> {
7 changes: 2 additions & 5 deletions extensions/ffi/lib.rs
Original file line number Diff line number Diff line change
@@ -340,11 +340,8 @@ fn op_ffi_call(
.get(&args.symbol)
.ok_or_else(bad_resource_id)?;

let buffers: Vec<&[u8]> = args
.buffers
.iter()
.map(|buffer| &buffer[..])
.collect();
let buffers: Vec<&[u8]> =
args.buffers.iter().map(|buffer| &buffer[..]).collect();

let native_values = symbol
.parameter_types