Uploaded image for project: 'Code Tools'
  1. Code Tools
  2. CODETOOLS-7903616

Bad formatting of layout string for structs with nested anon structs/unions

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • None
    • None
    • tools
    • None

      Consider this header:

      ```
      struct Foo {
          struct {
              int x;
              union {
                  int y;
                  int z;
              };
          };
      };
      ```

      Jextract generates this:

      ```
      private static final GroupLayout $LAYOUT = MemoryLayout.structLayout(
              MemoryLayout.structLayout(
              foo_h.C_INT.withName("x"),
              MemoryLayout.unionLayout(
              foo_h.C_INT.withName("y"),
              foo_h.C_INT.withName("z")
          ).withName("$anon$7:9")
          ).withName("$anon$5:5")
          ).withName("Foo");
      ```

      As it can be seen, the nested anon layouts are not indented as they should and this causes the layout declaration to be not very readable.

            mcimadamore Maurizio Cimadamore
            mcimadamore Maurizio Cimadamore
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: