From: José Fonseca Date: Wed, 4 May 2011 09:15:52 +0000 (+0100) Subject: Cleanup apigen dir. X-Git-Tag: 2.0_alpha^2~963 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e1f32116d11be0133f2d0db830760355b29f61db;p=tools%2Fapitrace.git Cleanup apigen dir. --- diff --git a/apigen/.gitignore b/apigen/.gitignore index 5ef2e39..1dbc0cf 100644 --- a/apigen/.gitignore +++ b/apigen/.gitignore @@ -2,5 +2,6 @@ *.tm *.txt *api.py -glsize.hpp +glparams.py +wglenum.py !Makefile diff --git a/apigen/Makefile b/apigen/Makefile index 475c635..d57d394 100644 --- a/apigen/Makefile +++ b/apigen/Makefile @@ -1,7 +1,8 @@ all: \ download \ - glapi.py glxapi.py wglapi.py + glapi.py glxapi.py wglapi.py \ + glparams.py wglenum.py download: \ enum.spec \ @@ -34,4 +35,11 @@ glxapi.py: glspec.py glx.tm glx.spec glxext.spec wglapi.py: glspec.py wgl.tm wgl.spec wglext.spec python glspec.py wgl wgl.tm wgl.spec wglext.spec > $@ +glparams.py: glparams.sed enum.spec sort.sh + sed -n -f glparams.sed enum.spec | ./sort.sh > $@ + +wglenum.py: wglenum.sh wglenumext.spec + ./wglenum.sh wglenumext.spec > $@ + + .PRECIOUS: %.spec %.tm diff --git a/apigen/README b/apigen/README new file mode 100644 index 0000000..85a1c39 --- /dev/null +++ b/apigen/README @@ -0,0 +1,12 @@ +This directory contains several helper scripts that facilitate the generation +of the API descriptions from specs. + +The specs are not expressive enough, which is why we can just code generate +everything from them. + +The typical procedure is to run + + make -B + +and then manually crossport new functions / enums to the files in the top dir +via a side-by-side diff tool, such as gvimdiff. diff --git a/apigen/gl_trace.py b/apigen/gl_trace.py deleted file mode 100755 index 182b395..0000000 --- a/apigen/gl_trace.py +++ /dev/null @@ -1,124 +0,0 @@ -#!/usr/bin/env python - -# Copyright 2008 VMware, Inc. -# Copyright 2004 IBM Corporation -# All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# on the rights to use, copy, modify, merge, publish, distribute, sub -# license, and/or sell copies of the Software, and to permit persons to whom -# the Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice (including the next -# paragraph) shall be included in all copies or substantial portions of the -# Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. - -import getopt -import os.path -import sys - -glapi_path = os.path.join(os.environ['MESA'], 'src/mapi/glapi/gen') -sys.path.insert(0, glapi_path) - -import gl_XML -import license - -type_map = { - 'void': 'Void', - 'int': 'Int', - 'float': 'Float', -} - -def parse_type(tokens, count = 0): - if count: - if tokens[-1] == '**': - return 'Array(Pointer(%s), "%s")' % (parse_type(tokens[:-1]), count) - if tokens[-1] == '*': - return 'Array(%s, "%s")' % (parse_type(tokens[:-1]), count) - else: - if tokens[-1] == '**': - return 'Pointer(Pointer(%s))' % parse_type(tokens[:-1]) - if tokens[-1] == '*': - return 'Pointer(%s)' % parse_type(tokens[:-1]) - if tokens[-1] == 'const': - return 'Const(%s)' % parse_type(tokens[:-1]) - if tokens[0] == 'const': - return 'Const(%s)' % parse_type(tokens[1:]) - assert len(tokens) == 1 - base = tokens[0] - return type_map.get(base, base) - -def get_type(t, count = 0): - tokens = t.split() - - return parse_type(tokens, count) - - -class PrintGlTable(gl_XML.gl_print_base): - def __init__(self): - gl_XML.gl_print_base.__init__(self) - - #self.header_tag = '_GLAPI_TABLE_H_' - self.name = "gl_trace.py (from Mesa)" - self.license = license.bsd_license_template % ( \ -"""Copyright (C) 1999-2003 Brian Paul All Rights Reserved. -(C) Copyright IBM Corporation 2004""", "BRIAN PAUL, IBM") - return - - def printBody(self, api): - abi = [ "1.0", "1.1", "1.2", "1.5", "GL_ARB_multitexture" ] - for pass_ in range(2): - for f in api.functionIterateByOffset(): - for name in f.entry_points: - [category, num] = api.get_category_for_name( name ) - args = [] - for p in f.parameters: - type = get_type(p.type_string(), p.count) - args.append('(%s, "%s")' % (type, p.name)) - arg_string = '[' + ', '.join(args) + ']' - if category in abi: - if pass_ == 0: - print ' GlFunction(%s, "gl%s", %s),' % (get_type(f.return_type), name, arg_string) - else: - if pass_ == 1: - print ' GlFunction(%s, "gl%s", %s),' % (get_type(f.return_type), name, arg_string) - - def printRealHeader(self): - return - - def printRealFooter(self): - print ']' - - -def show_usage(): - print "Usage: %s [-f input_file_name]" % sys.argv[0] - sys.exit(1) - - -if __name__ == '__main__': - file_name = os.path.join(glapi_path, "gl_API.xml") - - try: - (args, trail) = getopt.getopt(sys.argv[1:], "f:") - except Exception,e: - show_usage() - - for (arg,val) in args: - if arg == "-f": - file_name = val - - printer = PrintGlTable() - - api = gl_XML.parse_GL_API( file_name ) - - printer.Print( api ) diff --git a/apigen/glenumsize.sed b/apigen/glenumsize.sed deleted file mode 100644 index da7cbe2..0000000 --- a/apigen/glenumsize.sed +++ /dev/null @@ -1,2 +0,0 @@ -s/^\s\+\(\w\+\)\s*=\s*\(0x\w\+\)\s\+#\s\+\([0-9]\+\)\s\+\([IF]\)\s*\(#.*\)\?$/ (\4,\t\3,\t"GL_\1"),\t# \2/p -s/^\s\+\(\w\+\)\s*=\s*\(0x\w\+\)\s*\(#.*\)\?$/ (X,\t1,\t"GL_\1"),\t# \2/p diff --git a/apigen/glparams.sed b/apigen/glparams.sed new file mode 100644 index 0000000..8afde64 --- /dev/null +++ b/apigen/glparams.sed @@ -0,0 +1,2 @@ +s/^\s\+\(\w\+\)\s*=\s*\(0x\w\+\)\s\+#\s\+\([0-9]\+\)\s\+\([IF]\)\s*\(#.*\)\?$/ ("glGet",\t\4,\t\3,\t"GL_\1"),\t# \2/p +s/^\s\+\(\w\+\)\s*=\s*\(0x\w\+\)\s*\(#.*\)\?$/ ("",\tX,\t1,\t"GL_\1"),\t# \2/p