summaryrefslogtreecommitdiff
path: root/src/glx/apple/gen_defs.tcl
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2010-04-01 11:01:31 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2010-04-27 11:26:50 -0700
commitad503c41557606d15b0420c824369456f6d20a8f (patch)
tree7155272412f9b20b559fa172a1718fd8dfe6e98a /src/glx/apple/gen_defs.tcl
parentf1381880a8e0e0cdd96c4c725ff35a28b250b09d (diff)
apple: Initial import of libGL for OSX from AppleSGLX svn repository.
Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
Diffstat (limited to 'src/glx/apple/gen_defs.tcl')
-rw-r--r--src/glx/apple/gen_defs.tcl67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/glx/apple/gen_defs.tcl b/src/glx/apple/gen_defs.tcl
new file mode 100644
index 0000000000..d32694db72
--- /dev/null
+++ b/src/glx/apple/gen_defs.tcl
@@ -0,0 +1,67 @@
+#This parses and generates #defines from an enum.spec type of file.
+
+proc main {argc argv} {
+ if {2 != $argc} {
+ puts stderr "syntax is: [info script] input.spec output.h"
+ exit 1
+ }
+
+ set fd [open [lindex $argv 0] r]
+ set data [read $fd]
+ close $fd
+
+ set fd [open [lindex $argv 1] w]
+
+ set state ""
+
+ puts $fd "#define GL_VERSION_1_1 1"
+ puts $fd "#define GL_VERSION_1_2 1"
+ puts $fd "#define GL_VERSION_1_3 1"
+ puts $fd "#define GL_VERSION_1_4 1"
+ puts $fd "#define GL_VERSION_1_5 1"
+ puts $fd "#define GL_VERSION_2_0 1"
+ #puts $fd "#define GL_VERSION_3_0 1"
+
+ set mask ""
+ array set ar {}
+
+ foreach line [split $data \n] {
+ if {[regexp {^\S*#.*} $line] > 0} {
+ #puts COMMENT:$line
+ set state ""
+ } elseif {"enum" eq $state} {
+ if {[string match "\t*" $line]} {
+ if {[regexp {^\tuse.*} $line] > 0} {
+ lassign [split [string trim $line]] use usemask def
+ set usemask [string trim $usemask]
+ set def [string trim $def]
+ puts $fd "/* GL_$def */"
+ } else {
+ lassign [split [string trim $line] =] def value
+ set def [string trim $def]
+ set value [string trim $value]
+
+ #Trim out the data like: 0x0B00 # 4 F
+ set value [lindex [split $value] 0]
+
+ puts $fd "#define GL_$def $value"
+
+ #Save this association with the value.
+ set d $ar($mask)
+ dict set d $def $value
+ set ar($mask) $d
+ }
+ } else {
+ set state ""
+ }
+ } elseif {[string match "* enum:*" $line]} {
+ lassign [split $line] mask _
+ puts $fd "\n/*[string trim $mask]*/"
+ set ar($mask) [dict create]
+ set state enum
+ }
+ }
+
+ close $fd
+}
+main $::argc $::argv