Replies: 1 comment 3 replies
-
We don't yet have a way to import symbols that aren't functions. You'd be best off defining accessor functions to read these values. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I use
bun:ffi
to test an FFI built by Rust. This has been working successfully for a while for function calls, but I can't figure out a way to load constant C strings this way.The constants are generated from here and result in a header file like this:
I know these constants are in the FFI
dylib
itself because:dlopen
frombun:ffi
, then I'm able to get a JS object. If I specify an invalid symbol instead, I get aSymbol "…" not found
error. This shows thatbun:ffi
is clearly able to recognize the existence of these symbols.However, I cannot figure out a way to get the C string value from these symbols.
dlopen(…)
seem to be oriented around function calls, and I haven't been able to guess anything to return a symbol for a C string constant.{args: [], returns: FFIType.cstring }
for one of these symbols and calling it like a function. This results in:symbols
returned bydlopen(…)
all seem to be JS functions. But unlike normal functions, they are logged as e.g.[class CUBING_EVENT_222]
yet they don't have a.prototype
. I assume this is because ofbun
implementation details built on the assumption that the symbol is a function.Is it possible to access the C string values using
bun:ffi
, or am I missing something?Beta Was this translation helpful? Give feedback.
All reactions