Help with FFI strings
I've been testing with the deno FFI to see if it's powerful enough to leverage the power of other languages into Deno.
This however has been very unfruitful as FFI documentations seems to be "everywhere" when it comes to types, take for example anything that returns a
I was working with a function similar to this:
You can assume the
In my search I found this article: https://medium.com/deno-the-complete-reference/calling-c-functions-from-deno-part-2-pass-buffers-ad168a3b6cc7
However, two problems arise from here:
1. You cannot use the
Reading the official Deno docs, the documentation states:
- Source: https://docs.deno.com/runtime/manual/runtime/ffi_api/
Okay, so maybe everything as a
The previous Medium Post shows something like this:
However, when tried to replicate this, another TypeError arises:
Discord has an awfully lame limit, continuing in the comments (?)
This however has been very unfruitful as FFI documentations seems to be "everywhere" when it comes to types, take for example anything that returns a
char*. There are very few hints on how is one supposed to handle such returns.I was working with a function similar to this:
extern char* searchByDinoSpecies(char* dinosaursString, char* species);You can assume the
dinosaurString to be a JSON string or a YAML string, idk. Whatever your compiled C-grandson language lets you handleIn my search I found this article: https://medium.com/deno-the-complete-reference/calling-c-functions-from-deno-part-2-pass-buffers-ad168a3b6cc7
However, two problems arise from here:
1. You cannot use the
pointer type in parameters: [] when loading my dylib because I'll get a TypeError: Invalid FFI pointer type, expected null, or ExternalReading the official Deno docs, the documentation states:
buffer type accepts TypedArrays as parameter, but it always returns a pointer object or null when used as result type like the pointer type.
- Source: https://docs.deno.com/runtime/manual/runtime/ffi_api/
Okay, so maybe everything as a
buffer should work? Well, both parameters sure work when setting buffer but another problem arises. The output, either pointer or buffer is completely useless.The previous Medium Post shows something like this:
However, when tried to replicate this, another TypeError arises:
Discord has an awfully lame limit, continuing in the comments (?)
Medium
Learn how to call C functions from Deno and pass arbitrary buffers to and fro

