Skip to content

Commit 6eaa455

Browse files
committed
Fixed handling of preprocessor defines and comments in metadata for anonymous structs (#101)
1 parent 089a24e commit 6eaa455

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

dear_bindings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Dear Bindings Version v0.16
1+
# Dear Bindings Version v0.16 WIP
22
# Generates C-language headers for Dear ImGui
33
# Developed by Ben Carter (e-mail: ben AT shironekolabs.com, github: @ShironekoBen)
44

docs/Changelog.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
--- v0.16 WIP
2+
3+
* Fixed the JSON metadata generator where preprocessor declarations on anonymous structs were getting applied to the
4+
fields in the structure but not the implicit field where that structure was used. (#101)
5+
* Made implicit fields generated by anonymous structs in the metadata inherit the comments from their original
6+
structure declarations. This produces duplicate comments in some cases (one at the point where the anonymous struct
7+
is declared and another where it is used), but this seems preferable to potentially losing the comment entirely in
8+
some usage scenarios. (#101)
9+
110
--- v0.15
211

312
* Fixed the DX11 backend header including forward-declarations for some DirectX types that conflict with the actual

src/generators/gen_metadata.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,16 @@ def emit_struct_field_list(container, fields_root):
358358
dummy_field.is_array = [False]
359359
dummy_field.width_specifiers = [None]
360360
dummy_field.is_anonymous = child.is_anonymous # Technically wrong, but see above
361+
# We need to pretend this is in the same place in the tree, otherwise preprocessor defines don't
362+
# propagate correctly to it
363+
dummy_field.parent = child
364+
# If the struct had comments, temporarily attach them to the dummy field
365+
# This will result in the comments getting duplicated as they will also appear on the struct
366+
# declaration, but that's probably acceptable
367+
if child.pre_comments:
368+
dummy_field.pre_comments = child.pre_comments
369+
if child.attached_comment:
370+
dummy_field.attached_comment = child.attached_comment
361371
dummy_type = utils.create_type(child.name)
362372
dummy_field.field_type = dummy_type
363373
emit_field(fields_root, dummy_field)

0 commit comments

Comments
 (0)