diff options
-rw-r--r-- | cmake/piglit_glapi.cmake | 1 | ||||
-rw-r--r-- | glapi/parse_glspec.py | 36 |
2 files changed, 36 insertions, 1 deletions
diff --git a/cmake/piglit_glapi.cmake b/cmake/piglit_glapi.cmake index 368c1ca3b..899c7ee5a 100644 --- a/cmake/piglit_glapi.cmake +++ b/cmake/piglit_glapi.cmake @@ -34,6 +34,7 @@ set(piglit_glapi_inputs ${piglit_glapi_src_dir}/gl.spec ${piglit_glapi_src_dir}/enum.spec ${piglit_glapi_src_dir}/enumext.spec + ${piglit_glapi_src_dir}/GLES3/gl3.h ) add_custom_command( diff --git a/glapi/parse_glspec.py b/glapi/parse_glspec.py index c640e1085..59a799619 100644 --- a/glapi/parse_glspec.py +++ b/glapi/parse_glspec.py @@ -447,6 +447,38 @@ class Api(object): for alias in attributes['alias']: self.synonyms.add_alias(name, alias) + def read_gles_header(self, f): + category = 'GL_ES_VERSION_2_0' + for line in f: + # The GLES gl3.h has typedefs, tokens, and prototypes, + # each listed after a comment indicating whether they're + # part of 2.0 core or 3.0 core. + if re.match(r'/\* OpenGL ES 2.0 \*/', line): + category = 'GL_ES_VERSION_2_0' + elif re.match(r'/\* OpenGL ES 3.0 \*/', line): + category = 'GL_ES_VERSION_3_0' + + m = re.match(r'GL_APICALL', line) + if m: + # We do the regexp in two parts to make sure that we + # actually do catch all the GL_APICALLs. + m = re.match(r'^GL_APICALL\s*(.*)\s*GL_APIENTRY\s*gl(\w*)\s\((.*)\).*$', line) + return_type, name, args = m.groups() + + return_type = return_type.strip() + args = args.split(', ') + + if args == ['void']: + args = [] + param_names = [] + param_types = [] + for arg in args: + splitloc = max(arg.rfind(' '), arg.rfind('*')) + param_types.append(arg[:splitloc + 1]) + param_names.append(arg[splitloc + 1:]) + + self.add_function(name, return_type, param_names, param_types, category) + # Convert each line in the enumext.spec file into a key/value pair # in self.enums, mapping an enum name to a dict. For example, the # following enumext.spec input: @@ -495,5 +527,7 @@ if __name__ == '__main__': api.read_enumext_spec(f) with open(sys.argv[4]) as f: api.read_enumext_spec(f) - with open(sys.argv[5], 'w') as f: + with open(sys.argv[5]) as f: + api.read_gles_header(f) + with open(sys.argv[6], 'w') as f: f.write(api.to_json()) |