-
Notifications
You must be signed in to change notification settings - Fork 18
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
In debug mode generated classes must implement special debug interfaces #27
In debug mode generated classes must implement special debug interfaces #27
Comments
I don't quite understand the idea yet — maybe you can go on with some proof of concept code to illustrate how we can avoid reflection? |
public interface PositionInfo {
Map<String, Integer> attrStart();
Map<String, Integer> attrEnd();
Map<String, ? extends List<Integer>> arrStart();
Map<String, ? extends List<Integer>> arrEnd();
}
final KaitaiStruct struct = …;
// Generator generates classes, that implements this interface,
// if debug mode/positions-info is enabled
if (struct instanceof PositionInfo) {
final PositionInfo info = (PositionInfo)struct;
//...
} |
Sure, this makes sense. Let's do it! |
I'll prepare PR in next couple days, where I also plan to change the way information is stored to solve issue #26. I plan to store both positions -- relative to current IO object and relative to root IO object. This will solve problems with showing incorrect regions in https://github.com/kaitai-io/kaitai_struct_gui (see #26). |
Currently to obtain debug maps with positions you must use reflection. That looks ugly, because you need to catch checked exceptions, that never will be thrown.
I suggest to add to runtime special interfaces, that will be implemented by generated classes when debug mode is activated.
The text was updated successfully, but these errors were encountered: