At some point I discovered that Godot already has abstracted/cross-platform dynamic library loading & symbol lookup functionality (including special handling for iOS exports), declared virtual here:
Primarily this issue is to point out "hey this exists" but might also show potential approaches for integration of FFI functionality into Godot more directly.
Re:
src/crossplatform.cpp
Existing Godot dynamic library loading functionality
At some point I discovered that Godot already has abstracted/cross-platform dynamic library loading & symbol lookup functionality (including special handling for iOS exports), declared virtual here:
And implemented per platform, e.g.:
https://github.com/godotengine/godot/blob/416cd715a3f51b7d74676fa7d4c8e34c3c2823c9/drivers/unix/os_unix.cpp#L403-L448
https://github.com/godotengine/godot/blob/416cd715a3f51b7d74676fa7d4c8e34c3c2823c9/platform/windows/os_windows.cpp#L2246-L2295
https://github.com/godotengine/godot/blob/416cd715a3f51b7d74676fa7d4c8e34c3c2823c9/platform/osx/os_osx.mm#L1789-L1806
Related commits: here & here.
No access via GDNative
Unfortunately this functionality isn't exposed via GDNative--it's unclear if this is intentional or merely a result of the methods being virtual.
Rather than re-implement the wheel, it seems like it would be good to make use of the existing functionality, by e.g. doing one of:
Copy/paste the relevant code into Foreigner (assuming license compatibility). :D
Request
open_dynamic_library()
,close_dynamic_library()
&get_dynamic_library_symbol_handle()
are exposed to GDNative.Turn Foreigner into a module so we can use
OS::get_singleton()->open_dynamic_library(path, native_handle, true)
(I assume).Get Foreigner included in the core engine. :)
Get
GDNative
modified so there's a way to get access to a library but without requiring the library to implement any "standard" methods.Figure out some way to bypass the existing "validity" checks in
GDNative
. :)The code already admits it cheats anyway: :)
So if we could bypass that check it'd be golden...
Related:
call_native()
Semi-related would be that potentially we might also then piggyback on top of the existing
GDNative::call_native()
functionality:Conclusion
Primarily this issue is to point out "hey this exists" but might also show potential approaches for integration of FFI functionality into Godot more directly.
Edits: Added commit links. Add
src/crossplatform.cpp
link.