From db93090ffc36acfeb4c70617712378b9e09cd434 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Sun, 6 Feb 2022 15:02:26 -0500 Subject: [PATCH] asahi: Allow GenXML to be used in C++ C++ requires explicit casts from integers to enums. Fixes errors like the following when trying to use Asahi GenXML from a GTest unit test. src/asahi/lib/agx_pack.h:554:23: error: assigning to 'enum agx_channels' from incompatible type 'uint64_t' (aka 'unsigned long long') values->channels = __gen_unpack_uint(cl, 0, 6); Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/lib/gen_pack.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/asahi/lib/gen_pack.py b/src/asahi/lib/gen_pack.py index a803147..1491994 100644 --- a/src/asahi/lib/gen_pack.py +++ b/src/asahi/lib/gen_pack.py @@ -511,6 +511,9 @@ class Group(object): if field.modifier[0] == "log2": prefix = "1 << " + if field.type in self.parser.enums: + prefix = f"(enum {enum_name(field.type)}) {prefix}" + decoded = '{}{}({}){}'.format(prefix, convert, ', '.join(args), suffix) print(' values->{} = {};'.format(fieldref.path, decoded)) -- 2.7.4