Skip to content

fix-golang-types-conversion#331

Open
timmyb32r wants to merge 1 commit intokaitai-io:masterfrom
timmyb32r:fix-golang-types-conversion
Open

fix-golang-types-conversion#331
timmyb32r wants to merge 1 commit intokaitai-io:masterfrom
timmyb32r:fix-golang-types-conversion

Conversation

@timmyb32r
Copy link
Copy Markdown

Experimented with my .ksy-file (https://pastebin.com/M4vQDJVA) - found out, that go-generated sources not compiled, bcs of type conversion:

cannot use (int(this.MapHeader) >> 4) & 15 (value of type int) as uint8 value in assignment

used cursor to fix it - with this fix, go-generated sources compiles fine.
I'm not a guru with scala, but hope this fix will be useful.

@nzoschke
Copy link
Copy Markdown

nzoschke commented Mar 28, 2026

The compiler also emits broken go for this ksy:

https://raw.githubusercontent.com/Deep-Symmetry/crate-digger/d95c444bde4bec6763cbbffd1a405dda0cc08750/src/main/kaitai/rekordbox_pdb.ksy

I confirmed this patch works

git clone -b fix-golang-types-conversion --depth 1 \
  https://github.com/timmyb32r/kaitai_struct_compiler.git /tmp/kaitai_struct_compiler
cd /tmp/kaitai_struct_compiler && sbt compilerJVM/universal:packageBin
cd - && unzip -qo /tmp/kaitai_struct_compiler/jvm/target/universal/kaitai-struct-compiler-0.12-SNAPSHOT.zip -d /tmp

# Download latest .ksy
curl -Lo rekordbox_pdb.ksy \
  https://raw.githubusercontent.com/Deep-Symmetry/crate-digger/d95c444bde4bec6763cbbffd1a405dda0cc08750/src/main/kaitai/rekordbox_pdb.ksy

# Compile to Go
/tmp/kaitai-struct-compiler-0.12-SNAPSHOT/bin/kaitai-struct-compiler \
  -t go --go-package pdb --outdir . rekordbox_pdb.ksy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants