Add docs for FFI

This commit is contained in:
Jarred Sumner
2022-05-03 01:25:46 -07:00
parent c6d732eee2
commit 8b1924f6c2
23 changed files with 629 additions and 143 deletions

View File

@@ -937,6 +937,8 @@ pub const VirtualMachine = struct {
this.resolved_count = 0;
}
const shared_library_suffix = if (Environment.isMac) "dylib" else if (Environment.isLinux) "so" else "";
inline fn _fetch(
_: *JSGlobalObject,
_specifier: string,
@@ -1081,7 +1083,14 @@ pub const VirtualMachine = struct {
} else if (strings.eqlComptime(_specifier, "bun:ffi")) {
return ResolvedSource{
.allocator = null,
.source_code = ZigString.init("export const FFIType = " ++ JSC.FFI.ABIType.map_to_js_object ++ ";\n\n" ++ @embedFile("ffi.exports.js") ++ "\n"),
.source_code = ZigString.init(
"export const FFIType = " ++
JSC.FFI.ABIType.map_to_js_object ++
";\n\n" ++
"export const suffix = '" ++ shared_library_suffix ++ "';\n\n" ++
@embedFile("ffi.exports.js") ++
"\n",
),
.specifier = ZigString.init("bun:ffi"),
.source_url = ZigString.init("bun:ffi"),
.hash = 0,