1 #This parses and generates #defines from an enum.spec type of file.
3 proc main
{argc argv
} {
5 puts stderr
"syntax is: [info script] input.spec output.h"
9 set fd
[open [lindex $argv 0] r
]
13 set fd
[open [lindex $argv 1] w
]
17 puts $fd "#define GL_VERSION_1_1 1"
18 puts $fd "#define GL_VERSION_1_2 1"
19 puts $fd "#define GL_VERSION_1_3 1"
20 puts $fd "#define GL_VERSION_1_4 1"
21 puts $fd "#define GL_VERSION_1_5 1"
22 puts $fd "#define GL_VERSION_2_0 1"
23 #puts $fd "#define GL_VERSION_3_0 1"
28 foreach line
[split $data \n] {
29 if {[regexp {^
\S
*#.*} $line] > 0} {
32 } elseif
{"enum" eq
$state} {
33 if {[string match
"\t*" $line]} {
34 if {[regexp {^
\tuse.
*} $line] > 0} {
35 lassign
[split [string trim
$line]] use usemask def
36 set usemask
[string trim
$usemask]
37 set def
[string trim
$def]
38 puts $fd "/* GL_$def */"
40 lassign
[split [string trim
$line] =] def value
41 set def
[string trim
$def]
42 set value
[string trim
$value]
44 #Trim out the data like: 0x0B00 # 4 F
45 set value
[lindex [split $value] 0]
47 puts $fd "#define GL_$def $value"
49 #Save this association with the value.
51 dict
set d
$def $value
57 } elseif
{[string match
"* enum:*" $line]} {
58 lassign
[split $line] mask _
59 puts $fd "\n/*[string trim $mask]*/"
60 set ar
($mask) [dict create
]