Skip to content
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

[Feature] [name_entries] #2076

Open
1 task
rsp4jack opened this issue Jan 19, 2025 · 3 comments
Open
1 task

[Feature] [name_entries] #2076

rsp4jack opened this issue Jan 19, 2025 · 3 comments

Comments

@rsp4jack
Copy link

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

@paxcut
Copy link
Contributor

paxcut commented Jan 19, 2025

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;

@rsp4jack
Copy link
Author

rsp4jack commented Jan 19, 2025

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

@paxcut
Copy link
Contributor

paxcut commented Jan 19, 2025

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;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants