Thank you for the feedback, feedback is one of the biggest thing I'm lacking at this point.
I haven't looked at the files you linked yet, but some (semi-)quick comments you might find useful:
When displaying an array, pad the indices to the number of digits required by the biggest index.
- To be honest, the command line version had this feature and I thought it was still around. I'll re-enable it unless I can remember why it's not there anymore.
Support for ++ -- -= += ... operator would be nice
- This is a definite agree, and it is planned for the next time I do anything with the layout language itself. I'll add an improvement ticket to
github.
... I needed the address/offset of the current location in the file. I don't know if that's possible to do or if there is a better way to do it.
- It is possible! It was one of the more recent features added. To get the current address you can use
current_address(), at the same time I added
size_of_file. You can see how it's used in
png bet in the examples folder. I have considered the
& operator to get the address of the member as well - but I haven't added anything like that yet. For a more complete documentation of the language I wrote
some docs, that file is also a part of the package you get when you download the GUI application.
Regarding your next point, the
id_string in the example, it brings up an interesting point I don't know how to solve yet.
The problem is a "repeating member" vs "an array". Technically they're implemented the same way - an array in BEdit is just a "for i"-loop, but the problem comes with representation. Therefor there's a tag that gets applied to arrays telling the command line and GUI that "this was declared as an array". I was thinking of maybe having something like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 | struct Foo
{
u(4) a[2];
for (var i = 0; i < 2; i = i + 1)
{
u(4) b[2];
u(4) c;
}
};
- Would produce -
a[0] 123
a[1] 456
b#0[0] 123
b#0[1] 456
c#0 123
b#1[0] 123
b#1[1] 456
c#1 123
|
to disambiguate between the cases, but let's say the jury is still out on that one... Maybe a repeating member should just pretend it adds to an array, but that might lead to confusion if you have multiple arrays that are repeating members.
Arrays and
repeating members is still an unsolved problem, but a known one.
The display of "small enough" members (and arrays) being on separate lines is a known
annoyance, not only for the command line but also for the GUI (especially the hierarchy view). It's very clear when you have a
vec3 type that the members being on different indent levels bring no value. I've been playing around with having
internal as a keyword to indicate that "this member should be interpreted as non-nested", but that wouldn't solve the array case you mentioned.
I would like to be able to use sizeof( struct_type )
- So would I, but it's tricky - but it would be
really useful. One of the reasons I haven't implemented it is because the size of the type can depend on.. well.. everything. Unlike C the type can have parameters, and it can also have a size determined on the value of its members. Hence a
sizeof operator isn't trivial to implement. However, most struct sizes don't have dependencies on the data file being evaluated, and for those it's trivial to determine the size. I added
this issue to keep track of the feature request. Even in the case where the size of the type depends on the current address, it's not impossible to implement (maybe
sizeof(@(my_address) MyStruct)?).
I would like the "hidden" thing to be an attribute on a regular declaration, ...
- Not a bad
idea.
I think using a more "modern" way to declare variable would be great...
- Ah, it would certainly make it easier to parse! Joking aside, the reason it's "like a C language" is to make it easier to learn for C/C++ programmers - a knowledge-set I presume most people who deal with binary files have. Of course there's nothing preventing us from implementing multiple "languages" as both the command line and GUI only uses the intermediate representation (and some line information for debugging purposes), but that's not on the roadmap at this point in time... but the layout language is in public domain ;)
I'll have a look at the files you linked later this week if time permits (I do have some BEdit plans for the weekend unless I chicken-out).