diff --git a/index.js b/index.js index ade04b8..8a5dbb5 100644 --- a/index.js +++ b/index.js @@ -1,14 +1,21 @@ import { dlopen, FFIType, suffix } from "bun:ffi"; -const path = `./libfibonacci.so`; +const path = `./libtesticolo.so`; const { symbols } = dlopen(path, { - fibonacci_gmp: { - args: [], - returns: FFIType.cstring, + testicolo: { + args: [FFIType.cstring, FFIType.cstring], + returns: FFIType.void, }, }); -const result = symbols.fibonacci_gmp(); -console.log("Fibonacci(25000) =", result); +const input = "qwertyuiopasdfghjkllzxcvbnm123456789mnbvcxzlkjhgfdsapoiuytrewq1234567890"; +const output = new ArrayBuffer(input.length + 1); +const outputView = new Uint8Array(output); +// Call the function with the input string +symbols.testicolo(input, outputView); + +// Convert the output buffer to a string and log it +const result = new TextDecoder().decode(outputView); +console.log(result);