From 96c5a78739ae2d037980944872c65237cc6805f7 Mon Sep 17 00:00:00 2001 From: PanSi21 Date: Sun, 5 Jan 2025 00:56:32 +0100 Subject: [PATCH] Aggiorna index.js --- index.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) 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);