From 7c521e9968e4df3e702d6bd20f384afa3bc47111 Mon Sep 17 00:00:00 2001 From: James Park Date: Thu, 26 Nov 2020 20:43:29 -0800 Subject: [PATCH] amd: Work around MSVC limit for string literals MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Marek Olšák Part-of: --- src/amd/common/sid_tables.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/amd/common/sid_tables.py b/src/amd/common/sid_tables.py index a0cb5b2d832..6fc2ad01cef 100644 --- a/src/amd/common/sid_tables.py +++ b/src/amd/common/sid_tables.py @@ -40,6 +40,10 @@ sys.path.append(AMD_REGISTERS) from regdb import Object, RegisterDatabase +def string_to_chars(string): + return "'" + "', '".join(string) + "', '\\0'," + + class StringTable: """ A class for collecting multiple strings in a single larger string that is @@ -70,13 +74,14 @@ class StringTable: to filp. """ fragments = [ - '"%s\\0" /* %s */' % ( + '%s /* %s (%s) */' % ( + string_to_chars(te[0].encode('unicode_escape').decode()), te[0].encode('unicode_escape').decode(), ', '.join(str(idx) for idx in sorted(te[2])) ) for te in self.table ] - filp.write('%sconst char %s[] =\n%s;\n' % ( + filp.write('%sconst char %s[] = {\n%s\n};\n' % ( 'static ' if static else '', name, '\n'.join('\t' + fragment for fragment in fragments)