You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have some way to set a non-zero default value for an in variable.
An example:
u32 max_data_size in = 1024 * 1024;
Alternatively it might be better to have an attribute or the like to set the value instead.
How will this feature be useful to you and others?
I have a use case where I would like to avoid parsing some data depending on the size to keep the pattern fast. However it would be good to have a way for the user to increase or decrease the values depending on their usage.
I believe that this would make variables useful in situations where having a zero value in the variable isn't very useful or may even cause errors.
Request Type
I can provide a PoC for this feature or am willing to work on it myself and submit a PR
Additional context?
I have this pattern for afs files (archive files used by sega, see [https://github.com/fuzziqersoftware/gctools/blob/master/src/afsdump.cc] for some code that pulls out the data):
#pragma magic [41 46 53 00] @ 0x00
u32 max_data_size = 1024 * 1024;
struct file {
le u32 offset;
le u32 size;
if (size < max_data_size) {
u8 data[size] @ offset;
}
};
struct afs {
le u32 magic;
le u32 num_files;
file files[num_files];
};
afs afs @ 0x00;
I would like to have max_data_size be an in variable, but can't do that without it being zero by default.
The text was updated successfully, but these errors were encountered:
What feature would you like to see?
It would be nice to have some way to set a non-zero default value for an in variable.
An example:
Alternatively it might be better to have an attribute or the like to set the value instead.
How will this feature be useful to you and others?
I have a use case where I would like to avoid parsing some data depending on the size to keep the pattern fast. However it would be good to have a way for the user to increase or decrease the values depending on their usage.
I believe that this would make variables useful in situations where having a zero value in the variable isn't very useful or may even cause errors.
Request Type
Additional context?
I have this pattern for afs files (archive files used by sega, see [https://github.com/fuzziqersoftware/gctools/blob/master/src/afsdump.cc] for some code that pulls out the data):
I would like to have
max_data_size
be anin
variable, but can't do that without it being zero by default.The text was updated successfully, but these errors were encountered: