Created
March 30, 2018 12:41
-
-
Save cugu/5d941ad5bd851dd055efadc53c0417f0 to your computer and use it in GitHub Desktop.
Repeat eos generation for kaitai in go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild | |
package test_formats | |
import goio "io" | |
import "github.com/kaitai-io/kaitai_struct_go_runtime/kaitai" | |
type RepeatEosStruct struct { | |
Chunks []*RepeatEosStruct_Chunk | |
_io *kaitai.Stream | |
_root *RepeatEosStruct | |
_parent interface{} | |
} | |
func (this *RepeatEosStruct) Read(io *kaitai.Stream, parent interface{}, root *RepeatEosStruct) (err error) { | |
this._io = io | |
this._parent = parent | |
this._root = root | |
for { | |
tmp1 := new(RepeatEosStruct_Chunk) | |
err = tmp1.Read(this._io, this, this._root) | |
if err == goio.EOF { | |
return nil | |
} | |
if err != nil { | |
return err | |
} | |
this.Chunks = append(this.Chunks, tmp1) | |
} | |
return err | |
} | |
type RepeatEosStruct_Chunk struct { | |
Offset uint32 | |
Len uint32 | |
_io *kaitai.Stream | |
_root *RepeatEosStruct | |
_parent *RepeatEosStruct | |
} | |
func (this *RepeatEosStruct_Chunk) Read(io *kaitai.Stream, parent *RepeatEosStruct, root *RepeatEosStruct) (err error) { | |
this._io = io | |
this._parent = parent | |
this._root = root | |
tmp2, err := this._io.ReadU4le() | |
if err != nil { | |
return err | |
} | |
this.Offset = tmp2 | |
tmp3, err := this._io.ReadU4le() | |
if err != nil { | |
return err | |
} | |
this.Len = tmp3 | |
return err | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild | |
package test_formats | |
import goio "io" | |
import "github.com/kaitai-io/kaitai_struct_go_runtime/kaitai" | |
type RepeatEosU4 struct { | |
Numbers []uint32 | |
_io *kaitai.Stream | |
_root *RepeatEosU4 | |
_parent interface{} | |
} | |
func (this *RepeatEosU4) Read(io *kaitai.Stream, parent interface{}, root *RepeatEosU4) (err error) { | |
this._io = io | |
this._parent = parent | |
this._root = root | |
for { | |
tmp1, err := this._io.ReadU4le() | |
if err == goio.EOF { | |
return nil | |
} | |
if err != nil { | |
return err | |
} | |
this.Numbers = append(this.Numbers, tmp1) | |
} | |
return err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment