miqt/cmd/genbindings
mappu 8da51d61f5 genbindings: misc fixes 2024-08-28 18:47:44 +12:00
..
cachedir genbindings: generate multiple files in one run, cache clang ast files 2024-08-14 17:43:54 +12:00
README.md genbindings: switch to two-phase 2024-08-26 22:45:11 +12:00
clang2il.go genbindings: misc fixes 2024-08-28 18:47:44 +12:00
clang2il_test.go genbindings: variable pointer depth 2024-08-28 18:22:05 +12:00
clangexec.go genbindings: misc 2024-08-15 19:51:31 +12:00
emitcabi.go genbindings: misc fixes 2024-08-28 18:47:44 +12:00
emitgo.go genbindings: improved uintptr handling for enum types 2024-08-27 20:05:38 +12:00
exceptions.go genbindings: allow generating classes other than ^Q+ 2024-08-28 17:59:34 +12:00
intermediate.go genbindings: parse and call const methods for disambiguation 2024-08-28 18:47:23 +12:00
main.go genbindings: add namespaces support 2024-08-27 19:12:08 +12:00
transformblocklist.go genbindings: move checkComplexity into separate ast pass post-typedefs 2024-08-27 18:44:10 +12:00
transformchildclasses.go genbindings: track all typedefs, apply in a fixup AST pass 2024-08-26 22:52:46 +12:00
transformchildclasses_test.go genbindings/test: add test cases for child class expansion 2024-08-28 18:00:07 +12:00
transformoptional.go genbindings: support optional parameters for ctors 2024-08-25 12:50:48 +12:00
transformoverload.go genbindings: bind all Qt::constants as int 2024-08-25 17:50:14 +12:00
transformtypedefs.go genbindings: expand typedefs over inner list classes 2024-08-28 17:59:21 +12:00
transformtypedefs_test.go genbindings: misc fixes 2024-08-28 18:47:44 +12:00
util.go genbindings: try to invent better names for function overloads 2024-08-15 19:50:50 +12:00

README.md

genbindings

The genbindings program regenerates the Qt bindings.

Architecture design

Bindings are generated in two passes:

Pass 1

  1. Scan input directory for header files.
  2. For each header file:
  3. Run clang --ast-dump=json to get a JSON ast.
    • This is somewhat slow, the results will be cached in ./cachedir after the first run.
    • Strip all Clang AST nodes that were included from other files, to only consider the header's own definitions.
  4. Convert Clang AST to our own intermediate representation.
  5. Run some transformations on the intermediate representation.
  6. Cache and collect the global state of all known class names, enum names, and typedefs.

Pass 2

  1. For each intermediate-representation AST:
  2. Emit "CABI" cpp/h pair.
    • The CABI is a projection of Qt into plain C. The translation unit itself is C++, but the header can be used as extern c.
  3. Emit Go binding file.
    • The Go binding uses CGO to call into the CABI binding.

Configuration

It's tested to work on with Debian 12 / Qt 5.15 / Clang 14 / GCC 12.

You should check the following configuration:

  • main.go: Input directories containing Qt headers
  • exceptions.go: Check everything