-
Notifications
You must be signed in to change notification settings - Fork 26
/
Gtk-3.0.awk
187 lines (187 loc) · 5.99 KB
/
Gtk-3.0.awk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/usr/bin/awk
#
# Patch the generated wrapper Swift code to handle special cases
#
BEGIN { depr_init = 0 ; comment = 0 ; slist = 0 ; overr = 0 ; ostock = 0 ;
no_fields = 0 ; close_comment = 0; icon_size = 0 ; grp = 0
}
/Creates a new `GtkRecentChooserMenu` widget\.$/ { overr = 1 }
/a swatch representing the current selected color. When the button/ { overr = 1 }
#/Creates a new dialog box/ { overr = 1 }
/Creates a new font picker widget/ { overr = 1 }
/Creates a new toggle button/ { overr = 1 }
/Creates a new GtkModelButton/ { overr = 1 ; sub("GtkModelButton", "`GtkModelButton`") }
/Creates a new `GtkAboutDialog`\.$/ { overr = 1 }
/Creates a new `GtkCellRendererAccel`/ { overr = 1 }
/Creates a new `GtkCellRendererCombo`/ { overr = 1 }
/Creates a new `GtkCellRendererSpin`/ { overr = 1 }
/Creates a new `GtkCheckButton`/ { overr = 1 }
/Creates a new `GtkCheckMenuItem`/ { overr = 1 }
/Creates a new `GtkComboBoxText`/ { overr = 1 }
/Creates a new `GtkImageMenuItem` with an empty label/ { overr = 1 }
/Creates a new `GtkImageMenuItem` containing a label/ { overr = 1 }
/Creates a new `GtkMenuButton`/ { overr = 1 }
/Creates a new `GtkMenuToolButton`/ { overr = 1 }
/Creates a `GtkSearchEntry`/ { overr = 1 }
/Creates a new `GtkSeparatorMenuItem`/ { overr = 1 }
/Create a new `GtkSeparatorToolItem`/ { overr = 1 }
/Creates a new `GtkTearoffMenuItem`/ { overr = 1 }
/Creates a new `GtkToggleAction`/ { overr = 1 }
/Creates a new `GtkToggleButton`/ { overr = 1 }
/Creates a new `GtkToggleToolButton`/ { overr = 1 }
/Creates a new `GtkRecentAction`/ { ostock = 1 }
/ the file belongs to/ { grp = 1 }
/open .* ColorSelection/ { depr_init = 1 }
/public .* ColorSelection/ { depr_init = 1 }
/public .* HSV/ { depr_init = 1 }
/open .* HSV/ { depr_init = 1 }
/open .* HSV/ { depr_init = 1 }
/func getColumnHeaderCells/ { comment = 1 }
/func getRowHeaderCells/ { comment = 1 }
/get.* -> GtkIconSize {$/ { icon_size = 1 }
/: GtkIconSize {$/ { icon_size = 1 }
/let rv = / { icon_size = 0 }
/let rv: Int / {
if (icon_size) {
gsub("Int", "GtkIconSize")
}
}
/ return Int.rv.$/ {
if (icon_size) {
icon_size = 0;
gsub("Int.rv.", "rv")
}
}
/return/ { icon_size = 0; }
/extension _MountOperationHandlerIfaceProtocol/ { no_fields = 1; }
/extension _MountOperationHandlerProxyClassProtocol/ { no_fields = 1; }
/extension _MountOperationHandlerSkeletonClassProtocol/ { no_fields = 1; }
/^ @inlinable var [a-z]/ {
if (no_fields) {
print "#if false"
no_fields = 0;
close_comment = 1;
}
}
/^ }$/ {
if (close_comment) {
print
print "#endif"
close_comment = 0;
next
}
}
/var groups: UnsafeMutablePointer<UnsafeMutablePointer<gchar>/ {
if (grp) {
grp = 0
print " @inlinable var groups: UnsafeMutablePointer<UnsafePointer<gchar>?>! {"
next
}
}
/^[^ ]/ { slist = 0 ; grp = 0 }
/ UnsafeMutablePointer<GSList>! {/ {
slist = 1
gsub("UnsafeMutablePointer.GSList..", "SListRef!")
}
/return cast.rv.$/ {
if (slist) {
gsub("cast.rv.", "rv.map { SListRef($0) }")
}
}
/cast.newValue./ {
if (slist) {
gsub("cast.newValue.", "cast(newValue.map { $0.ptr })")
slist = 0
}
}
/^ }$/ { slist = 0 }
/^ @inlinable public init[(]font fontname:/ {
overr = 0
}
/^ @inlinable public init[<(]/ {
if (overr) {
gsub("public", "override public")
overr = 0
}
}
/^ @inlinable public init.*stockID: UnsafePointer<gchar>. = nil[)]/ {
if (ostock) {
gsub("public", "override public")
ostock = 0
}
}
/ init.. {/ {
if (depr_init) {
printf(" @available(*, deprecated)\n")
depr_init = 0
}
}
/ init. title:/ {
if (depr_init) {
printf(" @available(*, deprecated)\n")
depr_init = 0
}
}
/^open class RadioButton:/ {
print
print " /// Constructor for creating a RadioButton with a text label,"
print " /// creating a new group."
print " ///"
print " /// - Parameter label: the label to use for the button"
print " @inlinable public override init(label: UnsafePointer<gchar>!) {"
print " let rv = gtk_radio_button_new_with_label(nil, label)"
print " super.init(gpointer: gpointer(rv))"
print " }"
print ""
print " /// Constructor for creating a RadioButton with a text label"
print " /// that contains menomics creates a new group. Underscores in `label`"
print " /// indicate the mnemonic for the button."
print " ///"
print " /// - Parameter label: the label (including mnemonic) to use for the button"
print " @inlinable public override init(mnemonic label: UnsafePointer<gchar>!) {"
print " let rv = gtk_radio_button_new_with_mnemonic(nil, label)"
print " super.init(gpointer: gpointer(rv))"
print " }"
print ""
next
}
/^open class RadioMenuItem:/ {
print
print " /// Constructor for creating a RadioMenuItem with a text label,"
print " /// creating a new group."
print " ///"
print " /// - Parameter label: the label to use for the button"
print " @inlinable public override init(label: UnsafePointer<gchar>!) {"
print " let rv = gtk_radio_menu_item_new_with_label(nil, label)"
print " super.init(gpointer: gpointer(rv))"
print " }"
print ""
print " /// Constructor for creating a RadioMenuItem with a text label"
print " /// that contains menomics and creates a new group. Underscores in `label`"
print " /// indicate the mnemonic for the button."
print " ///"
print " /// - Parameter label: the label (including mnemonic) to use for the button"
print " @inlinable public override init(mnemonic label: UnsafePointer<gchar>!) {"
print " let rv = gtk_radio_menu_item_new_with_mnemonic(nil, label)"
print " super.init(gpointer: gpointer(rv))"
print " }"
print ""
next
}
/^open class RadioToolButton:/ {
print
print " /// Convenience constructor for creating a RadioToolButton group."
print " @inlinable public override init() {"
print " let rv = gtk_radio_tool_button_new(nil)"
print " super.init(gpointer: gpointer(rv))"
print " }"
print ""
next
}
// {
if (comment) {
printf("// ")
}
print
}
/^ }$/ { comment = 0 ; overr = 0 ; ostock = 0 }