Add Qt bindings#76
Conversation
This reverts commit bd14c59.
|
I converted to draft because I want to first settle the corresponding usage in deltatouch, see https://codeberg.org/lk108/deltatouch/pulls/269 and chatmail/core#8330 |
That facet package/repo allows LLM usage (https://github.com/facet-rs/facet/tree/main/.claude) which may or may not be a bad sign for a core dependency. There is a feature request for supporting 1password's typeshare crate: #58, I think that may be interesting to explore for generating types for other languages. |
This adds qt binding generation. It uses the json parsing from qt. A transport-implementation is needed to use it, similar to typescript. I have an implementation for deltachat-cffi but i think it would go in the chatmail-core repo.
Click to expand the CffiTransport implementation
I created a hopefully generally useful
TypeInfotype, which can be created fromTypeDef::SHAPE. This should allow easier future expansions for other (C-like) languages.Future improvements: Add docs for generated types. Currently only the rpc methods themself are documentd.
Sidenote: I discarded an ealier draft to create bindings which tried to first implement json parsing on the C-layer with a swap-able json-parser implementation (to support both cjson and qtjson). Then C++ wrappers were added ontop of the C-Layer. But writing safe C code and interop is hard and the generated code was quite involved and hard to understand, all in all it got quite complicated. This approach is much simpler, it just works for qt, but the generated code is straight forward.
Sidenote 2: I also took a look into https://facet.rs/ as a replacement for
typescript-type-defsderive(TypeDef). It is an extensible reflection framework and an alternative to serde. https://docs.rs/facet-typescript could in theory replace our typescript generation. I did not investigate further because we'd have to either have to switch to use facet also for json de-/serialization or we'd have to duplicate all the#serde(..)annotations in deltachat-jsonrpc. (Facet is probably slower at runtime than serde.) The nice thing abouttypescript-type-defis that it reuses the serde annotations.Another related advencement is reflection and comptime in rust which might make the derives superfluous all together one day.