kaitai_struct icon indicating copy to clipboard operation
kaitai_struct copied to clipboard

support for .to_s function to convert interger to string

Open toog opened this issue 5 years ago • 5 comments

using example from bcd.ksy (renamed to join it in this issue)

bcd.ksy.txt

produce good code in ruby but in GO can't have result, only error message : "an implementation is missing"

toog avatar Dec 17 '19 22:12 toog

Current golang support status can be observed here: https://ci.kaitai.io/ As you can see, it's nowhere close to 100%.

Please consider contributing fixes to make it better supported ;)

GreyCat avatar Dec 17 '19 22:12 GreyCat

Hooking into this question, I have a larger file I am trying to compile to go, is there any way to have a more specific error on what feature is missing ?

File: https://github.com/Deep-Symmetry/crate-digger/blob/main/src/main/kaitai/rekordbox_anlz.ksy

s00500 avatar Oct 06 '23 13:10 s00500

@s00500:

Hooking into this question, I have a larger file I am trying to compile to go, is there any way to have a more specific error on what feature is missing ?

Try the --ksc-exceptions CLI option - it will give you a stack trace:

$ kaitai-struct-compiler --help
...
  --ksc-exceptions         ksc throws exceptions instead of human-readable error messages

generalmimon avatar Oct 06 '23 17:10 generalmimon

@s00500 The problematic part is here - rekordbox_anlz.ksy:424-430:

      mask:
        value: |
          [
            (0xCB+c).as<s1>, (0xE1+c).as<s1>, (0xEE+c).as<s1>, (0xFA+c).as<s1>, (0xE5+c).as<s1>, (0xEE+c).as<s1>, (0xAD+c).as<s1>, (0xEE+c).as<s1>,
            (0xE9+c).as<s1>, (0xD2+c).as<s1>, (0xE9+c).as<s1>, (0xEB+c).as<s1>, (0xE1+c).as<s1>, (0xE9+c).as<s1>, (0xF3+c).as<s1>, (0xE8+c).as<s1>,
            (0xE9+c).as<s1>, (0xF4+c).as<s1>, (0xE1+c).as<s1>
          ].as<bytes>

Type casting (.as<>) is not yet implemented for Go, see https://github.com/kaitai-io/kaitai_struct/issues/931.

generalmimon avatar Oct 06 '23 18:10 generalmimon

Hey @generalmimon Thanks a lot, that was very helpful!

Do you have any pointers to what would need to be done to add this feature? Should I start looking into the compiler or the runtime part or is there any other tipps to where to start contributions?

Greetings

s00500 avatar Oct 08 '23 06:10 s00500