package:ffigen simplifies the process of generating
dart:ffi bindings from C header files. It is simple to use, with the input being a small YAML config file. It requires LLVM (9+) to work. This document tries to give a complete overview of every component without going into too many details about every single class/file.
package:ffigen binds to LibClang using
dart:ffi for parsing C header files.
The config file for generating bindings is
tool/libclang_config.yaml. The bindings are generated to
lib/src/header_parser/clang_bindings/clang_bindings.dart. These are used by Header Parser for calling libclang functions.
This is the main entry point for the user-
dart run ffigen.
--verbose: Sets log level.
--config: Specifies a config file.
ffigen.dartin the following way:
ffigen.dartwill try to find dynamic library in default locations. If that fails, the user must excplicitly specify location in ffigen's config under the key
Configobject from an input Yaml file. This is used by other modules.
parsemethod is then invoked to generate a
Libraryobject to the specified file.
The Config Provider holds all the configurations required by other modules.
The Header Parser parses C header files and converts them into a
The Code Generator generates the actual string bindings.