-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get cimgui_internal.h to a compileable state #47
Get cimgui_internal.h to a compileable state #47
Conversation
…tances from cimgui.h to cimgui_internal.h Account for custom types in related headers when generating functions
…nds of DOM elements
…ntext special case
Really great to make progress on that!
Would there is a way to get the sizeof() of that structure and temporarily replace it by an opaque buffer, so the outer struct can work?
My thoughts was that ideally we should generate cimgui.h, cimgui.json and cimgui.json, cimgui_internal.json as separate files. At minimum the .h file should be separate. |
52ae98a
to
90b0a69
Compare
Just a progress update - with just some minor hacks to Dear ImGui, my in-development C# bindings generator currently generates bindings for the base Dear ImGui, internals, as well as SDL2 and Win32 backends, all nicely separated unlike ImGui.NET 😛 Still quite a lot of work to do, but it's coming together, all thanks to Dear Bindings. What is the work required for this PR? At least for the initial internals support version? |
Sorry about the delay! That's awesome work - thank you so much! I've done some testing with this now - the code all looks very sensible and I'm not seeing any regressions so on that front I think everything is fine. With a bodge in place for There are just three points that I think may need tweaking:
a) Create templates so that imtextedit_minimal_header can be processed with Dear Bindings like follows:
b) Add a remap to change the included STB header to the c) Add a remap to rewrite That then produced a version that I could compile and run without needing changes in ImGui itself or manual edits to the file. That isn't an ideal solution but it feels like it may well be good enough for the time being? From my perspective if we can get those three sorted out then I think we're good to merge this - at a minimum, if we can resolve 1 and 2 in this PR then I think we can pull this in as-is (as 3 only affects |
I haven’t looked into it but would accept any PR in main lib that solves your textedit problem. (Since presently we support a single active InputTextState only maybe I should make that structure use a heap allocation as an indirection…) |
Huh. I don't remember deliberately doing that. Looking at it, it's probably a result of a bad merge conflict resolution on my side (initializer storage was added after I did the initial version of this PR last year). I'll bring it back.
That actually comes from this PR #46 - the github action adds the
I'm a bit concerned about how generating the internals becomes a multi-step process. It's still better since it works around having to change the main library, but perhaps we can document it better? Or maybe even automate that I'm not aware of any clever way to allow multiple people to work on a PR. So I've just gave you access to my fork on GitHub, feel free to do any edits there! @ocornut I've poked around at the main library, but I couldn't come up with a universal way to expose ImStb::STB_TexteditState without either a lot of code changes, or without making things ugly, or without introducing yet another imconfig.h option just for this. Heap-allocating ImGuiInputTextState is indeed a viable option, but I admit, I don't think I can do that, my cpp-fu is just good enough for reading... |
|
I have pushed those changes. This add an indirection, renames the type and move helper functions to the .cpp files. The only thing left is the block that includes imstb_textedit.h which I think you can skip and replace with a forward declaration. (I am trying to move that block to the .cpp file now, but struggling with C/C++ forward of typedefs) |
Moved the include to .cpp file: I believe the situation should be easy to solve on your end. |
… avoid having to emit
Thank you! This simplified things a lot. I now simply replace Feels pretty robust now overall, to me at least :) |
Great - that does indeed seem to solve everything in a nice and simple manner. |
Feel free to merge it, yes, it has been a long time coming :)
Sure thing! |
It may be interesting to do a sanity check of comparing cimgui.h/cpp/metadata before/after this change? |
I've done that and they are identical (apart from a very minor thing in cimgui.json which is correct now). I only skimmed through it, but output quality is top-notch.
|
Additional feedback, sorry for spam: (1) in README:
Amend with:
To provide an explicit example. (2) Amend BuildAllBindings.bat accordingly. (3) After switching to this branch I got an error with my install:
After updating Python it worked:
Note that updating Python required reinstalling |
The minimum required Python version for the current codebase is 3.10 (which is what we use in GitHub Actions), let's note that in the readme
Not directly related, but - shall we rewrite BuildAllBindings.bat with PowerShell? Simply because PowerShell is the only truly cross-platform shell. That way, Linux/macOS people would be able to use BuildAllBindings as well. (alternatively, we can create a separate BuildAllBindings.sh, but then it's two files to maintain) |
Next stop - ImPlot 😛 |
Cool, I've merged that and updated the documentation to match. Shout if you spot any problems! With regards to rewriting |
(ImPlot would be cool indeed! ^-^) |
And thanks again for all your hard work on this! |
Thanks Serhii ! and Ben for taking the time to follow on it. |
This gets the generator to the point where
imgui_internal.h
can be successfully parsed and the corresponding C bindings are generated and are able to be compiled.This is highly experimental - the only benchmark so far is that
example_null.c
is able to compile and use a function fromimgui_internal.h
.Some notes:
cimgui.h
, then generatecimgui_internal.h
while referencing theimgui.h
using--config-include
.--config-include
was made appendable, meaning it can be specified multiple times.Few things that might need to be improved/fixed:
ImGuiContext
is special-treated as an opaque pointer, with all the struct innards removed. This is because it includes a field of typeImGuiInputTextState
, which includes a field of typeImStb::STB_TexteditState
, and I'm not sure how to really handle that at the moment. Do we also parseimstb_textedit.h
? cimgui seems to be doing that, at least.cimgui.h
andcimgui_internal.h
. For me personally, that's nice, but perhaps there's a use-case for internal-only metadata?cimgui_internal.h
be markedis_internal
in JSON metadata? Or perhaps the source file is enough to infer that a thing is coming fromimgui_internal.h
?At this point, I'll try to use this branch with the new C# wrapper I'm developing, and as I'm bound to find bugs, there will probably be some fixes.