68 lines
2.5 KiB
Diff
68 lines
2.5 KiB
Diff
|
Index: mesa-24.3.0-rc1/src/nouveau/headers/class_parser.py
|
||
|
===================================================================
|
||
|
--- mesa-24.3.0-rc1.orig/src/nouveau/headers/class_parser.py
|
||
|
+++ mesa-24.3.0-rc1/src/nouveau/headers/class_parser.py
|
||
|
@@ -11,6 +11,16 @@ import subprocess
|
||
|
|
||
|
from mako.template import Template
|
||
|
|
||
|
+def removeprefix(s, prefix):
|
||
|
+ if s.startswith(prefix):
|
||
|
+ return s[len(prefix):]
|
||
|
+ return s
|
||
|
+
|
||
|
+def removesuffix(s, suffix):
|
||
|
+ if s.endswith(suffix):
|
||
|
+ return s[:-len(suffix)]
|
||
|
+ return s
|
||
|
+
|
||
|
METHOD_ARRAY_SIZES = {
|
||
|
'BIND_GROUP_CONSTANT_BUFFER' : 16,
|
||
|
'CALL_MME_DATA' : 256,
|
||
|
@@ -425,7 +435,7 @@ def parse_header(nvcl, f):
|
||
|
if ":" in list[2]:
|
||
|
state = 1
|
||
|
elif teststr in list[1]:
|
||
|
- curmthd.field_defs[curfield][list[1].removeprefix(teststr)] = list[2]
|
||
|
+ curmthd.field_defs[curfield][removeprefix(list[1], teststr)] = list[2]
|
||
|
else:
|
||
|
state = 1
|
||
|
|
||
|
@@ -435,7 +445,7 @@ def parse_header(nvcl, f):
|
||
|
if ("0x" in list[2]):
|
||
|
state = 1
|
||
|
else:
|
||
|
- field = list[1].removeprefix(teststr)
|
||
|
+ field = removeprefix(list[1], teststr)
|
||
|
bitfield = list[2].split(":")
|
||
|
curmthd.field_name_start[field] = bitfield[1]
|
||
|
curmthd.field_name_end[field] = bitfield[0]
|
||
|
@@ -456,13 +466,13 @@ def parse_header(nvcl, f):
|
||
|
is_array = 0
|
||
|
if (':' in list[2]):
|
||
|
continue
|
||
|
- name = list[1].removeprefix(teststr)
|
||
|
+ name = removeprefix(list[1], teststr)
|
||
|
if name.endswith("(i)"):
|
||
|
is_array = 1
|
||
|
- name = name.removesuffix("(i)")
|
||
|
+ name = removesuffix(name, "(i)")
|
||
|
if name.endswith("(j)"):
|
||
|
is_array = 1
|
||
|
- name = name.removesuffix("(j)")
|
||
|
+ name = removesuffix(name, "(j)")
|
||
|
x = method()
|
||
|
x.name = name
|
||
|
x.addr = list[2]
|
||
|
@@ -552,8 +562,8 @@ def main():
|
||
|
|
||
|
clheader = os.path.basename(args.in_h)
|
||
|
nvcl = clheader
|
||
|
- nvcl = nvcl.removeprefix("cl")
|
||
|
- nvcl = nvcl.removesuffix(".h")
|
||
|
+ nvcl = removeprefix(nvcl, "cl")
|
||
|
+ nvcl = removesuffix(nvcl, ".h")
|
||
|
nvcl = nvcl.upper()
|
||
|
nvcl = "NV" + nvcl
|
||
|
|