lv_binding_cpp icon indicating copy to clipboard operation
lv_binding_cpp copied to clipboard

Progress on lv_cxx_bindgen

Open voltangle opened this issue 1 year ago • 18 comments

It's just that I started work on my implementation of a C++ binding generator, soo I would like to know if someone is already working on this, so that I can know if I should still continue work on mine Current progress is an implemented extractor of functions from .h files, and an abstract source code tree (a representation of all binding parts in memory) generator in progress.

voltangle avatar Dec 28 '23 22:12 voltangle

It's just that I started work on my implementation of a C++ binding generator

A generator would be great! Mostly I have seen only hand written C++ bindings.

As far as I know no one is actively working on it now. Please keep us posted about the progress.

kisvegabor avatar Dec 30 '23 10:12 kisvegabor

If you're interested, here's a link to the repo: https://github.com/dynamium/lv_cxx_bindgen

voltangle avatar Dec 30 '23 14:12 voltangle

I plan to work with this. So recommended to update the lvgl code to the latest version

xinsuinizhuan avatar Jan 03 '24 08:01 xinsuinizhuan

I agree to this based on LVGL v9 (in current master). @kdschlosser is working on a simple JSON file containing the whole LVGL API in an easy to digest form. I hope it will go public soon.

kisvegabor avatar Jan 03 '24 09:01 kisvegabor

Now that sounds good! Because right now parsing all the source code is pretty hard to do right, especially with all the macros ngl Oh, and yes, if that JSON file becomes a thing, the generator can support both source code parsing and JSON, or better yet, have it separated into two utilities, the one that parses header files and extracts everything into a JSON file, and the one that generates all the bindings from the same JSON file

voltangle avatar Jan 03 '24 11:01 voltangle

See the discussion about the JSON file here: 5168

kisvegabor avatar Jan 03 '24 18:01 kisvegabor

I am! Got it working for version 8 en 9 with examples. Replace the lvgl dir with your fav. version. Generates with Python.

https://github.com/gjvanderheiden/lv_binding_cpp

This is weeks of work. I needed it to develop my own project.

gjvanderheiden avatar Jan 08 '24 14:01 gjvanderheiden

The only caveat is order of deletion, because the c lib deletes it's child objects.

This is all fine, as long as you declare your object in the same order as creation. Assuming you're not using raw pointers. (Then delete in the reverse order). Also tried to add a check, worked also, but wasn't sure about it being better

gjvanderheiden avatar Jan 08 '24 14:01 gjvanderheiden

Hi @gjvanderheiden,

Thank you for jumping in! It's great now we have 2 people working on it.

I suggest figuring out what the advantages of yours and @ggoraa's implementation are and try to unify them.

kisvegabor avatar Jan 08 '24 21:01 kisvegabor

I think the JSON file proposed in https://github.com/lvgl/lvgl/issues/5168 shall be used in the end so that the bindings can work from a common source.

kisvegabor avatar Jan 08 '24 22:01 kisvegabor

Sorry, I don't intend to redo my idea for a first version. I deleted my fork on GitHub.

I'm sorry, but my project is done as version 1. I've put many many many hours in the bindings and it is fully working for version 8 en 9, has examples, can wrap structs with assessors to name a few features. I did this in my own time. I'm talking about weeks full time. I wrote it, so I'm the owner of my code. Not to say I'm not open for suggestions, modifications, improvements. More to say I ment it as a take or leave over as is first version.

It could use json in the future, but now it's working. It also parses the #if LV_USE_... statements around the methods. It also parses comments and detects and removes the C-object parameter as It is even uncertain of json could provide the level of detail I'm doing in my version.

I wish good luck to the project.

gjvanderheiden avatar Jan 09 '24 07:01 gjvanderheiden

I'm sorry to hear that. All I wanted to say is that we are smarter together and we can discuss how to do things better.

kisvegabor avatar Jan 09 '24 10:01 kisvegabor

By the way, is the reward still a thing? :D

voltangle avatar Jan 23 '24 19:01 voltangle

Sure, it is! :slightly_smiling_face:

kisvegabor avatar Jan 24 '24 10:01 kisvegabor

Is there an update on this work or an example on how the generated API will look like? lvgl is now the best alternative to Qt embedded, but a good C++ support is mandatory for this.

boulabiar avatar Feb 15 '24 15:02 boulabiar

lvgl is now the best alternative to Qt embedded

Oh thank you! :blush:

but a good C++ support is mandatory for this.

I'm also curious about the current status. :eyes:

kisvegabor avatar Feb 16 '24 14:02 kisvegabor

I'm also curious about the current status. 👀

The status is "half way there" :)

I took a little break from development because of personal reasons (mainly exams and the start of the second semester in uni, but if I'm being honest, I also got a little carried away while playing around with Fusion 360, and started another project lmao 😅), but I plan to return very soon! Don't worry guys, the project is far from being dead, it's gonna be done no matter what :)

voltangle avatar Feb 17 '24 17:02 voltangle

Happy to hear that you haven't gave up! :muscle: :rocket:

kisvegabor avatar Feb 19 '24 20:02 kisvegabor