Skip to content
/ cthulhu Public
forked from cffi-rs/cffi

I know always that I am an outsider; a crab in this century and among those who are still writing C.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

fry/cthulhu

 
 

Cthulhu

Generate FFI-compatible extern fn from harmless fns using the power of proc macros. If you are wondering which ABI this is, remember: You can't spell Cthulhu without C!

Usage

It's a mystery.

Roadmap

v0.1 series

Let's get this show on the road.

  • Introduce marshalers and their ToForeign and FromForeign traits
  • Add procedural macros for invoking marshalers
  • Generate safe runtime checking of unsafe boundaries
  • Generate "exception handling" callbacks
  • Handle all basic scalar primitives (including the bool special case)
  • Introduce ReturnType trait for reflecting return values for complex types
  • Encapsulate all information needed to generate functions into a single Function type
  • Provide a micro-framework for demonstrating Cthulhu error handling

v0.2 series

Let's get more show out of this road.

  • Implement a good resource cleanup story
  • Implement a good Vec<T> story
  • Implement a good ref/owned/ohno story
  • Get strings in all their forms working safely and ergonomically
  • Allow generating extern functions by invokeing on impl and mod levels
    • Auto-prefixing of functions with a "C namespace" of the user's choice
  • Experiment with other syntaxes for declaring marshalers on longer type signatures
  • Improve error handling and reporting (some spans are still garbage or wrong)
  • Supply default marshalers for:
    • Path types per operating system
    • UTF-16 owned/borrowed strings
    • UTF-8 owned/borrowed strings
    • Arc<T>
  • Make invoke syntax consistent with marshal
  • Add debug logging to inform the user when a value has been consumed and should not be reused
  • Clean up the tests and make them pass
  • Support types whose representation in C would be multiple parameters or a struct

v1.0 series

Let's get this stable.

  • Ability to generate APIs for Kotlin, Swift and C#
  • Fuzzed so hard that the code is no longer fazed by aggressive abuse and invalid files

Background and philosophy

We enforce the usage of stdint.h types on the C side to simplify the implementation on the Rust side.

Interesting reads:

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

About

I know always that I am an outsider; a crab in this century and among those who are still writing C.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%