From 7547e7993cc4c75569d8ff19755c893ce1036825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zoran=20Bo=C5=A1njak?= Date: Wed, 3 Aug 2022 12:53:00 +0200 Subject: [PATCH] asterix: asterix-specs converter fix Some new asterix editions contain nested 'Group' item inside 'Extended'. In such case, a 'Group' item is processed like regular 'Element'. Fixes #18238 --- tools/asterix/update-specs.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/asterix/update-specs.py b/tools/asterix/update-specs.py index 49b0391959..62ea8445b6 100755 --- a/tools/asterix/update-specs.py +++ b/tools/asterix/update-specs.py @@ -352,6 +352,20 @@ def generate_group(item, variation=None): def is_generated(item): return item.get('is_generated') is not None +def ungroup(item): + """Convert group of items of known size to element""" + n = sum([get_bit_size(i) for i in item['variation']['items']]) + result = copy(item) + result['variation'] = { + 'rule': { + 'content': {'type': 'Raw'}, + 'type': 'ContextFree', + }, + 'size': n, + 'type': 'Element', + } + return result + def part1(ctx, get_ref, catalogue): """Generate components in order - static gint hf_... @@ -452,12 +466,19 @@ def part1(ctx, get_ref, catalogue): description = get_description(item) tell_pr(' {} &hf_{}, {} "{}", "asterix.{}", FT_NONE, BASE_NONE, NULL, 0x00, NULL, HFILL {} {},'.format('{', ref, '{', description, ref, '}', '}')) tell('static gint hf_{} = -1;'.format(ref)) + + items = [] for i in variation['items']: + if i.get('variation') is not None: + if i['variation']['type'] == 'Group': + i = ungroup(i) + items.append(i) + + for i in items: handle_item(path, i) tell('static const FieldPart *I{}_PARTS[] = {}'.format(ref,'{')) chunks = chain(repeat(n1,1), repeat(n2)) - items = variation['items'] # iterate over items, reinsert FX bits while True: bit_size = next(chunks)