More enums, and conditional evaluation

master
Valentin Ochs 2020-12-30 07:47:22 +01:00
parent c2b7f7d129
commit 50accfafa1
1 changed files with 25 additions and 12 deletions

View File

@ -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'