kaitai_struct
kaitai_struct copied to clipboard
GO: Serialization
Following up #27 #1060
documented in https://doc.kaitai.io/serialization.html
branches:
- https://github.com/kaitai-io/kaitai_struct_go_runtime/pull/28
- https://github.com/kaitai-io/kaitai_struct_compiler/pull/261
- base on https://github.com/kaitai-io/kaitai_struct_compiler/tree/serialization
- https://github.com/kaitai-io/kaitai_struct_tests/pull/101
- base on https://github.com/kaitai-io/kaitai_struct_tests/tree/serialization
kaitai_struct_go_runtime:
- [x] add more function for compiler, make go translator like other language.
- [x] if case
- [x] err resolve
- [x] add function to support writer
kaitai_struct_compiler:
- [x] rewrite go translator supoprt writer
the changes we do:
- kaitai_struct_go_runtime
- delete original reader and writer, and combined them into a new struct -> stream (like python and java's runtime)
- for go, add a new rws(read, write, seek) buffer struct
- for terminated string and bytes, add a new struct to describe them(util.go)
- kaitai_stricuct_compiler
- splite common reader and common write into go reader and go writer (also works well for any other language)
- rewrite go translator to support writer
- complete functions in go compiler
- some type conversions are fixed(support go's interface{})
- clean up unuseful code generate
now we can use the compiler to generate go files which support serialize and unserialize
for terminated string and bytes, add a new struct to describe them
This change is used to calc length when write. We add this.SizeOf()
to calc length of struct.