-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Move ImGuiIO initializers from constructor to struct definition #5541
Conversation
Thanks. Why not using = ImVec2(…) consructs ? |
I was a bit afraid to initialize I took a quick look into cimgui code parser, and it seems like it's not able to handle curly braces in data member declaration: |
It is not only that it does not handle curly braces in data member declaration (It could be worked) but the main concern is that it does not handle any initialization in data member declaration as that is not C compatible. |
There're numerous other aspects of |
The purpose of cimgui parser is to make an intermediate layer to make it compatible with C. The utility of cimgui is for other languajes that can interop with C but not with C++ so they can use imgui. Previous initialization of data members was done in contructors so that other languajes just needed to call the constructor for that (which was quite simple) |
I’m pretty sure that form of initialization makes no difference to code generation, it ends up in the constructor just the same. It is only a parsing problem ihmo.
|
There is no such contract!!!. |
Yes, in cimgui there are only "parsing problems". To face new behaviour, the C constructor instead of just wrapping the C++ constructor should also remember which was the initialization value of members and assign this value inside. |
No, you only need to call the constructor, as you alreasy do. The parsing problem is just ignoring what is after the = block on each line. |
This is already done. The problem is that member values get uninitialized values then (could be garbage or could be 0 or null values depending on the languaje) |
May be you are right. I just checked the Zoom member in cimnodes_r |
Calling C constructor calls C++ constructor which initializes struct from C++ struct definition. C struct definition just gives information about memory layout. |
Should be correctly parsed by cimgui now. |
Thank you very much! |
I looked at it and unfortunately I realize I don't think it is a good idea :( It would have been ideal for a fully public and configuration structure, but right now,
Right now given language support and the contents of I think in the short term it would be more reasonable to drop this idea. Sorry for the time taken. (PS: |
A follow-up for #5540.
With some initializers moved to struct definition, I had to replace memset with a bunch of default initializers. No strong opinion on exact syntax. Its just
= {}
felt like the best fit for this repo that avoids most vexing parse.