-
-
Notifications
You must be signed in to change notification settings - Fork 93
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
[Build] Initial implementation with API generation #132
Conversation
Just saw this, looks very interesting. |
6c0432c
to
ff9b88d
Compare
Excited for this! |
Wondering how this is PR is going, since I want to use some features only available on a more recent ImPlot version :) |
Hi @SpaiR, do you think this binding generator might be helpful? https://github.com/dearimgui/dear_bindings |
Hello. This is a generator for definitions. It helps to avoid manual routines when you need to go through header files. However, for the purpose of this PR, it's useless since I've already created such a generator. I'm using clang++ and its ast-dump functionality, and I find the result more robust than those of Python scripts. For example, this is how I extract enums: {
"@type" : "AstEnumDecl",
"offset" : 121559,
"name" : "ImGuiTreeNodeFlags_",
"decls" : [ {
"@type" : "AstFullComment",
"offset" : 121495,
"decls" : [ {
"@type" : "AstParagraphComment",
"offset" : 121495,
"decls" : [ {
"@type" : "AstTextComment",
"offset" : 121495,
"text" : " Flags for ImGui::TreeNodeEx(), ImGui::CollapsingHeader*()"
} ]
} ]
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 121585,
"name" : "ImGuiTreeNodeFlags_None",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 0,
"value" : "0",
"evaluatedValue" : "0"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 121634,
"name" : "ImGuiTreeNodeFlags_Selected",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 1,
"value" : "1 << 0",
"evaluatedValue" : "1"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 121710,
"name" : "ImGuiTreeNodeFlags_Framed",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 2,
"value" : "1 << 1",
"evaluatedValue" : "2"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 121824,
"name" : "ImGuiTreeNodeFlags_AllowItemOverlap",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 3,
"value" : "1 << 2",
"evaluatedValue" : "4"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 121943,
"name" : "ImGuiTreeNodeFlags_NoTreePushOnOpen",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 4,
"value" : "1 << 3",
"evaluatedValue" : "8"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 122104,
"name" : "ImGuiTreeNodeFlags_NoAutoOpenOnLog",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 5,
"value" : "1 << 4",
"evaluatedValue" : "16"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 122288,
"name" : "ImGuiTreeNodeFlags_DefaultOpen",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 6,
"value" : "1 << 5",
"evaluatedValue" : "32"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 122371,
"name" : "ImGuiTreeNodeFlags_OpenOnDoubleClick",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 7,
"value" : "1 << 6",
"evaluatedValue" : "64"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 122461,
"name" : "ImGuiTreeNodeFlags_OpenOnArrow",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 8,
"value" : "1 << 7",
"evaluatedValue" : "128"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 122668,
"name" : "ImGuiTreeNodeFlags_Leaf",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 9,
"value" : "1 << 8",
"evaluatedValue" : "256"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 122790,
"name" : "ImGuiTreeNodeFlags_Bullet",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 10,
"value" : "1 << 9",
"evaluatedValue" : "512"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 122883,
"name" : "ImGuiTreeNodeFlags_FramePadding",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 11,
"value" : "1 << 10",
"evaluatedValue" : "1024"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 123101,
"name" : "ImGuiTreeNodeFlags_SpanAvailWidth",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 12,
"value" : "1 << 11",
"evaluatedValue" : "2048"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 123428,
"name" : "ImGuiTreeNodeFlags_SpanFullWidth",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 13,
"value" : "1 << 12",
"evaluatedValue" : "4096"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 123568,
"name" : "ImGuiTreeNodeFlags_NavLeftJumpsBackHere",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 14,
"value" : "1 << 13",
"evaluatedValue" : "8192"
}, {
"@type" : "AstEnumConstantDecl",
"offset" : 123910,
"name" : "ImGuiTreeNodeFlags_CollapsingHeader",
"qualType" : "ImGuiTreeNodeFlags_",
"order" : 15,
"value" : "ImGuiTreeNodeFlags_Framed | ImGuiTreeNodeFlags_NoTreePushOnOpen | ImGuiTreeNodeFlags_NoAutoOpenOnLog",
"evaluatedValue" : "26"
} ]
} There's no need to say that it can generate definitions for any header files, even those not related to Dear ImGui. I understand your concerns about this PR. I, myself, am not pleased with how it is progressing. The reason for its prolonged development is time. It's hard to find the motivation to work on it in my spare time. During my working hours, I have many more responsibilities. Still, I believe the PR will be completed eventually. After that, tasks like binding updates will become a routine thing. At the moment, I've fully covered the function generation for the main |
Hi @SpaiR, I have increased my monthly contribution to the project, as I find it very useful and would love to see it evolve! Your work is much appreciated. I would encourage others to show their appreciation as well – even a little goes a long way in motivation: https://ko-fi.com/spair |
bcb15f4
to
ba36c00
Compare
ba36c00
to
95f6069
Compare
We believe in you! 😄 |
This PR was closed in favor of PR #240, which essentially implements the API for generation. At some point in time (exactly 2 years after the creation of this PR 🫠 ), I realized that the process had significantly stalled and it was necessary to move the bindings forward. Therefore, over the last few months, after over a hundred commits, this issue has been resolved. The API is far from perfect and has room for growth, but my primary focus now is to bring the official repository up to the Dear ImGui version. After that, we can think about QoL improvements. More updates will follow. |
Description
At the moment binding is created manually in Java code. And it becomes very frustrating to do, when you need to copy paste the same method 5 more times, just to implement "optional" args behaviour.
The new approach introduces an API for automatic binding generation. All is required is to provide a metadata file in a proper syntax. Stuff still need to be done manually. Yet everything becomes much easier when to implement methods with "optional" args you just need to mark those args as optional.
TODO
Since generation API mostly automates things around the old approach, they can co-exist.
Type of change