3 ms·
Can bun:ffi deal with opaque pointers and C preprocessor generated types? For example can you embed a package like Guile in JS with bun:ffi? https://www.gnu.o
by melony 4y ago
Can bun:ffi deal with opaque pointers and C preprocessor generated types?
For example can you embed a package like Guile in JS with bun:ffi?
https://www.gnu.org/software/guile/docs/guile-tut/tutorial.html#Init-Guile https://www.gnu.org/software/guile/docs/guile-tut/tutorial.h...
Opaque pointers and preprocessors often trip FFI up
- Jarred 4y agoopaque pointers yes - 'ptr' or 'void*' as the arg type/return type. if you need to create a pointer then you can use a Uint8Array or a BigUint64Array. generated types - not yet, though if it's a pointer you can pass that struct support isn't implemented yet - so just numbers, pointers and also strings. still not sure the best way to do structs efficiently. passing an object to the function call will be too slow.
- eyelidlessness 4y agoI haven’t looked in a while, what’s the status of Bun macros? For quite some time I’ve wanted a fast and ergonomic way to override built in runtime behavior for object/array literals. E.g. for an efficient implementation of the records/tuples proposal, for which I’ve thought Bun macros could be well suited. I think they’d be equally well suited to a specialized struct factory, which could bypass at least some of the overhead of JS runtime construction.