Skip to content

Instantly share code, notes, and snippets.

@mannprerak2
Last active March 10, 2021 12:55
Show Gist options
  • Save mannprerak2/e4530e6566b35cb94f8f1b340970973a to your computer and use it in GitHub Desktop.
Save mannprerak2/e4530e6566b35cb94f8f1b340970973a to your computer and use it in GitHub Desktop.
Google summer of code 2020 - Dart (google) - Prerak Mann

FFIGEN: Generating dart bindings from C header files

Student Prerak Mann - github@mannprerak2, Linkedin@mannprerak2, mannprerak2.github.io
Project Entry summerofcode.withgoogle.com/archive/2020/projects/6706610564497408
Project Repository github.com/dart-lang/ffigen
Pub package pub.dev/packages/ffigen

About

FFIGEN is a .h to .dart bindings generator which makes it easier to use a C library with dart:ffi.

Consider LibClang(C interface to Clang). The C headers in LibClang's API source code is ~8k LOC. If you were to generate dart bindings for LibClang it amounts to almost ~4.5k LOC. With FFIGEN , all you need to do is pass in a small yaml config file which is less than ~20 LOC and simply generate the bindings.

Users can control what C functions to generate, rename macros, enums, and individual struct members using simple regular expressions. It can also generate array members nested in structs (which are not supported in dart:ffi yet).

Check out github.com/dart-lang/ffigen for a complete list of configurations, FAQs, examples, etc.

Work done

The project was completed from scratch, under the guidance of my mentor Daco Harkes @dcharkes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment