Skip to content

Instantly share code, notes, and snippets.

@cugu
Created April 16, 2018 18:15
Show Gist options
  • Save cugu/8a724fbd91f4a23d6189be7c75c9d4a3 to your computer and use it in GitHub Desktop.
Save cugu/8a724fbd91f4a23d6189be7c75c9d4a3 to your computer and use it in GitHub Desktop.
// This is a generated file! Please edit source .ksy file and use kaitai-struct-compiler to rebuild
import "github.com/kaitai-io/kaitai_struct_go_runtime/kaitai"
type SwitchManualInt struct {
Opcodes []*SwitchManualInt_Opcode
_io *kaitai.Stream
_root *SwitchManualInt
_parent interface{}
}
func (this *SwitchManualInt) Read(io *kaitai.Stream, parent interface{}, root *SwitchManualInt) (err error) {
this._io = io
this._parent = parent
this._root = root
for !this._io.EOF() {
tmp1 := new(SwitchManualInt_Opcode)
err = tmp1.Read(this._io, this, this._root)
if err != nil {
return err
}
this.Opcodes = append(this.Opcodes, tmp1)
}
return err
}
type SwitchManualInt_Opcode struct {
Code uint8
Body *kaitai.Stream
_io *kaitai.Stream
_root *SwitchManualInt
_parent *SwitchManualInt
}
func (this *SwitchManualInt_Opcode) Read(io *kaitai.Stream, parent *SwitchManualInt, root *SwitchManualInt) (err error) {
this._io = io
this._parent = parent
this._root = root
tmp2, err := this._io.ReadU1()
if err != nil {
return err
}
this.Code = tmp2
switch this.Code {
case 73:
tmp3 := new(SwitchManualInt_Opcode_Intval)
err = tmp3.Read(this._io, this, this._root)
if err != nil {
return err
}
this.Body = tmp3
case 83:
tmp4 := new(SwitchManualInt_Opcode_Strval)
err = tmp4.Read(this._io, this, this._root)
if err != nil {
return err
}
this.Body = tmp4
}
return err
}
type SwitchManualInt_Opcode_Intval struct {
Value uint8
_io *kaitai.Stream
_root *SwitchManualInt
_parent interface{}
}
func (this *SwitchManualInt_Opcode_Intval) Read(io *kaitai.Stream, parent interface{}, root *SwitchManualInt) (err error) {
this._io = io
this._parent = parent
this._root = root
tmp4, err := this._io.ReadU1()
if err != nil {
return err
}
this.Value = tmp4
return err
}
type SwitchManualInt_Opcode_Strval struct {
Value string
_io *kaitai.Stream
_root *SwitchManualInt
_parent interface{}
}
func (this *SwitchManualInt_Opcode_Strval) Read(io *kaitai.Stream, parent interface{}, root *SwitchManualInt) (err error) {
this._io = io
this._parent = parent
this._root = root
tmp5, err := this._io.ReadBytesTerm(0, false, true, true)
if err != nil {
return err
}
this.Value = string(tmp5)
return err
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment