Hash :
a01a566c
Author :
Date :
2023-06-09T00:31:06
extension xmls: fix incorrect use of <ptype> tags
I was having trouble using some GL/EGL loader generators because of some
errors in the XML definitions for ANGLE.
The first major problem is the content of the <ptype> tags. Let's refer
to the Khronos registry XML schema (which is annoyingly a PDF rather
than an xsd that we can test against, though I don't know if an xsd
would catch this anyway):
https://raw.githubusercontent.com/KhronosGroup/OpenGL-Registry/master/xml/readme.pdf
In section 12.4.2, "Contents of <param> tags" it states:
The <ptype> tag is optional, and contains text which is a valid type
name found in <type> tag, and indicates that this type must be
previously defined for the definition of the command to succeed.
Builtin C types, and any derived types which are expected to be
found in other header files, should not be wrapped in <ptype> tags
Note that the above is repeated for the contents of <proto> tags as
well.
The extension XML files currently have a bunch of <ptype> tags which
don't meet the expectations described above. The correct transformation
for them would be, for example:
<ptype>GLfloat *</ptype> -> <ptype>GLfloat</ptype> *
<ptype>void *</ptype> -> void *
<ptype>const char *</ptype> -> const char *
<ptype>EGLAttrib *</ptype> -> <ptype>EGLAttrib</ptype> *
The next issue is that some tags have some typos, such as "<pytpe>"
instead of "<ptype>". (Now *that* is something an .xsd would catch...)
The last issue is the use of the typename "GLvoid" which is not as
serious a problem. It is still defined in Khronos' gl.xml <types> block,
but Khronos no longer uses it in their XML registries. The comment for
the "GLvoid" type in their <types> block states:
<type comment="Not an actual GL type, though used in headers in the past">typedef void <name>GLvoid</name>;</type>
So we might as well replace those with just plain "void".
Anyway, long story short: to apply these transformations, I used Perl
regular expressions, and applied these expressions in order:
- Fix the tag misspellings:
s#<(/?)pytpe>#<\1ptype>#g
- Move the const qualifiers (if present) and pointer asterisk(s) (if
any) outside the <ptype> tag itself:
s#<ptype>(const )?([A-Za-z0-9]+)[ ]?(\*\*?)</ptype> #\1<ptype>\2</ptype> \3#g
- Replace "GLvoid", "char", and "void" inside ptype tags to normal
C types outside tags:
s#<ptype>(GLvoid|void|char)</ptype>#\1#g
Bug: angleproject:8190
Change-Id: Ib0bea79fecb7e714910b6e92124bb9f52994d0fb
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4603709
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
{
"scripts/egl_angle_ext.xml":
"7ae2be7840b4dbf9db875688847606d4",
"scripts/gen_interpreter_utils.py":
"10ba16ee78604763fc883525dd275de8",
"scripts/gl_angle_ext.xml":
"49a0bf469d6f44c532098ef3a9fd087f",
"scripts/registry_xml.py":
"2175daaec34d2e6fe763d0c3efa93dea",
"third_party/EGL-Registry/src/api/egl.xml":
"2056d54ea07156f1988ca1366bdee21a",
"third_party/OpenCL-Docs/src/xml/cl.xml":
"6d0bf09e20a8f8c3ae440d79eda08bf9",
"third_party/OpenGL-Registry/src/xml/gl.xml":
"49f0afe5cac23951c74420e457b0cb23",
"third_party/OpenGL-Registry/src/xml/glx.xml":
"94f3eee4b076801d117804eb466714b7",
"third_party/OpenGL-Registry/src/xml/wgl.xml":
"eae784bf4d1b983a42af5671b140b7c4",
"util/capture/trace_fixture.h":
"3333b7a1f00b0721f3ca463bc8c577f8",
"util/capture/trace_interpreter_autogen.cpp":
"d88954571f2d6283195f32953f99405c"
}