ImHex icon indicating copy to clipboard operation
ImHex copied to clipboard

[Feature] [name_entries]

Open rsp4jack opened this issue 1 year ago • 3 comments

What feature would you like to see?

For example I have this:

struct Region {
    char name[4];
    u32 val;
};

Region region[4] @ 0x00;

And it would be like:

region
-> [0]
-> [1]
-> [2]
-> [3]

And if I have [name_entries]:

struct Region {
    char name[4];
    u32 val;
};

fn extract(ref auto pat) {
    return pat.name;
};

Region region[4] @ 0x00 [[name_entries("extract")]];

It should be like:

region
-> abcd
-> qwer
-> 0d00
-> 0721
(these are just names)

How will this feature be useful to you and others?

Just look at it and you will get it! It would be nice for patterns organized in chunks of various types, as RIFFs are.

Request Type

  • [ ] I can provide a PoC for this feature or am willing to work on it myself and submit a PR

Additional context?

No response

rsp4jack avatar Jan 19 '25 06:01 rsp4jack

You already have that in ImHex using the name attribute. For example in your code it would be:

struct Region {
    char name[4];
    u32 val;
}[[name(name)]];

Region region[4] @ 0x00;

paxcut avatar Jan 19 '25 07:01 paxcut

This will apply everywhere that it is used, and I do not want that.

rsp4jack avatar Jan 19 '25 09:01 rsp4jack

That was just to show you that a new feature is not needed to accomplish what you want. If being able to turn it on and off is what you want it can be implemented as the following code shows. other customizations you need to work out but the functionality is already there.

import std.io;
import std.core;

struct Region<auto useName> {
    u32 idx = std::core::array_index();
    char name[4];
    u32 val;
}[[name(useName ? name : std::format("[{}]",idx))]];

Region<true> regionWithNames[4] @ 0x00;
Region<false> regionWithoutNames[4] @ 0x00;

paxcut avatar Jan 19 '25 11:01 paxcut