-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathGLib-2.0.awk
54 lines (54 loc) · 1.21 KB
/
GLib-2.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
#!/usr/bin/awk
#
# Patch the generated wrapper Swift code to handle special cases
#
BEGIN { etpInit = 0 ; vaptrptr = 0 ; longdouble = 0 }
/public convenience init.T: ErrorTypeProtocol./ {
etpInit = 1
print " /// Convenience copy constructor, creating a unique copy"
print " /// of the passed in Error. Needs to be freed using free()"
print " /// (automatically done in deinit if you use ErrorType)."
}
/self.init.other.ptr./ {
if (etpInit) {
print " self.init(g_error_copy(other.ptr))"
etpInit = 0
next
}
}
/no reference counting for GError, cannot ref/ { next }
/no reference counting for GError, cannot unref/ {
print " g_error_free(error_ptr)"
next
}
/ -> GIConv {/, /^}/ {
sub(/GIConv {/,"GIConv? {")
sub(/return rv/,"return rv == GIConv(bitPattern: -1) ? nil : rv")
}
/UnsafeMutablePointer.CVaListPointer/ {
vaptrptr = 1
print "#if !os(Linux)"
}
/Pointer<va_list>/ {
vaptrptr = 1
print "#if !os(Linux) && !arch(arm64)"
}
/CLongDouble/ {
longdouble = 1
print "#if !(os(Linux) && arch(arm64))"
}
/^$/ {
if (vaptrptr || longdouble) {
print "#endif"
longdouble = 0
vaptrptr = 0
}
}
/\/\/\// {
if (vaptrptr || longdouble) {
print "#endif"
longdouble = 0
vaptrptr = 0
}
}
// { print }