← All areas

Code Generation

Much of Tom is generated. The **Code Generation** area collects the generators that turn annotated Dart into the bridges and reflection data the framework relies on — the D4rt bridge generator and the reflection generator — cherry-picked from their home components so they can be understood together.

In this area

tom_d4rt_generator Published

tom_d4rt_generator · v1.9.2
21.0k loc · 878 tests · 14.8k test LOC
Reads `buildkit.yaml`, follows barrel exports, and emits `*.b.dart` files that register native Dart APIs with the interpreter. The bridge-writing automation for the family.
Published

tom_d4rt_generator role: extension

tom_d4rt_generator · v1.9.2

To call real Dart APIs from inside a sandboxed script, the interpreter needs a bridge — a class mapping interpreter calls to native invocations. `tom_d4rt_generator` automates writing them. From a `d4rtgen:` block it follows barrel-file export chains, respects `show`/`hide`, and uses the analyzer to extract constructors, methods, getters, operators, type parameters, and defaults. It emits `BridgedClass` registrations, relaxer wrappers, proxy classes, and an entry point — never hand-edited. The generated files are consumed at runtime by both interpreter lines and by bridge corpus packages such as `tom_d4rt_flutter_ast`. Because the bridge API is shared, one generated bridge works against `tom_d4rt` and `tom_d4rt_ast` alike.

LOC
21.0k
Tests
878
Test LOC
14.8k
29 docs · 0 API

tom_reflection_generator Published

tom_reflection_generator · v1.1.1
7.0k loc · 4 tests · 46 test LOC
The standalone generator that produces the `.reflection.dart` files `tom_reflection` consumes. It runs as a build_runner builder or a CLI for one-off and CI builds.
Published

tom_reflection_generator role: extension

tom_reflection_generator · v1.1.1

`tom_reflection_generator` builds the reflection data that `tom_reflection` depends on. It scans annotated Dart sources and emits the `.reflection.dart` files that carry the mirror information for runtime introspection and invocation. It can run two ways: as a `build_runner` builder wired through `build.yaml`, or as a standalone command-line tool for single entry points, recursive directory processing, or CI pipelines. A programmatic API is also exposed for embedding generation in other tools. The package bundles the builder, the build_runner integration, and the CLI that were previously part of the Tom build tooling, so any Dart or Flutter workspace using `tom_reflection` can generate reflection without that heavier dependency.

LOC
7.0k
Tests
4
Test LOC
46
7 docs · 1 API
Explore other areas