add a rust API for defining struct types and ffi functions from safe rust without loading a dynamic library#3145
Draft
Skgland wants to merge 16 commits intomthom:masterfrom
Draft
add a rust API for defining struct types and ffi functions from safe rust without loading a dynamic library#3145Skgland wants to merge 16 commits intomthom:masterfrom
Skgland wants to merge 16 commits intomthom:masterfrom
Conversation
these are newly reported in rust 1.90+ due to excess perens from scryer-modular-bitfield macro
also add impls for Option<&(mut) T>
- techincally this should be used in the last argument of the error term not in the existence_error term, but we can't provide context for that here.
also rename run_query to run_query_string (run_query still exists for now, but is deprecated)
…ement FfiTypable for array types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
primarily adds functions
Machine::register_structandMachine::register_functionMachine::register_struct
This is the rust counterpart to to
ffi:foreign_struct/2in prolog.It allows registering a struct that implements the unsafe
CustomFfiStructtrait.Machine::register_function
There is no prolog equivalent.
Related to
use_foreign_module/2, tough without loading a dynamic/shared library and one function per call.https://github.com/Skgland/scryer-prolog/blob/c1a79f3598c8bd56f7d5a8b3769548ee1bd17cea/tests/scryer/ffi.rs#L373-L388
Todo
Help wanted
library(ffi)(or make loading it unnecessary), see https://github.com/Skgland/scryer-prolog/blob/c1a79f3598c8bd56f7d5a8b3769548ee1bd17cea/tests/scryer/ffi.rs#L373ffi:assert_predicate()should be created, seeFuture Work
CustomFfiStructsomething like
ffi:call(FnPtr, ArgTypes, RetType, Args, Ret)(suggestion for a better name appreciated) after this PR most things needed should be in place alreadyuse_foreign_moduleto have seperate predicates forffi:call/5abovee.g. allow loading plugins that all define the same entry-point/callback functions