Registered Member
|
Hi,
I'm trying to write an Okteta structure definition in javascript. I think I understand how it works for basic types, but I've run into a problem. I want to know if its possible to skip over a certain number of bytes, or alternatively skip to an offset in the data that I have calculated based on data that I've read. The data I'm trying to interpret is has structures which identify their size and type, so I want to read one of those in, then skip to the next one and repeat the process, ending up with an array of nodes with interpreted size and type. Thanks for any help, Dan |
Registered Member
|
Hi,
What you want to do is possible, however it is not as nice as I would like it to be. There is a
It can be created using the following syntax:
In the future I want to allow any javascript function to be used as the pointer value, however this is not yet possible. An example structure would be:
If you want to just skip a few bytes I am afraid currently the only solution is to add a dummy array as padding in between. This could look like this:
I hope this helps you with your structure. I must admit that the documentation for the structures tool is quite lacking, I never really got around to writing it. The currently most up to date documentation can be found here: http://userbase.kde.org/Okteta/Writing_structure_definitions. I will try to rewrite it in order to be more useful, but currently I am very busy with KDE Frameworks 5 development. Regards Alex |
Registered Member
|
Hi Alex,
Thanks for the detailed reply! The pointer type does sound very close to what I want, but I guess I really need the ability to substitute a java function for the uint32() as the target location as you said. I don't think inserting dummy bytes will work in my case as the sizes of the structures I'm working with can be large. It's a shame, but I can still achieve some good value out of my structure decoder without the pointer related part. Thanks for all the hard work, and also for the link to the new documentation, I hadn't found that before. Regards, Dan |
Registered users: Bing [Bot], blue_bullet, Google [Bot], rockscient, Yahoo [Bot]