mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-22 05:30:31 +01:00
egl: Apply autopep8.
My editor does this on save, so let's just apply it to EGL's python for consistency. The only exception is that the genCommon import needs the sys.path.insert, so that part of autopep8 was reverted. Reviewed-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Adam Jackson <ajax@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33517>
This commit is contained in:
parent
34fe896715
commit
58e73e792f
3 changed files with 46 additions and 27 deletions
|
|
@ -11,11 +11,11 @@ SUFFIX = ')'
|
|||
|
||||
# These entrypoints should *not* be in the GLVND entrypoints
|
||||
GLVND_EXCLUDED_ENTRYPOINTS = [
|
||||
# EGL_KHR_debug
|
||||
'eglDebugMessageControlKHR',
|
||||
'eglQueryDebugKHR',
|
||||
'eglLabelObjectKHR',
|
||||
]
|
||||
# EGL_KHR_debug
|
||||
'eglDebugMessageControlKHR',
|
||||
'eglQueryDebugKHR',
|
||||
'eglLabelObjectKHR',
|
||||
]
|
||||
|
||||
|
||||
def check_entrypoint_sorted(entrypoints):
|
||||
|
|
@ -26,7 +26,8 @@ def check_entrypoint_sorted(entrypoints):
|
|||
if i == 0:
|
||||
continue
|
||||
if entrypoints[i - 1] > entrypoints[i]:
|
||||
print('ERROR: ' + entrypoints[i] + ' should come before ' + entrypoints[i - 1])
|
||||
print('ERROR: ' + entrypoints[i] +
|
||||
' should come before ' + entrypoints[i - 1])
|
||||
exit(1)
|
||||
|
||||
print('All good :)')
|
||||
|
|
@ -40,17 +41,20 @@ def check_glvnd_entrypoints(egl_entrypoints, glvnd_entrypoints):
|
|||
if egl_entrypoint in GLVND_EXCLUDED_ENTRYPOINTS:
|
||||
continue
|
||||
if egl_entrypoint not in glvnd_entrypoints:
|
||||
print('ERROR: ' + egl_entrypoint + ' is missing from the GLVND entrypoints (src/egl/generate/eglFunctionList.py)')
|
||||
print('ERROR: ' + egl_entrypoint +
|
||||
' is missing from the GLVND entrypoints (src/egl/generate/eglFunctionList.py)')
|
||||
success = False
|
||||
|
||||
for glvnd_entrypoint in glvnd_entrypoints:
|
||||
if glvnd_entrypoint not in egl_entrypoints:
|
||||
print('ERROR: ' + glvnd_entrypoint + ' is missing from the plain EGL entrypoints (src/egl/main/eglentrypoint.h)')
|
||||
print('ERROR: ' + glvnd_entrypoint +
|
||||
' is missing from the plain EGL entrypoints (src/egl/main/eglentrypoint.h)')
|
||||
success = False
|
||||
|
||||
for glvnd_entrypoint in GLVND_EXCLUDED_ENTRYPOINTS:
|
||||
if glvnd_entrypoint in glvnd_entrypoints:
|
||||
print('ERROR: ' + glvnd_entrypoint + ' is should *not* be in the GLVND entrypoints (src/egl/generate/eglFunctionList.py)')
|
||||
print('ERROR: ' + glvnd_entrypoint +
|
||||
' is should *not* be in the GLVND entrypoints (src/egl/generate/eglFunctionList.py)')
|
||||
success = False
|
||||
|
||||
if success:
|
||||
|
|
@ -85,5 +89,6 @@ def main():
|
|||
|
||||
check_glvnd_entrypoints(entrypoints, glvnd_entrypoints)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ method values:
|
|||
Select the vendor that owns the current context.
|
||||
"""
|
||||
|
||||
|
||||
def _eglFunc(name, method, static=None, public=False, inheader=None, prefix="dispatch_", extension=None, retval=None):
|
||||
"""
|
||||
A convenience function to define an entry in the EGL function list.
|
||||
|
|
@ -85,16 +86,17 @@ def _eglFunc(name, method, static=None, public=False, inheader=None, prefix="dis
|
|||
if inheader is None:
|
||||
inheader = (not static)
|
||||
values = {
|
||||
"method" : method,
|
||||
"prefix" : prefix,
|
||||
"extension" : extension,
|
||||
"retval" : retval,
|
||||
"static" : static,
|
||||
"public" : public,
|
||||
"inheader" : inheader,
|
||||
"method": method,
|
||||
"prefix": prefix,
|
||||
"extension": extension,
|
||||
"retval": retval,
|
||||
"static": static,
|
||||
"public": public,
|
||||
"inheader": inheader,
|
||||
}
|
||||
return (name, values)
|
||||
|
||||
|
||||
EGL_FUNCTIONS = (
|
||||
# EGL_VERSION_1_0
|
||||
_eglFunc("eglChooseConfig", "none"),
|
||||
|
|
@ -250,4 +252,3 @@ EGL_FUNCTIONS = (
|
|||
# EGL_EXT_surface_compression
|
||||
_eglFunc("eglQuerySupportedCompressionRatesEXT", "display"),
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -46,8 +46,9 @@ import genCommon
|
|||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("target", choices=("header", "source"),
|
||||
help="Whether to build the source or header file.")
|
||||
parser.add_argument("xml_files", nargs="+", help="The XML files with the EGL function lists.")
|
||||
help="Whether to build the source or header file.")
|
||||
parser.add_argument("xml_files", nargs="+",
|
||||
help="The XML files with the EGL function lists.")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
@ -68,6 +69,7 @@ def main():
|
|||
text = generateSource(functions)
|
||||
sys.stdout.write(text)
|
||||
|
||||
|
||||
def fixupEglFunc(func, eglFunc):
|
||||
result = dict(eglFunc)
|
||||
if result.get("prefix") is None:
|
||||
|
|
@ -81,7 +83,8 @@ def fixupEglFunc(func, eglFunc):
|
|||
return result
|
||||
|
||||
if result["method"] not in ("display", "device", "current"):
|
||||
raise ValueError("Invalid dispatch method %r for function %r" % (result["method"], func.name))
|
||||
raise ValueError("Invalid dispatch method %r for function %r" %
|
||||
(result["method"], func.name))
|
||||
|
||||
if func.hasReturn():
|
||||
if result.get("retval") is None:
|
||||
|
|
@ -89,6 +92,7 @@ def fixupEglFunc(func, eglFunc):
|
|||
|
||||
return result
|
||||
|
||||
|
||||
def generateHeader(functions):
|
||||
text = textwrap.dedent(r"""
|
||||
#ifndef G_EGLDISPATCH_STUBS_H
|
||||
|
|
@ -118,7 +122,8 @@ def generateHeader(functions):
|
|||
for (func, eglFunc) in functions:
|
||||
if eglFunc["inheader"]:
|
||||
text += generateGuardBegin(func, eglFunc)
|
||||
text += "{f.rt} EGLAPIENTRY {ex[prefix]}{f.name}({f.decArgs});\n".format(f=func, ex=eglFunc)
|
||||
text += "{f.rt} EGLAPIENTRY {ex[prefix]}{f.name}({f.decArgs});\n".format(
|
||||
f=func, ex=eglFunc)
|
||||
text += generateGuardEnd(func, eglFunc)
|
||||
|
||||
text += textwrap.dedent(r"""
|
||||
|
|
@ -129,6 +134,7 @@ def generateHeader(functions):
|
|||
""")
|
||||
return text
|
||||
|
||||
|
||||
def generateSource(functions):
|
||||
# First, sort the function list by name.
|
||||
text = ""
|
||||
|
|
@ -156,7 +162,8 @@ def generateSource(functions):
|
|||
for (func, eglFunc) in functions:
|
||||
text += generateGuardBegin(func, eglFunc)
|
||||
if eglFunc["method"] != "none":
|
||||
text += " (__eglMustCastToProperFunctionPointerType) " + eglFunc.get("prefix", "") + func.name + ",\n"
|
||||
text += " (__eglMustCastToProperFunctionPointerType) " + \
|
||||
eglFunc.get("prefix", "") + func.name + ",\n"
|
||||
else:
|
||||
text += " NULL, // " + func.name + "\n"
|
||||
text += generateGuardEnd(func, eglFunc)
|
||||
|
|
@ -165,6 +172,7 @@ def generateSource(functions):
|
|||
|
||||
return text
|
||||
|
||||
|
||||
def generateGuardBegin(func, eglFunc):
|
||||
ext = eglFunc.get("extension")
|
||||
if ext is not None:
|
||||
|
|
@ -172,12 +180,14 @@ def generateGuardBegin(func, eglFunc):
|
|||
else:
|
||||
return ""
|
||||
|
||||
|
||||
def generateGuardEnd(func, eglFunc):
|
||||
if eglFunc.get("extension") is not None:
|
||||
return "#endif\n"
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
def generateDispatchFunc(func, eglFunc):
|
||||
text = ""
|
||||
|
||||
|
|
@ -186,7 +196,7 @@ def generateDispatchFunc(func, eglFunc):
|
|||
elif eglFunc.get("public"):
|
||||
text += "PUBLIC "
|
||||
text += textwrap.dedent(
|
||||
r"""
|
||||
r"""
|
||||
{f.rt} EGLAPIENTRY {ef[prefix]}{f.name}({f.decArgs})
|
||||
{{
|
||||
typedef {f.rt} EGLAPIENTRY (* _pfn_{f.name})({f.decArgs});
|
||||
|
|
@ -197,7 +207,8 @@ def generateDispatchFunc(func, eglFunc):
|
|||
|
||||
text += " _pfn_{f.name} _ptr_{f.name} = (_pfn_{f.name}) ".format(f=func)
|
||||
if eglFunc["method"] == "current":
|
||||
text += "__eglDispatchFetchByCurrent(__EGL_DISPATCH_{f.name});\n".format(f=func)
|
||||
text += "__eglDispatchFetchByCurrent(__EGL_DISPATCH_{f.name});\n".format(
|
||||
f=func)
|
||||
|
||||
elif eglFunc["method"] in ("display", "device"):
|
||||
if eglFunc["method"] == "display":
|
||||
|
|
@ -214,7 +225,8 @@ def generateDispatchFunc(func, eglFunc):
|
|||
lookupArg = arg.name
|
||||
break
|
||||
if lookupArg is None:
|
||||
raise ValueError("Can't find %s argument for function %s" % (lookupType, func.name,))
|
||||
raise ValueError("Can't find %s argument for function %s" %
|
||||
(lookupType, func.name,))
|
||||
|
||||
text += "{lookupFunc}({lookupArg}, __EGL_DISPATCH_{f.name});\n".format(
|
||||
f=func, lookupFunc=lookupFunc, lookupArg=lookupArg)
|
||||
|
|
@ -233,6 +245,7 @@ def generateDispatchFunc(func, eglFunc):
|
|||
text += "}\n"
|
||||
return text
|
||||
|
||||
|
||||
def getDefaultReturnValue(typename):
|
||||
if typename.endswith("*"):
|
||||
return "NULL"
|
||||
|
|
@ -243,10 +256,10 @@ def getDefaultReturnValue(typename):
|
|||
elif typename == "EGLSurface":
|
||||
return "EGL_NO_SURFACE"
|
||||
elif typename == "EGLBoolean":
|
||||
return "EGL_FALSE";
|
||||
return "EGL_FALSE"
|
||||
|
||||
return "0"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue