bun-types
Advanced tools
Comparing version 1.1.28-canary.20240913T140515 to 1.1.28-canary.20240914T140507
60
ffi.d.ts
@@ -605,2 +605,62 @@ /** | ||
/** | ||
* **Experimental:** Compile ISO C11 source code using TinyCC, and make {@link symbols} available as functions to JavaScript. | ||
* | ||
* @param options | ||
* @returns Library<Fns> | ||
* | ||
* @example | ||
* ## Hello, World! | ||
* | ||
* JavaScript: | ||
* ```js | ||
* import { cc } from "bun:ffi"; | ||
* import hello from "./hello.c" with {type: "file"}; | ||
* const {symbols: {hello}} = cc({ | ||
* source: hello, | ||
* symbols: { | ||
* hello: { | ||
* returns: "cstring", | ||
* args: [], | ||
* }, | ||
* }, | ||
* }); | ||
* // "Hello, World!" | ||
* console.log(hello()); | ||
* ``` | ||
* | ||
* `./hello.c`: | ||
* ```c | ||
* #include <stdio.h> | ||
* const char* hello() { | ||
* return "Hello, World!"; | ||
* } | ||
* ``` | ||
*/ | ||
function cc<Fns extends Record<string, FFIFunction>>(options: { | ||
/** | ||
* File path to an ISO C11 source file to compile and link | ||
*/ | ||
source: string | import("bun").BunFile | URL; | ||
/** | ||
* Library names to link against | ||
* | ||
* Equivalent to `-l` option in gcc/clang. | ||
*/ | ||
library?: string[] | string; | ||
/** | ||
* Include directories to pass to the compiler | ||
* | ||
* Equivalent to `-I` option in gcc/clang. | ||
*/ | ||
include?: string[] | string; | ||
/** | ||
* Map of symbols to load where the key is the symbol name and the value is the {@link FFIFunction} | ||
*/ | ||
symbols: Fns; | ||
}): Library<Fns>; | ||
/** | ||
* Turn a native library's function pointer into a JavaScript function | ||
@@ -607,0 +667,0 @@ * |
{ | ||
"version": "1.1.28-canary.20240913T140515", | ||
"version": "1.1.28-canary.20240914T140507", | ||
"name": "bun-types", | ||
@@ -4,0 +4,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
373619
12091