apple: Rename GLXcontext
[mesa.git] / src / glx / apple / gen_api_header.tcl
1
2 package require Tcl 8.5
3
4 set license {
5 /*
6 Copyright (c) 2008, 2009 Apple Inc.
7
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated documentation files
10 (the "Software"), to deal in the Software without restriction,
11 including without limitation the rights to use, copy, modify, merge,
12 publish, distribute, sublicense, and/or sell copies of the Software,
13 and to permit persons to whom the Software is furnished to do so,
14 subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT
23 HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 DEALINGS IN THE SOFTWARE.
27
28 Except as contained in this notice, the name(s) of the above
29 copyright holders shall not be used in advertising or otherwise to
30 promote the sale, use or other dealings in this Software without
31 prior written authorization.
32 */
33 }
34
35 set this_script [info script]
36
37 proc main {argc argv} {
38 if {2 != $argc} {
39 puts stderr "syntax is: [set ::this_script] serialized-array-file output.h"
40 return 1
41 }
42
43 set fd [open [lindex $argv 0] r]
44 array set api [read $fd]
45 close $fd
46
47 set fd [open [lindex $argv 1] w]
48
49 puts $fd "/* This file was automatically generated by [set ::this_script]. */"
50 puts $fd $::license
51
52 puts $fd "
53 #ifndef APPLE_XGL_API_H
54 #define APPLE_XGL_API_H
55 "
56
57 puts $fd "struct apple_xgl_api \{"
58
59 set sorted [lsort -dictionary [array names api]]
60
61 foreach f $sorted {
62 set attr $api($f)
63 set pstr ""
64
65 if {[dict exists $attr alias_for] || [dict exists $attr noop]} {
66 #Skip this function.
67 continue
68 }
69
70 foreach p [dict get $attr parameters] {
71 append pstr "[lindex $p 0] [lindex $p 1], "
72 }
73
74 set pstr [string trimright $pstr ", "]
75 puts $fd "\t[dict get $attr return] (*[set f])([set pstr]);"
76 }
77
78 puts $fd "\};"
79 puts $fd "void apple_xgl_init_direct(void);
80
81 #endif /*APPLE_XGL_API_H*/
82 "
83
84 return 0
85 }
86 exit [main $::argc $::argv]