Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: datalog foreign function interface prototype #228

Draft
wants to merge 7 commits into
base: v5
Choose a base branch
from
Draft

wip: datalog foreign function interface prototype #228

wants to merge 7 commits into from

Commits on Nov 12, 2024

  1. wip: datalog foreign function interface prototype

    This allows using external functions in datalog.
    
    This makes it easy to provide custom logic without extending the spec for every use-case, at the expense of portability: behaviour is no longer guaranteed to be consistent cross languages, and some languages won’t be able to support it at all (for instance JS as of now).
    
    Todo:
    - stricter conversions from datalog
    - feature-gating if possible
    
    Open questions:
    - enum index for the FFI variants (contiguous or not?)
    - how to provide functions (right now, function pointers: prevent mutability and closing over arguments)
    - how to provide arguments (right now, datalog::Term, so symbols have to be resolved, and functions returning strings have to register new symbols)
    divarvel committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    3cede37 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e0522da View commit details
    Browse the repository at this point in the history
  3. wip: allow closures in external funcs, use builder terms

    - using boxed functions instead of function pointers allow capturing the environment
    - using builder terms instead of datalog terms remove the need for manual symbol management
    divarvel committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    51d246f View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f6047ec View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    128c031 View commit details
    Browse the repository at this point in the history
  6. Add sample for FFI calls

    divarvel committed Nov 12, 2024
    Configuration menu
    Copy the full SHA
    bf923cb View commit details
    Browse the repository at this point in the history

Commits on Nov 13, 2024

  1. intern FFI call names

    Instead of storing strings directly in the ops, do as we do for everything else and use the symbol table.
    
    This required duplicating `biscuit_parser::builder::Binary` and `Unary` in the `biscuit_auth::builder` module (which previously used the definitions from the `datalog` module directly). There is a lot of duplication between `biscuit_parser::builder` and `biscuit_auth::builder`, with a circular-ish dependency (biscuit_auth depends on biscuit parser, but code generated by the `ToTokens` impl blocks in biscuit parser depend on `biscuit_auth::builder`).
    divarvel committed Nov 13, 2024
    Configuration menu
    Copy the full SHA
    99c0718 View commit details
    Browse the repository at this point in the history