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

FFI API #738

Merged
merged 23 commits into from
Feb 20, 2024
Merged

FFI API #738

merged 23 commits into from
Feb 20, 2024

Conversation

liz3
Copy link
Contributor

@liz3 liz3 commented Feb 10, 2024

FFI Api for dictu.

What's Changed:

Adds a FFI api which allows a C abi to easy extend dictu with native functions.

  • It works by providing a header(dictu-include.h) which contains all macros which might be useful for external users, although of course theres the chance i missed something.
  • The header replaces the compiler entry with a void pointer to avoid having to copy all its structs
  • The header contains function pointers for all the required functions from the vm, which are loaded at runtime automatically(dictu_internal_ffi_init), this avoids the user having to link against dictu or duplicate function definitions.
  • It also contains a mechanism to ensure that function pointers can safely be loaded with a versioning system.
  • The pr also adds support for two things:
    1. Invoking functions on a abstract without self as 0 arg, this is because the remote ffi function should only receive the actual function arguments, the 0 argument is the FFIInstance
    2. Adding properties to abstract which was a quick edit in the vm but might be useful for external modules.

Type of Change:

  • Bug fix
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Housekeeping:

  • Tests have been updated to reflect the changes done within this PR (if applicable).
  • Documentation has been updated to reflect the changes done within this PR (if applicable).

@liz3
Copy link
Contributor Author

liz3 commented Feb 10, 2024

im not sure why the docs fail but maybe its the empty links, but all other tests pass.
thats good

@Jason2605
Copy link
Member

Apologies been busy, I def will get round to this, thank you so much!

Be good to get your eyes too if you have any spare time @briandowns 🙂

@liz3
Copy link
Contributor Author

liz3 commented Feb 13, 2024

Apologies been busy, I def will get round to this, thank you so much!

Be good to get your eyes too if you have any spare time @briandowns 🙂

All good no stress

.gitignore Outdated
/Release
examples/ffi-example/build
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add new line characters to any file that don't have them?

src/optionals/ffi/ffi.c Outdated Show resolved Hide resolved
@briandowns
Copy link
Contributor

I love this. Very very cool. Few things:

  • Can we add the shared object libraries to the .gitignore?
  • How are would it be to use Dictu as an embedded language now with the shared objects?
  • Even thought it's FFI, I was curious aabout folks thoughts on naming the module "external" or something similar.

I can't wait to get started using this!

@liz3
Copy link
Contributor Author

liz3 commented Feb 16, 2024

I love this. Very very cool. Few things:

* Can we add the shared object libraries to the .gitignore?

* How are would it be to use Dictu as an embedded language now with the shared objects?

* Even thought it's FFI, I was curious aabout folks thoughts on naming the module "external" or something similar.

I can't wait to get started using this!

Can we add the shared object libraries to the .gitignore?

Uh if you can help me build the test libs with the runner sure. Since they are required for the tests.

How are would it be to use Dictu as an embedded language now with the shared objects?

Im not entirely sure what you mean by embedded here, as in including shared objects into a binary? Im a tad confused.

Even thought it's FFI, I was curious aabout folks thoughts on naming the module "external" or something similar.

We can do that idm about the name at all.

@@ -0,0 +1,643 @@
#ifndef dictumod_include_h
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's probably worth adding this to the include directory within src, that way people may find it easier rather than it being in the examples directory

@Jason2605
Copy link
Member

This is really really awesome!!! Thank you so much for working on this!! I'm gonna merge this in but left a little comment about moving / copying one file that any of us can pick up at some point (not massively urgent)

@Jason2605 Jason2605 merged commit a2179e1 into dictu-lang:develop Feb 20, 2024
6 of 8 checks passed
@Jason2605 Jason2605 mentioned this pull request Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants