<div dir="ltr">On 5 June 2013 16:14, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net" target="_blank">eric@anholt.net</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This gets us piglit-dispatch support for all the core functions of<br>
GLES2/3.<br>
---<br>
cmake/piglit_glapi.cmake | 1 +<br>
glapi/parse_glspec.py | 41 ++++++++++++++++++++++++++++++++++++++++-<br>
2 files changed, 41 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/cmake/piglit_glapi.cmake b/cmake/piglit_glapi.cmake<br>
index 368c1ca..899c7ee 100644<br>
--- a/cmake/piglit_glapi.cmake<br>
+++ b/cmake/piglit_glapi.cmake<br>
@@ -34,6 +34,7 @@ set(piglit_glapi_inputs<br>
${piglit_glapi_src_dir}/gl.spec<br>
${piglit_glapi_src_dir}/enum.spec<br>
${piglit_glapi_src_dir}/enumext.spec<br>
+ ${piglit_glapi_src_dir}/GLES3/gl3.h<br>
)<br>
<br>
add_custom_command(<br>
diff --git a/glapi/parse_glspec.py b/glapi/parse_glspec.py<br>
index ef6143c..163de70 100644<br>
--- a/glapi/parse_glspec.py<br>
+++ b/glapi/parse_glspec.py<br>
@@ -447,6 +447,43 @@ class Api(object):<br>
for alias in attributes['alias']:<br>
self.synonyms.add_alias(name, alias)<br>
<br>
+ def read_gles_header(self, f):<br>
+ category = 'GL_ES_VERSION_2_0'<br>
+ for line in f:<br>
+ # The GLES gl3.h has typedefs, tokens, and prototypes,<br>
+ # each listed after a comment indicating whether they're<br>
+ # part of 2.0 core or 3.0 core.<br>
+ if re.match(r'/\* OpenGL ES 2.0 \*/', line):<br>
+ category = 'GL_ES_VERSION_2_0'<br>
+ elif re.match(r'/\* OpenGL ES 3.0 \*/', line):<br>
+ category = 'GL_ES_VERSION_3_0'<br>
+<br>
+ m = re.match(r'GL_APICALL', line)<br>
+ if m:<br>
+ # We do the regexp in two parts to make sure that we<br>
+ # actually do catch all the GL_APICALLs.<br>
+ m = re.match(r'^GL_APICALL\s*(.*)\s*GL_APIENTRY\s*gl(\w*)\s\((.*)\).*$', line)<br>
+ return_type, name, args = m.groups()<br>
+<br>
+ return_type = return_type.strip()<br>
+ args = args.split(', ')<br>
+<br>
+ if args[0] == 'void':<br>
+ args.remove('void')<br></blockquote><div><br></div><div>How about:<br><br>if args == ['void']:<br></div><div> args = []<br><br></div><div>Just so that it doesn't look like this is supposed to handle foo(void, int x) or any other such nonsense.<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ param_names = [None] * len(args)<br>
+ param_types = [None] * len(args)<br>
+ i = 0<br>
+ for arg in args:<br>
+ splitloc = max(arg.rfind(' '), arg.rfind('*'))<br>
+ param_type = arg[:splitloc + 1]<br>
+ param_name = arg[splitloc + 1:]<br>
+<br>
+ param_types[i] = param_type<br>
+ param_names[i] = param_name<br>
+ i += 1<br></blockquote><div><br></div><div>Slightly terser (and more conventional Python, IMHO) would be:<br><br></div><div>param_names = []<br></div><div>param_types = []<br></div><div>for arg in args:<br>
</div><div> splitloc = max(arg.rfind(' '), arg.find('*'))<br></div><div> param_types.append(arg[:splitloc + 1])<br></div><div> param_names.append(arg[splitloc + 1:])<br><br><br></div><div>I'm nit-picking, though. With or without these two changes, the patch is:<br>
<br></div><div>Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+ self.add_function(name, return_type, param_names, param_types, category)<br>
+<br>
# Convert each line in the enumext.spec file into a key/value pair<br>
# in self.enums, mapping an enum name to a dict. For example, the<br>
# following enumext.spec input:<br>
@@ -495,5 +532,7 @@ if __name__ == '__main__':<br>
api.read_enumext_spec(f)<br>
with open(sys.argv[4]) as f:<br>
api.read_enumext_spec(f)<br>
- with open(sys.argv[5], 'w') as f:<br>
+ with open(sys.argv[5]) as f:<br>
+ api.read_gles_header(f)<br>
+ with open(sys.argv[6], 'w') as f:<br>
f.write(api.to_json())<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.8.3.rc0<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>