haxscramper / hcparse

High-level nim bindings for parsing C/C++ code
https://haxscramper.github.io/hcparse-doc/src/hcparse/libclang.html
Apache License 2.0
37 stars 2 forks source link

Serialize IR #14

Open haxscramper opened 2 years ago

haxscramper commented 2 years ago

Make CxxEntry IR serializable into json (or something else). Right now the structure is cyclic on .typeStore and some other fields (most likely only type store), so this needs to be addressed. Maybe just skip type store altogether and allow to re-create it again?

Serializing IR would make it possible for someone else to just take generated .json and construct the own binding generator (for nim or any other language, though hcparse is nim-specific for now). Considering how much information hcparse is holding during the wrapper generation process, it would be criminal to not make it accessible to the end users as well.

haxscramper commented 2 years ago

Generated wrappers should also contain a mapping between wrapped Cxx types and nim module that needs to be imported. This is needed to allow for inter-project dependencies.

haxscramper commented 2 years ago

Something other than .json need to be used, mainly due to its limitations wrt. to type handling.

Jsony creates minified json, while I would prefer to minimize diffs since I might want to commit generated files.

XML is better suited for that sort of data storage, but it is less widespread wrt. to language support.

haxscramper commented 2 years ago

frosty handles this task flawlessly, but generated sources are not human-readable (serialized to binary). The main objective is to be able to check IR dumps into git, and provide a schema file that can be used for anyone interested to write their own wrapper generator, so binary data formats are not suitable for this task.