Files
godot-angle-static/util/capture
Steven Noonan a01a566c48 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>
2023-06-09 21:15:16 +00:00
..