native icon indicating copy to clipboard operation
native copied to clipboard

[ffigen] Output style to multiple files

Open dcharkes opened this issue 1 month ago • 2 comments

@marshelino-maged @HosseinYousefi and I were discussing ingesting JNIgen and FFIgen generated code into a vector database in the context of https://github.com/dart-lang/native/tree/main/pkgs/native_doc_dartifier.

Java and Kotlin have a natural structure in their files with the fully qualified names. C, Obj-C, and Swift don't. The individual files are a natural way to ingest documents and retrieve documents: it retrieves a single class at the time. (Also, when the generated bindings change, generating new embedding vectors can be short-circutted on files that didn't change at all with file hashes.)

So, it would be useful to have an option to split the output of FFIgen into multiple files.

For C, do we have access to the file paths where functions/structs are defined? @mannprerak2 (Or otherwise we would need to split per struct and function, but that would be more confusing for users and LLMs I think.)

@liamappelbe Would there be a natural splitting point for Objective-C and Swift? Is per class or interface a good way? Do we have info about the the source-file-paths? Would that be a good split?

P.S. Low prio feature request. Just brainstorming at this point.

dcharkes avatar Oct 09 '25 09:10 dcharkes