Skip to content

Commit

Permalink
Fixed persisting problems with GL_TIMEOUT_IGNORED.
Browse files Browse the repository at this point in the history
Switched back to C macros for enums.
  • Loading branch information
ginkgo committed Jul 12, 2011
1 parent 1f8cafe commit 3f9f643
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion example/Makefile
Expand Up @@ -21,7 +21,7 @@ flextGL.o: generated/flextGL.c
gcc $(CFLAGS) -c generated/flextGL.c

generated/flextGL.c: profile.txt
python2 ../flextGLgen.py -T compatible -D generated profile.txt
python2.7 ../flextGLgen.py -T compatible -D generated profile.txt

clean:
rm -f *.o
Expand Down
14 changes: 8 additions & 6 deletions flextGLgen.py
Expand Up @@ -3,6 +3,7 @@
from optparse import OptionParser
import os.path
from glob import glob
import numbers

from Cheetah.Template import Template

Expand Down Expand Up @@ -265,7 +266,7 @@ def parse_enums(categories):

# There are sometimes 0xffffffffffff... enums defined
# To handle those, we truncate enum values to 32 bit.
enumvalue = int(int(match.group(2), 0) & 0x7fffffff)
enumvalue = long(long(match.group(2), 0) & 0x7fffffffffffffff)

current_enums[enumname] = enumvalue
elif refenumpattern.match(line):
Expand Down Expand Up @@ -297,17 +298,18 @@ def parse_enums(categories):



if not isinstance(realvalue, int) and not isinstance(realvalue, long):
if not isinstance(realvalue, numbers.Integral):
# let's try brute force
for category2 in enums.itervalues():
for name2, value2 in category2.iteritems():
if name2 == name and isinstance(value2, int):
if name2 == name and isinstance(value2, numbers.Integral):
realvalue = value2
if name2 == value and isinstance(value2, int):
if name2 == value and isinstance(value2, numbers.Integral):
realvalue = value2

if not isinstance(realvalue, int) and not isinstance(realvalue, long):
print("Could not resolve reference for enum %s = %s" % (name,value))
if not isinstance(realvalue, numbers.Integral):
print("Could not resolve reference for enum %s = %s (%s)" % (name,value,realvalue))
exit(1)

category[name] = realvalue

Expand Down
4 changes: 1 addition & 3 deletions templates/compatible/flextGL.h.template
Expand Up @@ -52,11 +52,9 @@ $passthru

//----------------------------------- ENUMS ---------------------------------//

enum extGLenum {
#for $enum,$value in $enums
GL_$enum $(' ' * ($longest_enum-len($enum))) = $hex($value),
#define GL_$enum $(' ' * ($longest_enum-len($enum))) ${"0x%x" % ($value)}
#end for
};
//------------------------ FUNCTION PROTOTYPES -----------------------------//

#for $category in $categories
Expand Down
5 changes: 2 additions & 3 deletions templates/glfw/flextGL.h.template
Expand Up @@ -52,11 +52,10 @@ $passthru

//----------------------------------- ENUMS ---------------------------------//

enum extGLenum {
#for $enum,$value in $enums
GL_$enum $(' ' * ($longest_enum-len($enum))) = $hex($value),
#define GL_$enum $(' ' * ($longest_enum-len($enum))) ${"0x%x" % ($value)}
#end for
};

//------------------------ FUNCTION PROTOTYPES -----------------------------//

#for $category in $categories
Expand Down

0 comments on commit 3f9f643

Please sign in to comment.