Comments (7)
Thanks!
from kaitai_struct.
@LogicAndTrick @sergeyzelenyuk Can anyone provide any meaningful examples for these to make tests? I keep thinking about it and the more I think, the more I don't like the idea actually ;) All examples I can come up with are very artificial and mostly can be achieved through other means.
What I don't like about these vars as well is that they are very context-dependent, while we generally strive to achieve "pure functional returns" without any side-effects, i.e. no matter where in the algorithm you access the field and what field type that is (i.e. sequence attribute, parsed instance or value instance), the result is going to be the same. It's not 100% true (as we don't have any checks for use of uninitialized variables before their usage), but it's fairly close. Exposing very state-related stuff like _io.pos
and _io.eof
aids in breaking this paradigm and I'm not sure what it brings anything.
from kaitai_struct.
There might be another way to cover this scenario, but I have a format which has an optional information block at the end of the file. There's no flag in the file to indicate if it's there, it's just either there at the end of the file or it isn't. Using a manually-coded parser, I currently do an EOF check to see if the additional block is present or not.
var mainPart = ReadMainPart(stream);
var infoPart = stream.IsEof() ? null : ReadInfoPart(stream);
It would be useful to be able to do something like this:
seq:
- id: main_part
type: main
- id: info_part
type: info
if: not _io.eof
Even though it would technically work in this situation, I wouldn't want to use a repeat
structure in this case because the result isn't a list, it's always a single object or a null.
from kaitai_struct.
Ok, _io.eof
is mostly there:
- C# test is failing - @LogicAndTrick, could you take a look? I've upgraded by Mono installation and now it's broken, so I can't even build the tests :(
- Perl test is missing - @sergeyzelenyuk, any news on the autoconversion script?
from kaitai_struct.
Fixed for C# in d9609e2. IsEof
was a function in the runtime but it was being called like a property. I changed it into a property for consistency with the others, and updated the compiler to match. Minor changes to runtime, tests, and compiler.
from kaitai_struct.
_io.pos
test is there, and, again, C# test seems to fail :( @LogicAndTrick, can you come to the rescue again?
from kaitai_struct.
Ok, looks like both tests are fine now. Closing this one, phew.
from kaitai_struct.
Related Issues (20)
- `_root` / `_parent` chain broken by recursive use of the top-level type
- `bytes.to_s(encoding)` should validate the passed encoding
- Using enum members as int is broken in ruby HOT 3
- Add explanation to errors `spec_build_failed` and `format_build_failed` on https://ci.kaitai.io/ HOT 1
- C++: the type of all integer constants wrongly deduced as `int32_t` HOT 1
- ci.kaitai.io: use snake_case for test names instead of PascalCase HOT 1
- Java: byte array elements propageted to `int` as signed values (0xFF -> -1 instead of 255)
- Unclear expected values for integer division HOT 4
- Invalid Java code generated: Incompatible types: possible lossy conversion from int to byte HOT 3
- Ruby, Lua: missing `require`s not detected by tests due to `require` leaks HOT 1
- Invalid Java code generated: Switch selectors cannot be of type "long" HOT 1
- Recursive decoding of value HOT 3
- Python: Fix missing `assertRaisesRegexp` method in Python 3.12
- C++11: segfault in debug mode for arrays HOT 1
- Construct: the order of `Computed` fields matter
- How to disable building documentation and JS?
- Health of the project?
- Support for Julia HOT 1
- Error: Could not find or load main class io.kaitai.struct.JavaMain HOT 5
- Extended nullabillity support for Kotlin and other null-safe languages
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kaitai_struct.