From ac7c37d7b9a42289bf221934c2e474025adf8cf4 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 15 Jun 2010 08:50:33 +0000 Subject: [PATCH] Consolidate genwrap.py and genenum.py into generate.py Add the temp directory to svn:ignore --- Makefile | 7 +- genenum.py | 52 -------------- genwrap.py => generate.py | 143 +++++++++++++++++++++++++++++--------- gl.files => gl.api | 2 + glx.files => glx.api | 2 + source/enums.table.t | 8 +++ 6 files changed, 124 insertions(+), 90 deletions(-) delete mode 100755 genenum.py rename genwrap.py => generate.py (74%) rename gl.files => gl.api (75%) rename glx.files => glx.api (86%) create mode 100644 source/enums.table.t diff --git a/Makefile b/Makefile index 41d812d..c1860bd 100644 --- a/Makefile +++ b/Makefile @@ -73,11 +73,8 @@ temp/.created: mkdir -p temp touch $@ -gensrc/%: source/%.t gensrc/.created genwrap.py gl.files gl.tm gl.io gl.spec glx.files glx.tm glx.io glx.spec glxext.spec - python ./genwrap.py $< gl.files glx.files >$@ - -gensrc/enums.table: gensrc/.created enum.spec glxenum.spec genenum.py - python ./genenum.py enum.spec=GL_ glxenum.spec=GLX_ >$@ +gensrc/%: source/%.t gensrc/.created generate.py gl.api gl.tm gl.io gl.spec glx.api glx.tm glx.io glx.spec glxext.spec + python ./generate.py $< gl.api glx.api >$@ gensrc/.created: mkdir -p gensrc diff --git a/genenum.py b/genenum.py deleted file mode 100755 index c41d37a..0000000 --- a/genenum.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/python -# $Id$ - -import sys - -enums = [] - -cur_categ = None -for fn in sys.argv[1:]: - prefix = "GL_" - if '=' in fn: - fn, prefix = fn.split('=', 1) - for line in open(fn): - line = line.strip() - if not line or line[0]=='#': - continue - elif line[-1]==':': - parts = line[:-1].split() - if parts[1]=="enum": - cur_categ = parts[0] - elif cur_categ: - parts = line.split() - if parts[0]=="use": - enums.append([None, cur_categ, prefix+parts[2]]) - elif parts[1]=="=": - try: - enums.append([int(parts[2], 0), cur_categ, prefix+parts[0]]) - except ValueError, e: - sys.stderr.write("Syntax error in %s: %s\n"%(fn, e)) - -for e in enums: - if e[0] is None: - for n in enums: - if n[2]==e[2] and n[0] is not None: - e[0] = n[0] - if e[0] is None: - sys.stderr.write("Could not find value for enum reference %s in category %s\n"%(e[2], e[1])) - -enums.sort(lambda x, y: cmp(x[0], y[0])*2+cmp(x[1], y[1])) - -'''categs = set([e[2] for e in enums]) -for c in categs: - print c, reduce(lambda x, y: x^y, [ord(c[i])*(1<=0: continue @@ -334,21 +391,41 @@ def read_spec(fn, prefix): pnames = [] cur_func = Function(prefix+line[:paren], pnames) funcs.append(cur_func) + return funcs +def read_enums(fn, prefix): + enums = [] + cur_categ = [] + + for line in InputFile(fn): + if ':' in line: + parts = line[:line.find(':')].split() + if len(parts)==2 and parts[1]=="enum": + cur_categ = parts[0] + elif cur_categ: + parts = line.split() + if parts[0]=="use": + enums.append(Enum(prefix+parts[2], cur_categ, None)) + elif parts[1]=="=": + try: + enums.append(Enum(prefix+parts[0], cur_categ, int(parts[2], 0))) + except ValueError, e: + sys.stderr.write("Syntax error in %s: %s\n"%(fn, e)) + + for e in enums: + if e.value is None: + for n in enums: + if n.name==e.name and n.value is not None: + e.value = n.value + if e.value is None: + sys.stderr.write("Could not find value for enum reference %s in category %s\n"%(e.name, e.category)) + + return enums + template = Template(sys.argv[1]) -functions = [] +apis = [] for i in sys.argv[2:]: - files = Files(i) - - typemap = Typemap(files.typemap) - iomap = IOmap(files.iomap) - for s in files.specs: - funcs = read_spec(s, files.prefix) - funcs = [f for f in funcs if f.name not in files.ignore_funcs and f.category not in files.ignore_categs] - for f in funcs: - f.finalize() - names = [f.name for f in funcs] - functions = [f for f in functions if f.name not in names]+funcs - -template.process(functions) + apis.append(Api(i)) + +template.process(apis) diff --git a/gl.files b/gl.api similarity index 75% rename from gl.files rename to gl.api index 8be2a33..40b44c7 100644 --- a/gl.files +++ b/gl.api @@ -2,5 +2,7 @@ typemap gl.tm iomap gl.io spec gl.spec prefix gl +enumspec enum.spec +enumprefix GL_ ignore category VERSION_3_2 ignore category ARB_sync diff --git a/glx.files b/glx.api similarity index 86% rename from glx.files rename to glx.api index bfac81e..f19df53 100644 --- a/glx.files +++ b/glx.api @@ -3,6 +3,8 @@ iomap glx.io spec glx.spec spec glxext.spec prefix glX +enumspec glxenum.spec +enumprefix GLX_ ignore category glxext ignore category SGIX_video_source ignore category SGIX_dmbuffer diff --git a/source/enums.table.t b/source/enums.table.t new file mode 100644 index 0000000..f90c851 --- /dev/null +++ b/source/enums.table.t @@ -0,0 +1,8 @@ +# $Id$ +!mode enums +:EnumInfo enums[] = +:{ +wl(' { 0x%X, "%s", "%s" },'%(enum.value, enum.category, enum.name)) +: { 0, 0, 0 } +:}; +:const unsigned enum_count = sizeof(enums)/sizeof(EnumInfo); -- 2.43.0