Skip to content

Commit

Permalink
Add reusable generic RIFF types
Browse files Browse the repository at this point in the history
There are two types of RIFF structs: with asserts (chunk and
parent_chunk_data) and without asserts (chunk_generic and
parent_chunk_data_generic). Those without asserts won't be
needed when kaitai-io/kaitai_struct#435 (comment) is resolved.
  • Loading branch information
generalmimon committed Nov 24, 2019
1 parent d0918ed commit 4b4c7dd
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
21 changes: 21 additions & 0 deletions common/riff/chunk.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
meta:
id: chunk
encoding: ASCII
endian: le
params:
- id: expected_id
type: str
seq:
- id: id_assert
type: str
size: 4
valid: expected_id
- id: len
type: u4
- id: data_slot
type: slot
size: len
- id: pad_byte
size: len % 2 # if size is odd, there is 1 padding byte
types:
slot: {} # Keeps _io for later use of same substream
17 changes: 17 additions & 0 deletions common/riff/chunk_generic.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
meta:
id: chunk_generic
encoding: ASCII
endian: le
seq:
- id: id
type: str
size: 4
- id: len
type: u4
- id: data_slot
type: slot
size: len
- id: pad_byte
size: len % 2 # if size is odd, there is 1 padding byte
types:
slot: {} # Keeps _io for later use of same substream
17 changes: 17 additions & 0 deletions common/riff/parent_chunk_data.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
meta:
id: parent_chunk_data
encoding: ASCII
endian: le
params:
- id: expected_form_type
type: str
seq:
- id: form_type_assert
type: str
size: 4
valid: expected_form_type
- id: subchunks_slot
type: slot
size-eos: true
types:
slot: {} # Keeps _io for later use of same substream
13 changes: 13 additions & 0 deletions common/riff/parent_chunk_data_generic.ksy
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
meta:
id: parent_chunk_data_generic
encoding: ASCII
endian: le
seq:
- id: form_type
type: str
size: 4
- id: subchunks_slot
type: slot
size-eos: true
types:
slot: {} # Keeps _io for later use of same substream

0 comments on commit 4b4c7dd

Please sign in to comment.