More enums, and conditional evaluation
This commit is contained in:
parent
c2b7f7d129
commit
50accfafa1
37
08_enums.ksy
37
08_enums.ksy
|
@ -5,23 +5,28 @@ meta:
|
||||||
endian: le
|
endian: le
|
||||||
seq:
|
seq:
|
||||||
- id: magic
|
- id: magic
|
||||||
contents: "RIFF"
|
# Could assert using contents here, but
|
||||||
size: 4
|
# just make sections conditional later
|
||||||
|
#contents: "RIFF"
|
||||||
|
type: u4be
|
||||||
|
enum: fourcc
|
||||||
- id: size
|
- id: size
|
||||||
type: u4
|
type: u4
|
||||||
- id: wave_str
|
- id: wave_str
|
||||||
contents: "WAVE"
|
#contents: "WAVE"
|
||||||
size: 4
|
type: u4be
|
||||||
|
enum: fourcc
|
||||||
- id: sections
|
- id: sections
|
||||||
type: section
|
type: section
|
||||||
repeat: eos
|
repeat: eos
|
||||||
|
if: 'magic == fourcc::riff and wave_str == fourcc::wave'
|
||||||
instances: {}
|
instances: {}
|
||||||
types:
|
types:
|
||||||
section:
|
section:
|
||||||
seq:
|
seq:
|
||||||
- id: name
|
- id: name
|
||||||
type: str
|
type: u4be # Big endian!
|
||||||
size: 4
|
enum: fourcc
|
||||||
- id: size
|
- id: size
|
||||||
type: u4
|
type: u4
|
||||||
- id: content
|
- id: content
|
||||||
|
@ -29,11 +34,11 @@ types:
|
||||||
type:
|
type:
|
||||||
switch-on: name
|
switch-on: name
|
||||||
cases:
|
cases:
|
||||||
'"fmt "': fmt
|
'fourcc::fmt': fmt
|
||||||
'"data"': data
|
'fourcc::data': data
|
||||||
'"fact"': fact
|
'fourcc::fact': fact
|
||||||
'"PEAK"': peak
|
'fourcc::peak': peak
|
||||||
'"LIST"': list
|
'fourcc::list': list
|
||||||
fmt:
|
fmt:
|
||||||
seq:
|
seq:
|
||||||
- id: type
|
- id: type
|
||||||
|
@ -56,7 +61,7 @@ types:
|
||||||
type:
|
type:
|
||||||
switch-on: _root.sections[0].name
|
switch-on: _root.sections[0].name
|
||||||
cases:
|
cases:
|
||||||
'"fmt "': sample(_root.sections[0].content.as<fmt>.type, _root.sections[0].content.as<fmt>.bits_per_unit)
|
'fourcc::fmt': sample(_root.sections[0].content.as<fmt>.type, _root.sections[0].content.as<fmt>.bits_per_unit)
|
||||||
_: u1
|
_: u1
|
||||||
repeat: eos
|
repeat: eos
|
||||||
types:
|
types:
|
||||||
|
@ -129,6 +134,14 @@ types:
|
||||||
type: strz
|
type: strz
|
||||||
size: size
|
size: size
|
||||||
enums:
|
enums:
|
||||||
|
fourcc:
|
||||||
|
0x52494646: 'riff'
|
||||||
|
0x57415645: 'wave'
|
||||||
|
0x666d7420: 'fmt'
|
||||||
|
0x66616374: 'fact'
|
||||||
|
0x5045414b: 'peak'
|
||||||
|
0x64617461: 'data'
|
||||||
|
0x4c495354: 'list'
|
||||||
encoding_type_enum:
|
encoding_type_enum:
|
||||||
1: 'int'
|
1: 'int'
|
||||||
3: 'float'
|
3: 'float'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user