dearimgui / dear_bindings

C header (and language binding metadata) generator for Dear ImGui
MIT License
221 stars 12 forks source link

Add information from imconfig.h #43

Open Ldash4 opened 9 months ago

Ldash4 commented 9 months ago

Unless I am missing something, it seems that changed defines in imconfig.h aren't available in cimgui.json. This is quite important for getting the bindings to be exactly compatible.

ShironekoBen commented 9 months ago

Oops, yeah, you're absolutely right - I'd somehow overlooked that use-case entirely. Thanks!

I've pushed an update now that parses imconfig.h whilst generating the headers, and also includes any content it finds there in the JSON output. It also adds a --config-include option so that custom configuration headers can be included if required.

Fingers crossed that solves the issue for you - if not the just let me know what's broken and I'll have another go at fixing it.

Ldash4 commented 9 months ago

I may be doing something wrong, but I'm not seeing the output in the json. Repro:

  1. Clone Dear ImGui at a6143874 (probably doesn't matter)
  2. Clone Dear bindings at eec94ae (latest as of writing)
  3. Make directory out/
  4. Modify something in imgui/imconfig.h (I uncommented IMGUI_DISABLE_OBSOLETE_FUNCTIONS)
  5. Run python dear_bindings/dear_bindings.py -o out/c_imgui imgui/imgui.h
  6. Search for IMGUI_DISABLE_OBSOLETE_FUNCTIONS in out/c_imgui.json. It cannot be found as a define
ShironekoBen commented 9 months ago

I just had a look and you're absolutely right, but that's actually due to a different "bug"... it seems the metadata doesn't include #defines that don't have a value.

What's more, it appears to have been deliberate (there was a comment explicitly stating that was what it was doing), but I have to admit I have absolutely no idea why I did that.

I can't think of any reason they shouldn't be in there (and, indeed the actual emit_define code explicitly handles the case where there is no value present!), so I've updated the code to remove that check meaning that they should be included now.

Give that a try and let me know if it's still broken for you!