Skip to content

[ffigen][jnigen] Util to dump entire parsed API #3605

Description

@liamappelbe

We tell people to write a Dart config script for FFIgen/JNIgen, and give them a bunch of examples. But if you write a config, and the API elements you expect don't appear in your bindings, it's unclear what to do next.

One debugging approach, under the new visitor API, is to write a custom visitor that just prints all the API elements. Then you can see if the problem is that you haven't set the correct entry points (headers etc), or your filters are misconfigured.

We should provide a util that does this, so users don't have to do it. Best API is probably an extension method on FfiGenerator/JniGenerator that dumps all the AST nodes (public AST nodes, as seen by a custom visitor). Eg:

Func(originalName, USR)
ObjCInterface(originalName, USR)
ObjCMethod(ObjCInterface(originalName, USR), methodSelector)
...

That output is not the most human readable format, but it's clear and greppable. Other suggestions welcome.

Activity

  1. dcharkes commented on Sep 7, 2026

    @dcharkes
    Collaborator

    An alternative idea is to have a formatted JSON/YAML format for the full user-visible AST. And a flag to dump it. And then we can dump it after every visitor so that you can debug your visitor that way. (Like what we do with printing the IL in the Dart compiler.)

    We can either dump it to stderr/stdout or dump it to text files.

  2. amanmaurya92 commented on Sep 8, 2026

    @amanmaurya92

    I would like to work on this. Please assign this to me.

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

Metadata

Metadata

Assignees

Labels

good first issueA good starting issue for contributors (issues with this label will appear in /contribute)package:ffigenpackage:jnigen

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions