Open Mingun opened 4 years ago
From what I understand, adding these annotations would allow to use reflection in runtime to determine if given member is:
seq
?)Which problems does that solve and how does that help with the questions that you've outlined above, i.e.:
?
a "field" (what is a "field", actually? an attribute in a
seq
?)
Yes
an "instance" (probably you'll want to distinguish between "parse instances" and "value instances"?).
No, I think not. I just want to mark fields/getters/[setters], that generated from instances
map. If I understand correctly, you mean
value
key (http://doc.kaitai.io/user_guide.html#_calculated_value_instances)value
keydetermining whether a member is internal field or not
Right now you are forced to use dirty haks to exclude fields, that is not fields, like checking name of field for leading underscore. With annotation you just go through all fields with these annotations
determining sequence of seq attributes
Initially, I hoped, that field sequence in the class will reflect order in seq
. But, unfortunally, Java does not guaranties, that method or field will in some order (for example, in Java 10, this is the reverse order of defining fields in a class), so in actual proposal I included index
parameter
If you want to build visualizer, you must rely on that fact, that internal fields begins with underscore. You can use the static field
_seqFields
to distinguish between parameters and structure fields. ~To distinguish between parameters and instances of the structure, you can see that there is a field with the same name, as getter method. If there is no field, it is aninstance
.~ No, this not work, instances also has backing field in classBut all these methods are fragile. I suggest introduce 3 annotations instead:
List of all related issues/PRs: